A ruthenium-catalyzed, atom-economical synthesis of nitrogen heterocycles.