Natural and synthetic guide stars can serve as beacons for Shack-Hartmann wavefront sensors in space-based applications. In this paper, the authors determine the key equations that govern the optimization of the wavefront sensor employed on a space-based imaging system. There are two major products of this analysis. First, the number of subapertures can be optimized. Second, the number of modes used in the wavefront recovery can be optimized. Finally, the process for optimizing these values is explained. For the examples shown, the optimal number of retrieved modes and the optimal number of subapertures are determined.