  Universal quantum computation requires the implementation of a logical
non-Clifford gate. In this paper, we characterize all stabilizer codes whose
code subspaces are preserved under physical $T$ and $T^{-1}$ gates. For
example, this could enable magic state distillation with non-CSS codes and,
thus, provide better parameters than CSS-based protocols. However, among
non-degenerate stabilizer codes that support transversal $T$, we prove that CSS
codes are optimal. We also show that triorthogonal codes are, essentially, the
only family of CSS codes that realize logical transversal $T$ via physical
transversal $T$. Using our algebraic approach, we reveal new purely-classical
coding problems that are intimately related to the realization of logical
operations via transversal $T$. Decreasing monomial codes are also used to
construct a code that realizes logical CCZ. Finally, we use Ax's theorem to
characterize the logical operation realized on a family of quantum Reed-Muller
codes. This result is generalized to finer angle $Z$-rotations in
arXiv:1910.09333.
