Letting an agent edit your files is easier when you know you can take it back. Checkpoints are that safety net, and you never have to remember to make one: Claude Code captures the state of your code automatically before each prompt you send.
How they work
Every prompt that starts a turn creates a checkpoint. Claude Code tracks the changes made by its own file-editing tools, keeps file snapshots for the 100 most recent checkpoints in a session, and saves them with the conversation, so they still work after you resume a session later. Snapshots are cleaned up with old session data, by default about 30 days after the session last saved one.
Rewinding
Run /rewind, or press Esc twice while the prompt input is empty, to open the rewind menu. It lists the prompts you sent in the session. Pick one, then choose what to restore:
- Restore code and conversation: go back to that point entirely.
- Restore conversation: rewind the chat but keep the current code.
- Restore code: undo the file changes but keep the conversation.
When you restore the conversation, your original prompt is put back in the input, so “try that again, differently” is a quick edit and resend.
The same menu can also summarize from or up to the point you picked. That compresses part of the conversation to free context window space without touching any files, which is handy after a long, verbose debugging detour. Context covers why that space matters.
The catch
Checkpoints only see edits made through Claude’s file-editing tools. Files changed by Bash commands (rm, mv, cp, or anything a script does) aren’t tracked, and neither are changes you make outside Claude Code or edits from other sessions running at the same time. Most subagent edits aren’t restored either, and symlinked or hard-linked files are skipped.
So treat checkpoints as session-level undo, not version control. Keep committing to git for real history; the checkpointing docs say as much. If you want to stop a risky shell command before it runs, rather than regret it afterwards, that’s a job for hooks.