NewThe Mac app is out for Apple SiliconGet it →
Fenzi
blog, safety

Does Claude Code rewind undo everything?

No. Rewind restores the files Claude changed with its own file editing tools, and the conversation, to the point before one of your prompts. It leaves files that only shell commands changed, most subagent edits, symlinked files, and anything that left your machine, such as a push, a database write or an API call. For those, Git and a prompt before the action are the undo.

By Boris Kwemo, , six-minute read

Rewind is the first thing people reach for when an agent goes the wrong way: press Esc twice, pick a prompt, and the code is back. It works well for what it covers. The trouble is what it does not cover, because those are often the changes you most want back.

What rewind restores

Anthropic's checkpointing page describes the mechanism: before each prompt that starts a turn, Claude Code saves a checkpoint of the files its editing tools touch. /rewind, or Esc twice on an empty prompt, opens a menu of your prompts, and the commands reference lists /checkpoint and /undo as aliases of the same command.

From the menu you restore the code, the conversation, or both. Claude Code keeps snapshots for the 100 most recent checkpoints in a session, saves them with the conversation so a resumed session can still rewind, and deletes them in a cleanup sweep about 30 days after the session last saved one.

What rewind leaves as it is

The same page lists the limits. Each one is a change you can see in your project after a bad turn, with no restore option in the menu.

ChangeDoes rewind restore it?
A file Claude edited with its edit toolsYes
Later shell changes to a file Claude had already editedYes
A file only shell commands changed, such as rm, sed -i or a code generatorNo
Edits by a background subagent to files Claude had not editedNo
Symlinked or hard-linked files, such as packages pnpm links into placeNo, they are skipped with a warning
Your own edits, or another session's, outside Claude CodeNormally no
A push, a deploy, a database write, an API callNo

The last row is the one that matters most. Anthropic's page on how Claude Code works says it in one line.

Actions that affect remote systems (databases, APIs, deployments) can't be checkpointed.Claude Code docs, How Claude Code works

The checkpointing page ends on the same advice: checkpoints are for quick recovery inside a session, and version control, such as Git, stays the history you rely on.

Why the gap matters more in auto mode

Since version 2.1.283, auto mode is the mode interactive terminal and VS Code sessions start in, according to Anthropic's permission modes page. A second model, a classifier, reviews most actions instead of you.

That page also says that in auto mode, pushing to any branch of the repository you are working in, and opening a pull request that matches your request, run without a prompt. The classifier still blocks a force push or a secret in the commit, and the remote's own branch protection still applies. So the push you did not see is exactly the kind of change rewind cannot reach.

"If it goes wrong, we will just rewind."

Revision 1: rewind covers Claude's file edits. A push, a migration, or a file a script deleted needs Git or a prompt before it happens.

Use Git as the undo for files

Git restores what was committed, whichever tool made the change. That makes it the undo for everything rewind skips inside the project, as long as there is a commit to go back to. The habit is short: start clean, give the agent its own branch, read the diff, and throw it away if it is wrong.

git status                    # start from a clean tree
git switch -c agent/fix-login # the agent's own branch
# ...the agent works...
git diff main                 # read every change
git reset --hard main         # discard the branch's changes
git clean -n                  # list new files reset left behind
git reflog                    # find a commit you reset past

Git's reset documentation says --hard makes tracked files match the commit, but a new file Git never tracked stays, which is why git clean -n comes next: it shows what would be removed without removing it. The reflog records where branches pointed, so a reset can be reversed; by default it prunes an entry the branch no longer reaches after 30 days. None of it brings back work that was never committed.

So commit before you hand the agent a task. A commit is the one checkpoint that covers every tool.

For longer tasks, a linked worktree gives the agent a separate folder on its own branch, attached to the same repository. Your own checkout stays as it was while the agent works, and removing the worktree removes its files.

Put a person before what cannot come back

For a change that leaves the machine, the only undo is not doing it unasked. Anthropic's page on configuring auto mode gives the recipe: an ask rule forces a prompt, even in auto mode, and the classifier cannot approve a matching action for you.

{
  "permissions": {
    "ask": [
      "Bash(git push *)",
      "Bash(gh pr create *)"
    ]
  }
}

The same page names the edge. A push written another way, such as git -C <dir> push, does not match the rule. For a check that reads the full command text, it points to a PreToolUse hook, and for an action that must never run, to a deny rule, which blocks before the classifier is asked.

Telling Claude "don't push until I review" works for a while. The page warns that the instruction can be lost when the conversation is compacted, so a rule in settings is the durable form. Our notes on how Claude Code permissions work cover how ask, deny and allow rules combine, and our post on human in the loop for AI agents covers where a person's yes belongs.

Keep the irreversible out of reach

An agent can only drop a table it can reach. A database URL for production in the project's .env, a cloud token in the shell, a deploy key in the home folder: each one turns a wrong command into a change with no checkpoint. The same three questions sit behind most AI agent security risks: which files it reads, which hosts it can send to, and which keys it holds.

So give the agent a development database, a token scoped to the task, and no credential for production. Then the worst a bad turn can do is a diff you read and discard. The first of the four rules of agentic AI security we hold to says the same thing in fewer words: the agent gets the directories the task needs, and nothing else.

A side note on how we do it

We build Fenzi, which runs the agent inside an OpenShell sandbox on a copy of the project, on a branch of its own; its commits come back to your repository and your branch moves only when you apply them, as the workspace sheet explains. The agent cannot push, because the sandbox has no git host and no token. A worktree or a container with a fresh clone answers the same question.

So, can you undo what Claude Code did?

Some of it. Rewind takes back Claude's own file edits and the conversation, and Git takes back anything committed in the project, whoever changed it. Nothing takes back a push, a deploy or a write to a remote system, so put an ask rule in front of those, keep production credentials out of the agent's reach, and read Anthropic's Checkpointing page next.

One line to install.
One command to run.

curl -fsSL https://fenzi.dev/install.sh | sh

Then fenzi run claude. Ask it to open a pull request with the GitHub API, and watch the deny land.