We describe Pegasus, a new hybrid-kinetic particle-in-cell code tailored for the study of astrophysical plasma dynamics. The code incorporates an energy-conserving particle integrator into a stable, second-order--accurate, three-stage predictor-predictor-corrector integration algorithm. The constrained transport method is used to enforce the divergence-free constraint on the magnetic field. A delta-f scheme is included to facilitate a reduced-noise study of systems in which only small departures from an initial distribution function are anticipated. The effects of rotation and shear are implemented through the shearing-sheet formalism with orbital advection. These algorithms are embedded within an architecture similar to that used in the popular astrophysical magnetohydrodynamics code Athena, one that is modular, well-documented, easy to use, and efficiently parallelized for use on thousands of processors. We present a series of tests in one, two, and three spatial dimensions that demonstrate the fidelity and versatility of the code.