We study optimal labor and capital taxation in a dynamic economy subject to government expenditure and aggregate productivity shocks. We relax two assumptions from Ramsey models: that a representative agent exists and that taxation is proportional with no lump-sum tax. In contrast, we capture a redistributive motive for distortive taxation by allowing privately observed differences in relative skills across workers. We consider two scenarios for tax instruments: (i) taxation is linear with arbitrary intercept and slope; and (ii) taxation is non-linear and unrestricted as in Mirrleesian models. Our main result provides conditions for perfect tax smoothing: marginal taxes on labor income should remain constant over time and invariant to shocks. In addition, capital should not be taxed. We also discuss implications for optimal debt management. Finally, an extension highlights movements in the distribution of relative skills as a potential source for variations in optimal marginal tax rates.