This paper studies a novel distributed precoding scheme for cell-free massive MIMO networks. Our scheme, coined team minimum mean-square error (TMMSE) precoding, generalizes classical centralized MMSE precoding to arbitrary patterns of channel state information (CSIT) sharing among the transmitters. Building on the so-called theory of teams, we show that designing the optimal TMMSE precoders is equivalent to solving an infinite dimensional linear system of equations. We solve the problem explicitly for two important CSIT sharing patterns, i.e., the classical case of purely local CSIT and the case of unidirectional CSIT sharing along a serial fronthaul. The latter scenario is relevant, e.g., for the recently proposed radio stripes concept. In both cases, our optimal design outperforms the heuristic methods that are known from the previous literature. Duality arguments and numerical simulations validate the effectiveness of the proposed schemes in terms of ergodic achievable rates under a sum power constraint.