During vertebrate development, spinal neurons differentiate and connect to generate a system that performs sensorimotor functions critical for survival. Spontaneous Ca2+ activity regulates different aspects of spinal neuron differentiation. It is unclear whether environmental factors can modulate this Ca2+ activity in developing spinal neurons to alter their specialization and ultimately adjust sensorimotor behavior to fit the environment. Here, we show that growing Xenopus laevis embryos at cold temperatures results in an increase in the number of spinal motor neurons in larvae. This change in spinal cord development optimizes the escape response to gentle touch of animals raised in and tested at cold temperatures. The cold-sensitive channel TRPM8 increases Ca2+ spike frequency of developing ventral spinal neurons, which in turn regulates expression of the motor neuron master transcription factor HB9. TRPM8 is necessary for the increase in motor neuron number of animals raised in cold temperatures and for their enhanced sensorimotor behavior when tested at cold temperatures. These findings suggest the environment modulates neuronal differentiation to optimize the behavior of the developing organism.