Firms reduce investment to avoid costly violations of financial covenants, most of which are based on earnings. Empirically, I show that a 25% drop in earnings implies a 15% decrease in investment for the median listed US firm due to the reduced distance to the covenant threshold. To quantify this precautionary effect of covenants in the aggregate, I incorporate earnings covenants into a heterogeneous firm model with a financial sector. In the model, covenants reduce aggregate investment by 14% relative to a benchmark economy without limits on borrowing, where the precautionary effect of covenants accounts for most of the decrease.