Claude Code Checkpoints and Rewind: Undoing an Agent’s Changes
Claude Code saves a checkpoint before every prompt, and /rewind takes your code, the conversation or both back to it. Every option in the rewind menu, exactly what a checkpoint restores and what it never will, and a way to experiment that leans on both checkpoints and git.
6 min read
Claude Code checkpoints are automatic snapshots of your files, taken before each prompt you send that starts a turn. Run /rewind, also available as /checkpoint and /undo, or press Esc twice on an empty prompt, pick an earlier prompt, and restore the code, the conversation, or both to that point. A checkpoint restores edits Claude made with its own file-editing tools in this session, and nothing else: not files changed by shell commands, not most subagent edits, not your own edits or another session’s, and not anything Claude did outside your files, such as a commit, a push or an MCP call. Treat checkpoints as a fast undo for Claude’s edits and keep git for everything that matters.
How checkpoints work
Checkpoints arrived alongside version 2.0 of the terminal interface. Anthropic’s announcement (opens in a new tab) put the limit plainly from the start: they apply to Claude’s edits, not user edits or bash commands, and are meant to be used together with version control. The current behavior, from the checkpointing documentation (opens in a new tab):
- Every prompt that starts a turn creates a checkpoint. There is nothing to switch on and no command to save one by hand.
- Snapshots are kept for the 100 most recent checkpoints in a session.
- Checkpoints are saved with the conversation, so
/rewindstill works after you resume a session. - Snapshot files are deleted in the regular cleanup, by default about 30 days after the session last saved one. Rewinding past that can fail with “No files were restored”. Raise
cleanupPeriodDaysto keep them longer. - A message you type while Claude is working that joins the running turn gets no checkpoint of its own and does not appear in the menu. Rewind to the prompt that started that turn instead.
The rewind menu, option by option
/rewind # also /checkpoint or /undo Esc Esc # same menu, when the prompt input is empty
If the prompt has text in it, double Esc clears the text instead, saving it to history so Up brings it back. The menu lists each prompt you sent; choose one, then an action:
- Restore code and conversation: files and the conversation both go back to that point.
- Restore conversation: the conversation goes back, your files stay as they are now.
- Restore code: the files go back, the conversation stays, so Claude still remembers what it tried.
- Summarize from here: compresses the conversation from that point on into a summary, freeing context while keeping your early instructions word for word.
- Summarize up to here: compresses everything before that point and keeps later messages intact.
- Never mind: back to the list, nothing changed.
Three details make the menu faster to use. The two code options appear only when that checkpoint has tracked file changes after it. After restoring the conversation, or choosing Summarize from here, your original prompt is put back in the input box, so you can edit it and send a better version. And the summarize options never touch files on disk; highlight one and type what the summary should focus on in the add context row before pressing Enter. If you ran /clear earlier in the same process, the top of the list also offers the conversation from before it.
What a checkpoint restores
- Edits Claude made in this session with its file-editing tools.
- The conversation, to any listed prompt.
- Edits from a skill with
context: forkthat runs in the foreground, because it edits your working tree during your own turn.
What a checkpoint does not restore
- Anything a shell command changed. The documentation’s own examples are
rm file.txt,mv old.txt new.txtandcp source.txt dest.txt; the same goes for a formatter, a code generator or a migration run through Bash. When Claude deletes files, this is almost always how, which is why Claude Code deleted my files is about prevention and recovery rather than rewinding. - Edits made by a subagent, with the foreground forked skill as the only exception. A background fork and a background
/code-review --fixrun are not restored either. Use git to revert those. - Your own edits outside Claude Code, and edits from other sessions running at the same time, unless they happen to touch the same files.
- Symlinked and hard-linked files. A restore skips them and warns “Restored the code, but skipped N files”. Config files a dotfile manager links into the project, and files pnpm hard-links into place, both fall into this group.
- Everything beyond your working files: a commit, a push, a package install, a deploy, a message sent, or a change made through an MCP tool. Rewinding the conversation removes those steps from what Claude remembers, not from the world.
Rewind, branch or git
Three tools look alike and do different jobs.
/rewindundoes, inside one session. Use it when an attempt went wrong and you want the files and the conversation back as they were./branch, orclaude --continue --fork-sessionfrom the command line, copies the conversation so you can try a different direction and keep the original intact to return to with/resume. Branching does not rewind files; the sessions documentation (opens in a new tab) covers what a branch inherits.- Git keeps history that outlives the session, covers every kind of change and can be shared. Anthropic describes checkpoints as quick, session-level recovery and says to keep using version control for permanent history.
In the VS Code extension, hover over any message for a rewind button with three choices: Fork conversation from here, Rewind code to here, or Fork conversation and rewind code. They use the same checkpoints, with the same limits. For apps built on the Agent SDK, file checkpointing (opens in a new tab) is opt-in with enableFileCheckpointing and tracks only the Write, Edit and NotebookEdit tools.
A safe way to experiment
- Commit, or at least stash, before you start, so there is a clean point that does not depend on the session.
- Ask for the first approach. For anything large, plan first; Claude Code plan mode is cheaper than an implementation you throw away.
- Read the diff. If it is wrong,
/rewind, choose Restore code and conversation at the prompt that started it, edit the prompt that comes back and send the better version. - If Claude’s reasoning was useful but the code was not, choose Restore code instead, so it keeps what it learned.
- Before Claude runs anything that rewrites files through a command, such as a generator, a formatter across the repository or a migration, commit. Rewind will not undo that step.
- When the result is right, commit it. The checkpoint was a draft; the commit is the record.
Checkpoints pair well with fewer prompts, because a wrong edit is cheap to undo, but only for file edits. The more commands you let Claude run without asking, the less of its work a rewind covers. Auto-approve in Claude Code explains what runs unprompted in each mode, and how to stop a Claude Code task covers interrupting a turn before there is anything to undo.
Rewind does not reach the board
If Claude is connected to fenbs, the work it did there is one of those changes outside your files. Suppose it moved a task to Completed, rewrote its plan and commented before you rewound: the conversation forgets all three, and the board keeps them. Check what to put back in History, which records each change as the assistant acting for you, and correct the task by hand or ask Claude to. A task it deleted can be restored with its number, comments and links, though files attached to it are gone for good. Then add a comment saying what was rewound, so nobody takes the earlier comment as the final word. How that record is kept is in an audit trail for AI agents.
Related
Recovering files a command deleted: Claude Code deleted my files. Stopping a turn: how to stop a Claude Code task. Boundaries around shell commands: the Claude Code sandbox. Connecting a board: the Claude Code integration and the MCP docs.