How to Undo Changes in Claude Code With /rewind

To undo changes in Claude Code, run /rewind, or press Esc twice on an empty prompt.

Choose the message you want to go back to, then pick whether to restore your code, the conversation, or both.

Claude Code saves a checkpoint of your files before each prompt you send. That’s what makes it possible to roll back.

This article explains each rewind option, how to use it, and the changes that rewind can’t undo.

Open the rewind menu

Run this command:

/rewind

Or press Esc twice while the prompt is empty. The command also has two aliases: /undo and /checkpoint.

If there’s text in the prompt, pressing Esc twice clears the text instead. Press Up to get it back.

Choose what to restore

The menu lists the prompts you sent in this session. Pick one, then choose an action:

OptionWhat it does
Restore code and conversationPuts both back the way they were at that point
Restore conversationGoes back in the conversation, but keeps your current code
Restore codeReverts the file changes, but keeps the conversation
Summarize from hereShrinks everything after that point into a summary
Summarize up to hereShrinks everything before that point into a summary
Never mindCloses the menu without changing anything

The code options only appear when there are file changes to revert after that point.

After you restore the conversation, your original prompt goes back into the input box, so you can edit it and send it again.

Example: undo a bad edit

Say Claude rewrote a file and broke your tests. Here’s how to undo it:

  1. Press Esc to stop Claude if it’s still working
  2. Run /rewind
  3. Choose the prompt where you asked for the change
  4. Choose Restore code and conversation
  5. Edit the prompt to be more specific, then press Enter

What rewind can’t undo

Rewind only tracks files that Claude edits with its own file editing tools. These changes aren’t undone:

  • Files changed only by shell commands: if Claude ran rm, mv, or a script that changed a file it never edited directly, rewind won’t restore it
  • Most edits made by subagents: only files Claude had already edited in your conversation are restored
  • Changes you made yourself outside Claude Code, or changes from another Claude session
  • Symlinked and hard-linked files: Claude Code skips them and shows a warning
  • Anything outside your files, like database changes, deployed code, or sent messages

Use git for these. Commit before asking Claude to do something big, then run git restore or git checkout if it goes wrong.

How long are checkpoints kept?

Checkpoints are saved with your session, so /rewind still works after you resume a session with claude --resume.

Claude Code keeps snapshots for the last 100 checkpoints in a session. Old snapshots are deleted after about 30 days, along with old sessions. To keep them longer, raise cleanupPeriodDays in your settings, as explained in where Claude Code sessions are stored.

Rewind vs fork

Rewinding goes back and replaces the current path. If you’d rather keep the current conversation and try something else on the side, fork it instead. See how to fork a conversation in Claude Code.

Conclusion

Run /rewind or press Esc twice, pick a prompt, and choose what to restore. For changes Claude makes with shell commands, and for anything important, keep using git alongside it.