Cadmium telluride (CdTe) is a p-type semiconductor used in thin-film solar cells. To achieve high light-to-electricity conversion, annealing in the presence of CdCl2 is essential, but the underlying mechanism is still under debate. Recent evidence suggests that a reduction in the high density of stacking faults in the CdTe grains is a key process that occurs during the chemical treatment. A range of stacking faults, including intrinsic, extrinsic, and twin boundary, are computationally investigated to identify the extended defects that limit performance. The low-energy faults are found to be electrically benign, while a number of higher energy faults, consistent with atomic-resolution micrographs, are predicted to be hole traps with fluctuations in the local electrostatic potential. It is expected that stacking faults will also be important for other thin-film photovoltaic technologies.