An internal coordinate system describes the geometry of a molecule using the relative positions and orientations of atoms within the molecule, in contrast to the Cartesian coordinate system which describes the geometry using the absolute positions of each atom. The most common types of internal coordinates are the two-atom bond distances, three-atom bending angles, and four-atom dihedral angles. A sufficiently large set of these three types of internal coordinates can fully represent all internal degrees of freedom of a molecule. To facilitate automation, our algorithm is capable of automatically determining an appropriate set of internal coordinates. Notably, the algorithm handles systems with linear bending angles by replacing those coordinates with alternate coordinates, adding dummy atoms where necessary. Without this functionality, optimization algorithms in internal coordinates will often crash due to derivative discontinuities in bending angle degrees of freedom.