Skip to content

Rewind to a checkpoint with /rewind

You handed the agent the next chunk of the rate-limiter feature — “add role-based checks to the API” — and went to refill your coffee. Five minutes turned into fifteen. When you sit back down, Claude Code has been busy: it has wired role checks into the top-level middleware, refactored three handlers around that, and written tests for the whole arrangement. There’s just one problem. You meant the checks to be per-route — the middleware approach is exactly wrong, and it’s now load-bearing under fifteen minutes of confident follow-on work.

This is the failure mode that makes people nervous about letting an agent run: not that it does nothing, but that it does a lot, well, in the wrong direction. The instinct is to start typing corrections — “no, move those into the handlers” — and patch forward. Resist it. Patching forward from a broken base means the agent is now reasoning about your correction on top of its mistake, and the conversation fills with the tension between the two. There’s a cleaner way out, and it’s to pretend the last fifteen minutes didn’t happen.

Press Esc twice — or type /rewind — to open the checkpoint picker. Claude Code quietly snapshots state at each of your turns, so the picker is a list of moments you can return to:

> [Esc][Esc]
Rewind to checkpoint:
now
"write tests for the role checks" 2 min ago
"add the admin override too" 9 min ago
❯ "add role-based checks to the API" 16 min ago ← right before the misread
"wire the limiter into /login" 40 min ago
Restore: ❯ code + conversation conversation only code only

Land on the checkpoint just before the misread, and choose what comes back with you. Usually you want code + conversation — the files revert and the dead-end discussion vanishes, as if you’d never sent that prompt. Occasionally you’ll want conversation only (keep the agent’s reasoning visible but undo the edits) or code only (roll back files while keeping a note of what went wrong) — but the default is the clean slate. Pick it, and the sixteen-minute detour is gone, files and chatter both, while everything before it stays exactly intact:

⎿ Restored to 16 min ago. 4 files reverted, conversation trimmed.
> the role checks are per-route, not global — add them in each handler that
needs them, not in the top-level middleware
[picks up from the good checkpoint, this time with the right framing]

You didn’t argue the agent out of its mistake. You removed the mistake and re-asked the question better.

It’s worth being precise about what rewind actually covers, because getting this wrong is how people lose work. Rewind is the agent’s undo, not git. It rolls back what Claude Code changed during this session. It does not touch anything you’d already committed, anything you edited by hand outside the agent, or side effects that escaped the session — a migration that already ran against your database, a branch you pushed. Those live outside the checkpoint and stay exactly as they are.

Which is why the habit that makes rewind safe lives in git. Commit at green checkpoints: every time the agent reaches a genuinely working state, lock it in with a commit. Then the two undo systems cover different scales — rewind cleans up the agent’s mess within a working block, git holds the line between blocks — and there’s almost no amount of agent flailing that can cost you real work. With that rhythm in place you can let the agent run on a much longer leash, because a wrong turn now costs one keystroke instead of an afternoon.

One restraint, though: don’t over-rewind. If only the last turn went sideways, step back one checkpoint, not five. It’s tempting to nuke a big stretch out of frustration, but every checkpoint you jump past throws away good work along with the bad. Rewind to the mistake — not to before you were having a good day.

The role checks are right now, per-route, and the agent is moving cleanly again. The feature’s nearly done — except you’ve reached the kind of decision the agent can’t make for you. The validation layer could go two ways, and you genuinely don’t know which is better until you’ve seen both.

So instead of guessing, you’re going to build it both ways at once — without letting either version contaminate the other.