Mac guides

How to undo Claude Code changes, including the ones /rewind can't

By Qiffe · Tested on macOS 27.0.1,

Claude Code can undo its own edits. Press Esc twice and you can rewind the code to any earlier prompt. That covers most mistakes, but not all of them: some changes an agent makes never reach the checkpoint at all.

This guide shows what /rewind restores, what it leaves alone, and three ways to get back the rest. Claude Code’s behavior comes from its checkpointing documentation; the Mac steps were checked on macOS 27.0.1.

Option 1: rewind with /rewind

Claude Code saves a checkpoint before every prompt that starts a turn, and keeps file snapshots for the 100 most recent ones in a session.

  1. Run /rewind, or press Esc twice while the prompt input is empty.
  2. Pick the prompt you want to go back to.
  3. Choose Restore code to undo the file changes and keep the conversation, Restore conversation to do the opposite, or Restore code and conversation for both.

Checkpoints are saved with the conversation, so /rewind still works after you resume a session. By default the snapshots are deleted about 30 days after the session last saved one.

What /rewind can’t undo

The documentation lists these limits:

Change Rewound?
Edits made with Claude’s file editing tools Yes
Files changed by Bash commands, such as rm, mv, cp, sed -i or a build script No
Edits made by most subagents, including background ones No
Changes you or another session made outside this session Normally no
Symlinked or hard-linked files No, they’re skipped

The Bash row is the one that hurts. An agent that cleans up with rm -rf, renames a folder with mv or rewrites files with a script has changed things a checkpoint never saw. Rewinding brings back Claude’s edits around them, but not the files those commands touched.

Option 2: git

If the folder is a git repository and you committed before the session, git covers tracked files whatever changed them:

git status
git restore .

git restore . puts every tracked file back as it was at the last commit. To keep the agent’s work for later instead of throwing it away, run git stash --include-untracked.

git has gaps of its own. It doesn’t bring back untracked or ignored files that were deleted, such as a local database, .env files, downloaded assets or build settings, and it doesn’t help in folders that aren’t repositories at all.

Option 3: an APFS clone before you start

On a Mac, cp -c copies with clonefile, so the copy shares its data with the original until a file changes. A large folder copies quickly and takes almost no extra space at first:

cp -c -R ~/Projects/Aurora ~/Projects/Aurora-before

If the session goes wrong, compare the two folders, or move the broken one to the Trash and rename the copy back. This catches every change, Bash included. The catch is that it’s all by hand: there’s no list of what changed, no way to put back just a few files, and old copies pile up until you delete them. The cp man page also notes that it falls back to a normal copy when the destination can’t clone, for example on another disk.

Option 4: take a mulligan

Mulligan is our app for exactly this. It saves a folder as an APFS clone before you, a script or an agent changes it, then shows every file that changed, was removed or was added since, and puts back the whole folder or only the files you pick. Replaced versions go to the Trash.

  1. Before the session, click Take a mulligan in Mulligan and choose the project folder, or right-click the folder in Finder and choose the Take a Mulligan Quick Action. With a license you can run mulligan save . in Terminal instead.
  2. Let the agent work.
  3. Open Mulligan to see the changes, select what you want back, and click Put back.

Saving 20,000 files plus a 1 GB file took 2.0 seconds and about 8 MB of extra space in our tests on macOS 27.0.1. It’s an undo point on the same disk, not a backup.

Which one to use

/rewind git APFS clone Mulligan
Claude’s file edits Yes Tracked files Yes Yes
Bash commands (rm, mv, scripts) No Tracked files Yes Yes
Untracked and ignored files Only Claude’s edits No Yes Yes
Shows what changed Per prompt git diff No Yes
Put back only some files No Yes By hand Yes

Use /rewind for quick, everyday undo inside a session and keep committing with git. Take a clone or a mulligan before a run where the agent will move, delete or generate files, especially outside a repository.

Questions

Does Claude Code's /rewind undo Bash commands?

No. Claude Code's documentation says checkpointing does not track files changed by Bash commands such as rm, mv or cp; only edits made with Claude's file editing tools can be rewound.

How do I open the rewind menu in Claude Code?

Run /rewind, or press Esc twice while the prompt input is empty. Pick the prompt you want to go back to, then choose Restore code, Restore conversation, or both.

How long does Claude Code keep checkpoints?

File snapshots for the 100 most recent checkpoints in a session. By default they are deleted about 30 days after the session last saved one; the cleanupPeriodDays setting changes that.

Is git enough to undo an AI agent's changes?

For tracked files in a repository, mostly yes. git doesn't bring back untracked or ignored files that were deleted, such as local data, .env files or build settings, and it doesn't cover folders that aren't repositories.