You ask Claude Code to tidy a folder of client files. Halfway through, you see it rewrote the wrong ones.
Claude Code has an undo button, called rewind. It fixes a lot. It does not fix everything, and finding that out after the damage is too late. This guide shows you how to use rewind, the three things Anthropic's docs say it does not bring back, and the habit that covers the gaps: copy the folder before any big job.
01 / 06
Before a big job: copy the folder
A copy is a separate folder, so it does not depend on what Claude Code tracked. Make it before you start. Pick the one that fits you.
Mac or Linux (Terminal):
cp -R "Client files" "Client files copy 2026-11-08"
Windows (PowerShell), the safe version:
robocopy "Client files" "Client files copy 2026-11-08" /E
Robocopy finishes with exit code 1 when it has copied files (PowerShell shows it with echo $LASTEXITCODE). That is a success, not an error.
Windows (PowerShell), the plain version:
Copy-Item -Recurse -Path "Client files" -Destination "Client files copy 2026-11-08"
Run it once. If the destination folder already exists, PowerShell puts the copy inside it, one level too deep.
Or right-click the folder, choose Copy, and Paste. It is slower on big folders but needs no commands.
Open the copy and check that hidden files (like
.env) and sub-folders are inside.Open
Claude Code in the original folder, not in the copy. The copy stays untouched.
If you use Git, a commit is also a restore point:
git add -A, thengit commit -m "before big job". This includes any.envor key files in the folder, so keep that repository on your own computer and never push it.
02 / 06
If Claude goes wrong: use rewind
Open rewind by typing
/rewind, or pressEsctwice when the prompt box is empty. If the box has text in it, doubleEscclears the text instead.Pick the message you sent that started the job that went wrong. Rewind puts your files back as they were before that message.
Choose what to restore. Anthropic's docs list three options: Restore code and conversation puts back both, Restore conversation rewinds the chat only and leaves the files as they are, and Restore code puts the files back and keeps the conversation.
The two code options appear only when
Claude's file edits were tracked after that message.
03 / 06
What rewind will not bring back
Anthropic's checkpointing page lists these limits. Read them before the job, not after.
Files that only a command changed. Rewind tracks edits
Claude makes with its own file editing tools. If Claude ran a command that deleted, moved or copied a file it never edited, rewind does not track it and the file stays changed. One detail from the docs: if Claude did edit a file first, rewind does undo a later command's change to that same file.
Most helper-agent edits. If
Claude hands part of the job to a helper agent (a subagent), those edits usually are not captured. The docs say a helper running in the background is a common case. Use Git or your copy.
Changes made outside the session. Edits you make yourself, or that another
Claude session makes, are normally not tracked.
Two more limits from the same page:
- Linked files. Symlinks and hard links are skipped when you restore code, and
Claude Code shows a warning.
- Old snapshots.
Claude Code keeps snapshots for the 100 most recent checkpoints in a session, and deletes a session's snapshots about 30 days after it last saved one, by default. This is the setting as of November 2026.
The docs also say checkpoints are for quick recovery inside a session and are not a replacement for version control.
04 / 06
After the job
Look at what changed before you delete the copy. Keep it for a few days.
If something is wrong, try
/rewindfirst.If the damage came from a command or a helper agent, restore from your copy.
One optional extra: add a line to your CLAUDE.md file, the file Claude Code reads at the start of every session, such as
Before deleting or moving files, list them and ask me first. It is a request to Claude, not a lock, so keep the copy.
05 / 06
Test it safely
Make a dummy folder with three small text files. Copy it using the command for your system.
Run
diff -r(Mac or Linux) or open both folders and compare. They should match, including hidden files.Open
Claude Code in the dummy folder, ask it to change one file, then open
/rewind, pick the earlier message and choose Restore code. The file should return.Ask
Claude to delete a different file using a command, then try rewind again. Check what comes back.
What was tested: on 8 November 2026 the copy commands were run on a dummy folder with a hidden .env file. cp -R was run in Git Bash on Windows, not on a Mac. robocopy copied everything and exited with code 1, and Copy-Item run twice nested the copy one level too deep, as warned above. git add -A did include the .env file. The rewind steps and limits come from Anthropic's checkpointing page, read the same day. Not tested: a live /rewind session, and restoring a file from a Git commit.
Common mistakes
Opening
Claude Code in the copy. Work in the original and leave the copy alone.
Trusting rewind for command changes. Files only a command touched are not tracked.
Skipping the check. Open the copy once and look inside.
Pushing a repository that holds
.envfiles. Keep restore-point repositories local.
Does rewind work for everything Claude does?
No. It covers edits made with Claude's own file editing tools. Commands, most helper agents and outside changes are the gaps.
How long are rewind snapshots kept?
By default about 30 days after a session last saved one, and only for the 100 most recent checkpoints in a session.
Why not just use Git?
Git is a good restore point if you already use it. A plain folder copy works for people who do not. Do either one before a big job.
Do I need to code?
No. You type one copy command, or use right-click, Copy, Paste.
Finish line
What to do next
Pick the folder
Claude will work on next.
Make the copy and open it once.
Save this page for the next time a job goes sideways.
Back to all the free guides. Two that pair well with this one: AI guardrails that hold and run Claude Code overnight safely.
You reached the end of the guide