Contact planning is crucial to the locomotion performance of robots: to properly self-propel forward, it is not only important to determine the sequence of internal shape changes (e.g., body bending and limb shoulder joint oscillation) but also the sequence by which contact is made and broken between the mechanism and its environment. Prior work observed that properly coupling contact patterns and shape changes allows for computationally tractable gait design and efficient gait performance. The state of the art, however, made assumptions, albeit motivated by biological observation, as to how contact and shape changes can be coupled. In this paper, we extend the geometric mechanics (GM) framework to design contact patterns. Specifically, we introduce the concept of “contact space” to the GM framework. By establishing the connection between velocities in shape and position spaces, we can estimate the benefits of each contact pattern change and therefore optimize the sequence of contact patterns. In doing so, we can also analyze how a contact pattern sequence will respond to perturbations. We apply our framework to sidewinding robots and enable (1) effective locomotion direction control and (2) robust locomotion performance as the spatial resolution decreases. We also apply our framework to a hexapod robot with two back-bending joints and show that we can simplify existing hexapod gaits by properly reducing the number of contact state switches (during a gait cycle) without significant loss of locomotion speed. We test our designed gaits with robophysical experiments, and we obtain good agreement between theory and experiments.