Yu-Shiba-Rusinov states are subgap bound states induced by magnetic impurity atoms in a superconductor. These states can be used as building blocks in constructing an effective topological superconductor. Here we formulate a unified theory of topological superconductivity in different dimensions based on Yu-Shiba-Rusinov states, and demonstrate its application with simple but illustrative examples. Such a theory underlies a number of recent experiments on the related platform.