In this paper we develop a new methodology for finding optimal government policies in economies with heterogeneous agents. The methodology is solely based on three classes of equilibrium conditions from the government's and individual agent's optimization problems: 1) the first order conditions; 2) the stationarity condition on the distribution function; and, 3) the aggregate market clearing conditions