The intrinsic oscillatory activity of central pattern generators underlies motor rhythm. We review and discuss recent findings that address the origin of Caenorhabditis elegans motor rhythm. These studies propose that the A- and mid-body B-class excitatory motor neurons at the ventral cord function as non-bursting intrinsic oscillators to underlie body undulation during reversal and forward movements, respectively. Proprioception entrains their intrinsic activities, allows phase-coupling between members of the same class motor neurons, and thereby facilitates directional propagation of undulations. Distinct pools of premotor interneurons project along the ventral nerve cord to innervate all members of the A- and B-class motor neurons, modulating their oscillations, as well as promoting their bi-directional coupling. The two motor sub-circuits, which consist of oscillators and descending inputs with distinct properties, form the structural base of dynamic rhythmicity and flexible partition of the forward and backward motor states. These results contribute to a continuous effort to establish a mechanistic and dynamic model of the C. elegans sensorimotor system. C. elegans exhibits rich sensorimotor functions despite a small neuron number. These findings implicate a circuit-level functional compression. By integrating the role of rhythm generation and proprioception into motor neurons, and the role of descending regulation of oscillators into premotor interneurons, this numerically simple nervous system can achieve a circuit infrastructure analogous to that of anatomically complex systems. C. elegans has manifested itself as a compact model to search for general principles of sensorimotor behaviours.This article is part of a discussion meeting issue 'Connectome to behaviour: modelling C. elegans at cellular resolution'. © 2018 The Author(s).