How to undo Claude Code changes
To undo what Claude Code just did, run /rewind, or press
Esc twice with the prompt empty, pick the prompt to go back to, and choose Restore
code. That reverts edits made with Claude Code's file editing tools. Files changed by Bash
commands, by you, or by another session are not covered, and Git is how you undo those.
The rewind menu
Claude Code's checkpointing documentation, read on October 16, 2026, says each prompt you send that starts a turn saves a checkpoint of the code first. The rewind menu lists the prompts you sent in the session. Select one, then choose:
- Restore code and conversation: both go back to that point.
- Restore conversation: the conversation goes back, and the code stays as it is.
- Restore code: the files go back, and the conversation stays.
- Summarize from here or Summarize up to here: compresses part of the conversation. No file changes.
- Never mind: back to the list with nothing changed.
The two code choices appear only when there are tracked file changes after that point. After you restore the conversation, the prompt you picked goes back into the input, so you can edit it and send it again.
Checkpoints are saved with the conversation, so /rewind still works after you
resume a session. Where sessions are kept, and for how long, is in
where Claude Code keeps session history.
What rewind does not undo
- Bash commands. A file deleted, moved or copied with
rm,mvorcpis not tracked, so rewinding does not bring it back. - Edits made outside the session. Your own edits, and edits from another Claude Code session running at the same time, are normally not captured.
- Most subagent edits. Rewinding restores files the main conversation had already edited. A subagent's edits to other files stay.
- Symlinked and hard-linked files. These are skipped, with a warning that names how many files were skipped. Their contents stay as they are.
- Old checkpoints. A session keeps file snapshots for its 100 most recent
checkpoints. Snapshots are deleted about 30 days after the session last saved one. Rewinding to a
checkpoint whose snapshots are gone can fail with
No files were restored.
The documentation says checkpoints are for quick recovery inside a session, not a replacement for version control. Keep using Git.
Undo with Git
Start by seeing what is there. In the project folder:
git status
git diff --stat
git status also lists edits you made before the run. Each command below acts on
your lines as well as the agent's, so read the diff of a file before you discard it.
Changes nobody committed
git restore path/to/file
git restore --staged path/to/file
The first puts a file back as it was at the last commit, or as staged. The second unstages it,
so the first can then put it back. A file the agent created is untracked, and
git restore leaves it alone. Delete it yourself once you have read it.
To set the whole attempt aside without losing it:
git stash --include-untracked
That empties the working tree back to the last commit and keeps the changes, new files
included. git stash pop brings them back.
Commits the run made
git log --oneline -5
git revert <commit>
git revert adds a new commit that undoes the one you name, which is safe on a
branch other people have pulled. Rewriting history with a reset is a different decision, and a
riskier one once the commit is pushed.
Try again without losing the first attempt
To try a different approach and keep the first one, the documentation suggests
/branch inside the session, or claude --continue --fork-session when you
start. Each copies the conversation so far into a new session and leaves the original as it was.
That copies the conversation, not the files. To keep the first attempt's code, stash or commit it
first.
Know what you are undoing
An undo is a review in reverse. Before you throw a run away, look at what it changed, so you keep the part that was right. Read sign-in, deletion, payments, new dependencies and configuration first. The order is in what did Claude Code change?, and the checks before you keep a change are in how to review AI-generated code before you merge.
BuildGist explains each meaningful Claude Code, Cursor and Codex run in plain English and flags concerns, so you can see what a run did before you decide to keep or undo it. BuildGist does not undo anything. Rewind and Git do that. The explanation is written by AI, so check important behavior against the code and tests.
What you need
- A Mac with Apple silicon and macOS 12 or later.
- Claude Code, Cursor or Codex.
- A Git project. No commit, push, remote or GitHub repository is needed.
- A GitHub account, to sign in. BuildGist does not access your GitHub repositories.
Codex needs you to approve BuildGist once, in Codex. BuildGist shows the steps. Setup is in Getting started.
To explain a run, your computer sends BuildGist what that run needs, and BuildGist passes it to Anthropic. BuildGist does not keep this material. It does not send your whole repository, files the run did not change, or files named like secrets, such as .env files and keys. It keeps the explanation and short cited excerpts of changed code, at most 12 lines each. Secret masking is best-effort. Privacy has the full list.
Every account gets 7 days of BuildGist Pro free, with no card. The 7 days start at your first explanation or Continue handoff. Nobody is charged when the trial ends. After that, BuildGist Pro is $12 per month, plus any applicable tax shown at checkout. See pricing.
Apple silicon, macOS 12 or later. United States, 18 or older.
Related
- What did Claude Code change?
- Switch from Claude Code to Codex
- Understand code an agent wrote
- Hand off Claude Code to Cursor
- Review what Codex changed
- You’ve hit your session limit in Claude Code
- You’ve hit your usage limit in Codex
- Keep context across agents
- Review AI code before merging
- BuildGist or the git diff
- Claude Code session history
- BuildGist vs CLAUDE.md, AGENTS.md and HANDOFF.md
- Keep context from Claude Code to Cursor
- Resume an agent session in another tool
- BuildGist vs Conductor
Questions: kayvanandre@gmail.com.