Using a quantitative sovereign default model, we characterize constrained efficient borrowing by a Ramsey government that commits to income-history-contingent borrowing paths taking as given ex-post optimal future default decisions. The Ramsey government improves upon the Markov government because it internalizes the effects of borrowing decisions in period t on borrowing opportunities prior to t. We show the effect of borrowing decisions in t on utility flows prior to t can be encapsulated by two single dimensional variables. Relative to a Markov government, the Ramsey government distorts borrowing decisions more when bond prices are more sensitive to borrowing, and changes in bond prices have a larger effect on past utility. In a quantitative exercise, more than 80% of the default risk is eliminated by a Ramsey government, without decreasing borrowing. The Ramsey government also has a higher probability of completing a successful deleveraging (without defaulting), while smoothing out the fiscal consolidation.