Prompt & Done · UNDOIT
Undo anything Claude does to your project: 5 git commands
A commit is a photo of your whole project folder. Take one before you let Claude run, and any change it makes can be rolled back. We tested it on 7 Nov 2026: Claude Code rewrote our 3-commit coffee site as a neon app (7 files changed, 592 lines added), and git restore . brought the page back exactly as it was.
Run these in your project folder, in a terminal. Never used git there? Start with git init once.
1 Take the photo: commit
git add -A
git commit -m "works: before Claude"Do this every time something works. Or just tell Claude Code: "commit what we have with a clear message". It runs git for you.
2 See what changed
git status
git diff --statgit status lists changed files and new ones (??). git diff --stat counts the changed lines in files git already knows.
3 Bring the last photo back
git restore .Puts every tracked file back to the last commit. New files Claude created stay. See them with git clean -n (dry run), then delete them with git clean -fd only if that list is what you expect. Not sure? git stash -u sets everything aside instead, and git stash pop brings it back.
4 Try risky ideas on a branch
git switch -c try-redesign
# let Claude go wild, commit on this branch
git switch main # your safe version, untouchedLiked it? git merge try-redesign from main.
5 Find an older photo
git log --oneline
git restore --source=<commit-id> .The first lists your save points, newest first. The second puts your files back as they were at that commit (commit first if you want to keep what you have now).
Careful: git reset --hard also throws away uncommitted work, with no undo. You don't need it for any of the above.
+ The safe workflow with Claude Code
1) Commit before every big prompt. 2) Risky change? Branch first. 3) After Claude finishes, read git diff --stat before you keep it. 4) Ask Claude to commit each working step.
Claude Code also has checkpoints: press Esc twice or type /rewind to roll back its file edits. They're session-level, don't track changes made by shell commands, and the docs say to keep using git for real history.
code.claude.com: Checkpointing · git-scm.com: git restore · git switch