Claude Code

Esc Esc in Claude Code: rewind code and conversation with checkpoints

TL;DR

Claude Code checkpoints before each prompt; rewind with Esc Esc or /rewind and five options. Cheaper than several correction turns, but Bash commands, subagents and external edits may not be covered.

You ask Claude Code to refactor a module, it edits 12 files, the tests are all red, and its approach is completely wrong. The usual reflex is to type "no, go back to the old way", which costs several more turns and leaves a pile of wrong history in context. The faster way: press Esc twice. Claude Code saves a checkpoint before every prompt, so you can rewind both code and conversation to the moment before things broke. This post explains how checkpoints work, the options in the rewind menu, and the limits you need to know so you don't "think you restored it when you didn't".

When are checkpoints created?

  • Every prompt you send (starting a turn) creates a checkpoint that records file state before Claude edits.
  • Snapshots are kept for the 100 most recent checkpoints in a session; they're saved with the conversation, so rewind still works after a resume.
  • Snapshots are cleaned up periodically, by default about 30 days after the last save (tune with cleanupPeriodDays).

The rewind menu: 5 options

Type /rewind or press Esc twice with an empty input, pick the prompt to go back to, then choose an action:

OptionWhat it doesUse when
Restore code and conversationRewinds both files and conversationThe approach was totally wrong and you want to start over with a better prompt
Restore conversationRewinds the conversation, keeps current codeThe code is fine but the chat history has wandered; you want a clean context
Restore codeReverts files, keeps the conversationYou want Claude to remember "why that approach failed" and try another
Summarize from hereCompresses the conversation from this point onward into a summaryA long debugging stretch is done; free context but keep your initial instructions
Summarize up to hereCompresses everything before this point, keeps later messages intactEarly exploration no longer needs full detail

After rewinding the conversation, the original prompt is put back into the input so you can edit and resend it. With either Summarize option you can type guidance for the summary (for example "keep the schema decisions") before pressing Enter. Summarize works like a targeted /compact; to branch off and try another approach while keeping the original session, use /branch.

Why rewinding saves tokens

Fixing a mistake by talking more means every later turn has to "carry" the failed attempt: the broken diff, the error logs, the explanations. Rewinding cuts that out of context. Combined with a better prompt, the retry is usually much shorter than three or four rounds of back-and-forth corrections.

Important limits

  • Bash commands aren't fully tracked: a file changed only by shell commands (rm, mv, code generators) that Claude never edited with its edit tools is not restored.
  • Subagents: most subagent edits (except a forked skill running in the foreground) aren't part of the main session's checkpoints.
  • External changes: files you edit outside Claude Code, or that another session edits, are usually not captured.
  • Symlinks/hard links: skipped on restore, with a "skipped N files" warning.
  • Messages sent mid-turn while Claude is working may have no checkpoint of their own.

The docs are explicit: checkpoints are for quick recovery within a session, not a replacement for git.

How to apply it

  • Dev: Build the reflex "wrong direction → Esc Esc, fix the prompt, resend" instead of arguing. Commit before big changes or before Claude runs shell commands with side effects.
  • Tech Lead: Teach the team the combination: checkpoints for short experiments, worktrees/branches for longer ones, git for real history.
  • PM: When drafting documents with Claude, use "Restore conversation" to try several writing styles on the same draft.

Sources & references

  1. Checkpointing — Claude Code Docs