Table of Contents
If Claude Code takes the wrong approach, press Esc twice or enter /rewind. Select an earlier prompt, then choose whether to restore the conversation, restore the code, restore both, or summarize part of the session. The important step is choosing the option that matches what you want to keep.
Rewind is more capable than simply asking “undo that,” but it is not a replacement for Git. Claude Code checkpoints track edits made through Claude's file-editing tools; they do not reverse deployments, database writes, API calls, or every shell command.
How Claude Code checkpoints work
Each user prompt creates a checkpoint. Before Claude edits a file with its editing tools, Claude Code snapshots the affected content. Those snapshots allow a later checkpoint to restore tracked file edits without requiring you to set up checkpointing manually.
Checkpoints are associated with the local session and can remain available when a session is resumed. Anthropic's current checkpointing documentation says they are cleaned up with sessions after the configured retention period, which defaults to 30 days.
Open the rewind menu
- Return to the Claude Code input prompt.
- Press
Esctwice in succession, or type/rewind. - Use the scrollable list to select the prompt before the work you want to revise.
- Choose the appropriate restore or summary action.
A single Esc has a different purpose: it interrupts Claude while preserving the current context so you can redirect the work. Double Esc opens the checkpoint menu.
Understand the rewind options
| Option | Conversation | Files | Use it when |
|---|---|---|---|
| Restore code and conversation | Rewinds to the selected prompt | Reverts tracked Claude edits after that point | Both the reasoning path and implementation are unwanted |
| Restore conversation | Rewinds to the selected prompt | Keeps current files | The code is useful, but you want a cleaner or different dialogue branch |
| Restore code | Keeps the full conversation | Reverts tracked Claude edits | You want to discuss what failed while discarding the implementation |
| Summarize from here | Compresses the selected point forward | Keeps files | Later turns contain lessons worth retaining without their full token cost |
| Summarize up to here | Compresses earlier turns and keeps later ones | Keeps files | The recent work matters, but old setup detail is consuming context |
After restoring a conversation or selecting Summarize from here, Claude Code returns the selected prompt to the input field so you can edit and resend it. Review that prompt instead of sending it unchanged.
Example: replace a failed refactor
Suppose Claude first inspects the repository correctly, then introduces an unnecessary plugin architecture. Open /rewind and choose the prompt that requested the refactor.
If you want to discard both the plugin implementation and the turns discussing it, choose Restore code and conversation. Then replace the original request with a smaller one:
The current entry point loads configuration directly.
Extract only the configuration-loading code into a separate module.
Keep the existing public behavior and dependencies.
Run the current tests after the change, and stop if the tests reveal an unrelated failure.
This preserves the earlier session context while giving Claude a more precise goal and stopping condition.
Preserve lessons without keeping the full dead end
A failed attempt may expose an incompatible library, a hidden test requirement, or a useful architectural constraint. In that case, use Summarize from here rather than erasing the later conversation. Review the generated summary and correct anything important before continuing.
You can also record durable facts in project documentation or a task note. Context management should not be the only place where a critical migration constraint exists.
What rewind cannot undo
- Files edited manually or by another process may not be covered.
- Shell commands can create side effects outside Claude's tracked edit snapshots.
- Database writes, messages, payments, API calls, deployments, and remote repository actions cannot be rolled back by a local checkpoint.
- Untracked files or edits made concurrently can make a restore differ from what you expect.
- A restored file state does not automatically restore running processes, installed packages, caches, or environment variables.
Before restoring code, run git status and inspect the working tree. If unrelated user changes are present, copy or commit them safely first. For a broader version-control workflow, see how to use Git effectively.
Verify after restoring
- Run
git statusand inspect the files that changed. - Use
git diffor your editor's comparison view to confirm the expected state. - Run the smallest relevant test or build command.
- Check for generated files, dependency changes, or processes that a checkpoint did not restore.
- Only then send the revised implementation prompt.
If the repository was clean before the failed attempt, Git provides a useful independent reference. Do not use destructive Git commands casually, especially when the working tree contains changes that predate Claude's work.
When to rewind, interrupt, clear, or ask for an undo
- Press Esc once: Claude is still working and you can already see the direction is wrong.
- Use /rewind: you want to return conversation, code, or both to a particular prompt.
- Ask “undo that”: the most recent change is small and you want Claude to reverse it while retaining the discussion.
- Use a summary option: the session contains useful findings but too much detailed history.
- Use /clear: you are starting an unrelated task or repeated corrections have made the current context confusing.
Troubleshooting
The rewind menu does not open
Make sure you are at the CLI input prompt, then press and release Esc twice. In the VS Code extension, hover over a message and use its rewind control; the extension presents actions through the interface rather than depending entirely on the CLI shortcut.
The code changed when you wanted only a cleaner conversation
Use Restore conversation, not Restore code and conversation. Read the action description before confirming it.
A command's side effect remains
This is expected for effects outside tracked file edits. Use the service's own rollback procedure, a database transaction or backup, the package manager, or Git as appropriate. If rollback could delete data or affect users, stop and verify the exact target first.
You rewound too far
Check whether the session and checkpoint still provide a later restore point, and inspect Git history or the terminal transcript. Avoid reconstructing code from memory when a commit, diff, or backup can establish the correct state.
Reader Comments 0
Sign in with email or Google to join the discussion.