← Blog

How-to5 min read

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.

Reviewing coding-agent edits and rewinding or branching sessions in MirasimReviewing coding-agent edits and rewinding or branching sessions 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 optionWhat it changesWhen to use it
Restore code and conversationReverts tracked files and rewinds chat to that promptAn approach went off track and you want to try again cleanly
Restore codeReverts tracked files while keeping the full conversationYou want Claude to remember what failed while undoing the bad edit
Restore conversationRewinds chat only; files on disk stay as they areYou like the edits on disk but want a cleaner prompt history
Summarize from here / up to hereCompresses that slice of conversation without touching filesFree 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 /rewind still works after /resume, and cleans them up after about 30 days by default (cleanupPeriodDays in 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 /clear earlier in the same Claude Code process, /rewind shows 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 /branch or claude --continue --fork-session instead 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, /rewind reverts 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.

Questions

What is the shortcut to undo in Claude Code?
Press Esc twice when the prompt box is empty (in vim mode, press Esc twice from NORMAL mode), or type /rewind or /undo.
Does Codex have an in-place /rewind like 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 /rewind say “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.

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