Does Claude Code's /rewind Undo Deleted Files? (Honest Answer)
You hit /rewind expecting your deleted file back and it didn't work. Here's exactly what /rewind can and can't undo, why it skips deletes, and what actually recovers your file.
Short answer, because you're probably mid-panic: no, /rewind does not undo a deleted file in most cases. It only undoes Claude's own direct edits inside the current session, not deletes, not terminal commands, not your .env.
If you already hit Esc Esc and it didn't bring your file back, you're not doing it wrong. You hit the exact blind spot almost nobody explains until it bites them. Let's clear it up, then get your file back.
What /rewind actually does
/rewind (you trigger it with Esc twice) is Claude Code's undo for the edits Claude makes directly to a file. You ask Claude to rewrite a paragraph or a function, you don't like the result, you rewind, and the old version comes back. For that job it's genuinely great, and you should keep using it.
The trap is assuming "undo" means "undo anything." It doesn't.
What /rewind does NOT undo (the part that just burned you)
There are three hard limits, and the loss that sent you here is almost always one of them.
1. It doesn't undo terminal commands. Claude doesn't only edit files directly. It also runs shell commands to get things done, things like rm (remove), mv (move), and cp (copy or overwrite). When a file vanishes because of one of those, rewind cannot see it. It only tracks Claude's own Write and Edit edits, never the commands Claude runs in the terminal. So rm -rf is completely invisible to rewind.
2. It doesn't cover untracked files. Your .env (the little file holding your secret keys), a local database, a brand-new file you haven't saved into git yet: these often sit outside every safety net, including rewind. One developer (issue #67917) watched Claude's Write tool do a full-file replacement on a deliberately git-ignored STATE.md. No error, no undo, content from earlier sessions just gone. Rewind couldn't touch it because the file was never something it tracked.
3. It only reaches inside the current session. Rewind walks back through checkpoints in the session you're in. Cross a session boundary and it's blind.
There's also a fourth, more confusing case worth naming: sometimes rewind shows you the changed file on its list screen, then the confirm step only offers "Restore conversation," not the code. One user hit exactly this (issue #20201): the code stays unchanged even though the change is right there in the list. That's the false sense of safety that hurts most, you think you have an undo button, and you learn at the worst possible moment that it's conversation-only.
This isn't a knock on Claude or on rewind. It's just the boundary of the tool. The problem is that the boundary is invisible until you cross it.
So how do you actually get your file back?
Rewind is out, so work down this list in order and stop the moment your file shows up. (For the full walkthrough with every platform, see Claude Code Deleted My Files? How to Recover Them.)
- Check the Trash / Recycle Bin. The most common save. If the file was moved rather than nuked, it's sitting right there. Right-click, Put Back (Mac) or Restore (Windows).
- Check your backup or cloud version history. Time Machine, iCloud, Dropbox, Google Drive, OneDrive, and Windows File History all quietly keep older versions. If your project lived in any of them, roll back to a version from before the loss.
- Check your git history. If the project is a git repo and you committed recently, you can restore. Just ask Claude in plain English: "Is this a git repo? Show me recent commits and help me restore the file that was just deleted. Explain each step before running it." The catch: git can only return what it had a snapshot of. Never committed, or the file was git-ignored? There's nothing to pull from.
- File-recovery software, as a last resort. Tools like Disk Drill or Recuva scan the drive for deleted files. The sooner you try the better, and know that if the file was overwritten (not just deleted), the old bytes are likely already gone.
The honest truth: if there was no backup, no git snapshot, and the file was overwritten or git-ignored, this is the case that sometimes can't be undone. That's not your fault. It's the gap rewind quietly leaves open.
How to make rewind's blind spot stop mattering
You can't extend rewind, but you can stop depending on it for the jobs it was never built for. Three moves, easiest first:
- Keep your project in a backup-synced folder. Dropbox, Google Drive, OneDrive, iCloud, or Time Machine for its location. Now every change keeps a recoverable history automatically.
- Ask Claude to set up git and make a checkpoint before big changes. You don't need to learn git. Just say: "Set up git if it isn't already and commit a checkpoint now, so I have a safe point to return to."
- Add a net for the files git and rewind skip. This is the real gap. Git and rewind don't protect what they were never told to watch: your
.env, your local database, brand-new files. Undeletable is a tiny local add-on that saves a byte-for-byte copy of a file before Claude touches it, no matter how Claude changes it (direct edit or terminal command). If something goes wrong you type/restore. It runs locally (no account, no cloud), it's a one-time $19, and it's prevention not magic: it protects files from the moment you install it forward, so the time to set it up is now.
You're not stuck
If rewind let you down, that's expected, not a failure on your part. Work the recovery list above, then take ten minutes to close the gap so the next scare is a non-event.
Start with the free Claude Code Safety Checklist. It's the calm, plain-English, do-this-then-this version of everything here, and we'll email it to you so you have it when you need it. When you want the always-on net for the files rewind misses, Undeletable is $19, one time, and lives quietly on your machine.
Related reading: Claude Code Deleted My Files? How to Recover Them · The Beginner's Safety Guide to Claude Code · Undeletable
Frequently asked questions
- Does /rewind undo files deleted by Claude Code?
- No. /rewind (Esc Esc) only undoes Claude's own Write and Edit changes inside the current session. It does not undo a file that was deleted or overwritten by a terminal command (like rm or mv), and it does not cover files that were never tracked, such as your .env or a local database. For those you need a backup, git history, or a tool like Undeletable.
- Why does /rewind show the change but not actually restore it?
- Some users see the changed file listed on rewind's screen, then the confirm step only offers to restore the conversation, not the code. That means rewind tracked the chat but not a recoverable file checkpoint for that change. It happens most when the change came from a terminal command or from outside the session rewind is looking at. Treat the list screen as a hint, not a guarantee.
- Does /rewind work across multiple sessions?
- No. /rewind only reaches back through the current session's checkpoints. If you closed Claude Code and reopened it, or the loss happened in an earlier session, rewind can't reach that far back. Your git history and your backup can, which is why both matter.
- Does /rewind undo rm -rf?
- No. rm -rf is a terminal command, and /rewind never tracks terminal commands, only Claude's direct Write and Edit edits. Once a file is gone from the filesystem, rewind has nothing to restore from. You need the Trash, a Time Machine or cloud version, your git history, or a pre-delete snapshot.
- What can /rewind actually undo, then?
- The thing it's good at: undoing Claude's direct edits to a file inside the session you're in. Asked Claude to rewrite a function and hate the result? Rewind brings the old version back. It's a fast everyday undo for Claude's own edits, not a safety net for deletes or untracked files.
Never lose your work to Claude Code.
Drop your email. The free Claude Code Safety Checklist lands in your inbox. The 2-minute setup that stops almost every “Claude deleted my work” story.
free · one email · the checklist · unsubscribe anytime