It is widely believed that governments tend to over accumulate debt, which gives rise to the need for fiscal rules. This paper studies the optimal fiscal and default rules when governments can default on their debt obligations. We build a continuous-time model that encompasses the standard rationale for debt overaccumulation: hyperbolic discounting and political economy frictions. In addition, governments are subject to taste shocks, which makes spending optimally random. Since shocks are private information, there is a trade-off between rules and discretion. We derive the optimal fiscal rules which are debt-dependent only when default is possible. Depending on the severity of the spending bias and the cost of default, the optimal fiscal rules range from strict debt limits, complemented by strong deficit limits, to the absence of all rules. In intermediate cases, debt-dependent deficit limits must be complemented with default rules, with some areas where default is forbidden and others where default is forced.