We report the assembly and thermal transformation of linear diamondoid assemblies inside carbon nanotubes. Our calculations and observations indicate that these molecules undergo selective reactions within the narrow confining space of a carbon nanotube. Upon vacuum annealing of adamantane molecules encapsulated in a carbon nanotube, we observe a sharp Raman feature at 1857 cm(-1), which we interpret as a stretching mode of carbon chains formed by thermal conversion of adamantane inside a carbon nanotube. Introduction of pure hydrogen during thermal annealing, however, suppresses the formation of carbon chains and seems to keep adamantane intact.