Claude Code /rewind and /undo: checkpoints, what isn't tracked, and branching sessions
How Claude Code checkpoints work (/rewind, /undo, Esc twice), what isn't tracked (Bash and subagents), and visual rewind, rerun and forking in Mirasim.


The short answer
Claude Code creates an automatic file checkpoint on every prompt you send. Type /rewind (or its alias /undo), or press Esc twice when the input box is empty, to pick an earlier prompt and restore the code, the conversation, or both — or summarize part of the thread to free context space. Checkpoints only cover files Claude edited with its file-editing tools, not arbitrary Bash changes or background subagents, so keep Git for full version control.
| Rewind option | What it changes | When to use it |
|---|---|---|
| Restore code and conversation | Reverts tracked files and rewinds chat to that prompt | An approach went off track and you want to try again cleanly |
| Restore code | Reverts tracked files while keeping the full conversation | You want Claude to remember what failed while undoing the bad edit |
| Restore conversation | Rewinds chat only; files on disk stay as they are | You like the edits on disk but want a cleaner prompt history |
| Summarize from here / up to here | Compresses that slice of conversation without touching files | Free context after a verbose debugging detour |
How Claude Code checkpoints work
- Retention: Claude Code keeps snapshots for the 100 most recent checkpoints in a session, saves them with the session so
/rewindstill works after/resume, and cleans them up after about 30 days by default (cleanupPeriodDaysin settings changes this). - Save the rewind before exiting: if you rewind the conversation and exit Claude Code before sending a new prompt, the rewound messages can return next time (restored files stay reverted). Send a follow-up prompt so the rewound history is saved.
- Rewind past
/clear: if you ran/clearearlier in the same Claude Code process,/rewindshows a/resume <session-id> (previous session)entry at the top of the list until you exit or resume another session. - Fork instead of overwriting: if you want to test another direction without losing the original thread, use
/branchorclaude --continue --fork-sessioninstead of rewinding.
Four things /rewind does not restore
- Files changed only by Bash commands
- If Claude edited a file with its file-editing tools earlier in the session,
/rewindreverts later Bash changes to that file too. A file touched only by shell commands (rm,mv, scripts) isn't tracked — use Git to restore it. - Background subagents and
/code-review --fix - A foreground forked skill (
background: false) is captured in checkpoints, but background subagents and background fixes aren't — only files the main session had already edited are reverted. - Your own edits after the checkpoint
- Restoring code on a file Claude edited will overwrite edits you or another session made to that file after the checkpoint. Commit or copy important manual edits before rewinding.
- Messages queued mid-turn
- A message sent while Claude was still working appears as **No code restore** because it has no checkpoint of its own. Pick the prompt that started that turn to revert the whole turn's edits.
Rewind, re-run, and branch sessions visually in Mirasim
Instead of remembering CLI flags or juggling terminal tabs, Mirasim puts rewind, re-run, conversation branching, and Git worktrees directly on each message and pane.
- Rewind on any message: pick **Rewind** on a message you sent to restore the conversation, the code, or both to before that message — your original prompt goes right back into the composer to edit and resend. **Reuse prompt** fills the composer without changing the thread.
- Re-run a reply: open
⋯› **Re-run** on any reply to ask again with that turn's agent, model and reasoning level. Agents that don't support in-place rewind (such as Codex) re-ask at the end and keep later turns. - Fork and compare side by side: open
⋯› **New session from here** to branch off a separate session while the original keeps running — or start risky changes in a dedicated Git worktree and discard or restore individual files from the Git tab.
Chapter 8 · Branches, reruns and worktrees › Re-running and rewinding turns → Forking, re-running, rewinding, and worktrees in the Mirasim docs.
Questions
- What is the shortcut to undo in Claude Code?
- Press
Esctwice when the prompt box is empty (in vim mode, pressEsctwice from NORMAL mode), or type/rewindor/undo. - Does Codex have an in-place
/rewindlike Claude Code? - Codex relies primarily on Git (including isolated Worktrees in the desktop app) to revert file edits cleanly. In Mirasim, running Codex in its own Git worktree lets you review or discard changes per file in the Git tab, and Re-run re-asks a prompt without losing the thread.
- Why does
/rewindsay “No files were restored”? - Either the checkpoint's snapshots were cleaned up after the retention window (about 30 days by default), or the files weren't edited through Claude Code's file-editing tools.
Article · Running two coding agents in one repository → Isolating risky or parallel edits with Git worktrees in Claude Code, Codex and Mirasim.
Article · Cutting Claude Code and Codex token usage: /context, /compact, prompt caching, and model routing → Using `/compact`, `/clear`, and Summarize to keep context lean.
Article · How to use Claude Code: your first session, permission modes, and undoing changes → How to use Claude Code: permissions, commands and daily workflow.
Sources
Checked on November 29, 2026 against Anthropic's Checkpointing guide at code.claude.com/docs/en/checkpointing. Check that page for the latest retention defaults and shortcuts.
Keep reading

Fixing OpenAI and Codex 403 “unsupported_country_region_territory”
Why OpenAI and Codex return 403 unsupported_country_region_territory, how to fix false positives on VPNs or cloud IPs, and compliant alternatives.

Running Claude Code and Codex on Amazon Bedrock, Vertex AI, and Microsoft Foundry
Connect Claude Code and Codex to Amazon Bedrock, Vertex AI, and Microsoft Foundry: env vars, config.toml, auth, model pinning, and limits.

Using Claude Code with Chrome and Codex Browser: live debugging, Playwright, and previews
How to connect Claude Code to Chrome (extension, console logs, login limits) and use Codex Browser or Playwright, plus live dev-server previews in Mirasim.