How to undo Claude Code changes
Last updated: 8 October 2026
Claude Code changed something you did not want: a file rewritten, a file deleted by rm, a dependency installed. There are three ways back, and each one restores different things. This page says what each one covers, so you can pick the right one before you need it. If files are already gone, start with Claude Code deleted my files.
1. Claude Code's own rewind
Claude Code keeps a checkpoint before each prompt that starts a turn. "Run /rewind, or press Esc twice when the prompt input is empty, to open the rewind menu", pick a message, then choose to restore the code, the conversation, or both (checkpointing).
- It tracks "all changes made by its file editing tools" and keeps "file snapshots for the 100 most recent checkpoints in a session".
- Checkpoints are saved with the conversation, "so you can still run
/rewindafter you resume a session"; the snapshots are deleted "by default about 30 days after the session last saved one".
What it does not cover, in the documentation's words: "Checkpointing does not track files modified by Bash commands." (checkpointing). For subagents: "Any other subagent: rewinding doesn't restore the edits", apart from a skill forked in the foreground (subagent edits). And "Checkpointing doesn't rewind symlinked or hard-linked files." Its own advice: checkpoints are "Not a replacement for version control".
A measured test on Claude Code 2.1.292 shows the line in practice: /rewind restored a Write edit and none of rm, mv, sed -i and npm install (What /rewind misses).
2. git
If you committed before you asked Claude for something, git can take the changed files back. Use git restore --staged --worktree . rather than plain git restore .: "By default, if --staged is given, the contents are restored from HEAD, otherwise from the index." (git restore), so a change Claude already staged is undone too. For new files, git clean -n lists what would go: "Don't actually remove anything, just show what would be done." (git clean).
Its limits:
- It only knows what you committed. Work since the last commit, yours or Claude's, is not in it.
git stashkeeps your own uncommitted work out of the way, but plaingit stashleaves out untracked files (-uadds them), and only-atakes the files your.gitignoreexcludes, such as.env: "All ignored and untracked files are also stashed and then cleaned up with git clean." (git stash).- Claude can run git too. A
git reset --hardin a turn will "Overwrite all files and directories with the version from <commit>" (git reset), uncommitted work included.
3. turnslip
turnslip is a Claude Code plugin. It snapshots the project's files and compares them at the end of each turn (its README), so a file changed by a shell command counts as much as one Claude edited. One line under each reply says what changed; /turnslip:undo takes the last turn back. In a test on 7 October 2026 with Claude Code 2.1.292, one turn changed a file with sed -i and deleted another with rm, and the undo put both back:
- It restores every file the turn changed or deleted, and removes the files it created. A file renamed with
mvgoes back under its old name since 0.3.8. - It never overwrites a file you changed since the turn: that file is kept and named.
- The undo is a turn of its own, so it can be undone too. With Pro,
/turnslip:undo 3takes back an earlier turn.
Its limits, said plainly:
- Paths your
.gitignoreexcludes are never read, so they are never restored. A.envClaude deleted stays deleted.node_modulesis never tracked either: afternpm install, undo restorespackage.jsonand removes a new lockfile, but the installed packages stay, and the line lists the install as not undone (measured). - A write outside the project folder is flagged, not restored.
- A database migration, a
git push, a deploy or a global install is listed as not undone; no file undo can take those back. - On the first turns in a new or very large project, before its index is built, a turn can run in light mode: Claude's own edits stay undoable, but shell changes are not tracked yet, and the slip says so.
- Files over 5 MB are not kept, and each project keeps its last 50 turns.
Which one to use
Commit before a big request, whatever else you use. For a quick step back in the same session, /rewind also rewinds the conversation. When Claude runs commands, and you want to see what changed before you decide, turnslip covers the shell changes /rewind leaves out. They work side by side.
Related: What did Claude Code just change? · What /rewind misses: a measured test · All guides · Install turnslip, free