This paper studies the optimal design of rules in a dynamic model when there is a time inconsistency problem and uncertainty about whether the policy maker can commit to follow the rule ex post. The policy maker can either be a commitment type, which can always commit to follow rules, or an optimizing type, which sequentially decides whether to follow rules or not. This type is unobservable to private agents, who learn about it through the actions of the policy maker. Higher beliefs that the policy maker is the commitment type (i.e., the policy maker’s reputation) help promote good behavior by private agents. We show that in a large class of economies, preserving uncertainty about the policy maker’s type is preferable from an ex-ante perspective. If the initial reputation is not too high, the optimal rule is the strictest one that is incentive compatible for the optimizing type. We show that reputational considerations imply that the optimal rule is more lenient than the one that would arise in a static environment. Moreover, opaque rules are preferable to transparent ones if reputation is high enough.