Claude Code Deleted My Files? How to Recover Them
Claude Code deleted or overwrote your work? Here's how to get your files back step by step, why /rewind didn't help, and how to make sure it never happens again.
Okay. Breathe.
Claude Code just deleted or overwrote something you cared about, and now your stomach is in your shoes. You are not the first person this happened to, and you are not stupid. This catches smart people every single day — and almost nobody explains, in plain English, what to actually do next.
So let's fix it. First we'll try to get your files back, in the order most likely to work. Then I'll explain why this happened (the answer surprises most people). Then I'll show you a simple 4-step setup so it can never wreck your day again.
Move fast on the recovery steps, but don't panic-click. The worst thing you can do right now is keep working in that same folder and accidentally write over the files you're trying to save.
First, don't panic — try these in order
Do these from top to bottom. Stop as soon as you get your files back.
1. Check the Trash / Recycle Bin
Sounds too simple, but it's the most common save. If Claude (or a command it ran) moved a file to the Trash instead of nuking it, it's sitting right there.
- Mac: open Trash, find the file, right-click → Put Back.
- Windows: open Recycle Bin, right-click the file → Restore.
If it's there, you're done. Go straight to "Make sure it never happens again" below so this is the last time.
2. Restore from a backup or cloud version history
If the folder you were working in was inside a backup-synced location, the old version is probably still recoverable. This works even if the Trash is empty.
- Time Machine (Mac): open the folder in Finder, then launch Time Machine and "travel back" to a time before the deletion. Restore the file.
- iCloud Drive (Mac): check iCloud.com → Settings → Restore Files — deleted iCloud files hang around for ~30 days.
- Dropbox / Google Drive / OneDrive: open the web version, right-click the file or folder → Version history or Deleted files, and roll back to an earlier version. Cloud drives quietly keep old versions of files — this saves people constantly.
- Windows File History: if it was turned on, right-click the folder → Restore previous versions.
Plain English: a "backup-synced folder" just means a folder that some service is automatically keeping copies of. If your project lived in Dropbox/Drive/OneDrive/iCloud, you very likely have a recoverable older copy. If it lived somewhere random on your hard drive with no backup turned on, this step won't help — skip ahead.
3. If your project is a "git repo," you have an undo button
Don't tune out at the word git. Here's all you need to know: git is a tool that takes snapshots of your project. If at any point you (or Claude) ran a "commit," git saved a snapshot you can jump back to. Many Claude Code projects have git running without you fully realizing it.
How to check and recover, even if you've never typed a git command:
Just ask Claude itself, in plain English:
"Is this project a git repository? If yes, show me the recent commits, and help me restore the files that were just deleted from the last commit. Explain each step before you run it."
If git is set up and you committed recently, this usually gets your files back cleanly. Two terms you'll hear:
git reflog— git's "history of your history." Even changes you thought were lost often show up here. It's the deep-recovery move.git restore/git checkout— pulls a file back to how it looked in your last snapshot.
The catch: git can only bring back what it had a snapshot of. If you never committed, or the file was brand new and never saved into git, there's nothing to restore from. Which is exactly why the prevention section below matters.
4. Last resort: file-recovery software
If the Trash is empty, there's no backup, and git can't help, you can try file-recovery tools (Disk Drill, PhotoRec, Recuva on Windows, etc.). These scan your drive for traces of deleted files.
Be honest with yourself about the odds here. When a file is deleted, the space it used isn't wiped immediately — but the moment something else gets written to that space, the old data is gone for good. So:
- The sooner you try, the better. Stop using that drive for anything heavy.
- Overwritten is not the same as deleted. If Claude replaced a file's contents (rather than removing the file), recovery tools often can't help, because the old bytes are already gone.
- Some cases genuinely aren't recoverable. That's the hard truth — and the whole reason the prevention setup below exists.
Why this happened (and why /rewind didn't save you)
Here's the part nobody tells beginners clearly.
Claude Code edits the real files on your computer — not copies. When it changes, moves, or deletes something, it's doing it to your actual project, live. There's no sandbox in between by default. That's what makes it powerful, and that's what makes a bad moment hurt.
"But I have /rewind!" — yes, and it's great, but it has a blind spot most people never learn about until it bites them.
What /rewind actually does
/rewind (you trigger it by pressing Esc twice) lets you undo Claude's direct edits — the changes Claude makes when it edits a file itself. Used Claude to rewrite a paragraph and hate the result? Rewind brings it back. Genuinely useful.
What /rewind does NOT do (the blind spot)
Rewind does not recover files that were deleted by a shell command.
Translation: Claude doesn't only edit files directly. Sometimes it runs terminal commands to get things done — commands like rm (remove), mv (move), or cp (copy/overwrite). When a file disappears because of one of those commands, rewind cannot bring it back. It only tracks Claude's own direct file edits, not the commands Claude runs in the terminal.
And there's a second gap: rewind doesn't cover files that were never being tracked in the first place — like your .env file (the little file that holds your secret keys and passwords) or a local database. Those often sit outside the safety net entirely.
So the classic "Claude deleted my work and rewind won't undo it" situation is almost always one of these:
- A file got removed or overwritten by a terminal command, not a direct edit — rewind can't see it.
- The lost file was a
.env, a database, or something never tracked — nothing was watching it.
This isn't a knock on Claude. It's just the boundary of the built-in tool — and it's exactly why a backup that doesn't care how a file changed is worth setting up.
Want the deeper version? See Why /rewind can't undo
rm— and what to do instead in the Safety Hub.
Make sure it never happens again (4-step safety setup)
You can make this the last time, in about ten minutes. Here's the setup, easiest first.
1. Work inside a backup-synced folder
Move your project into Dropbox, Google Drive, OneDrive, or iCloud (or turn on Time Machine for its location). Now every change keeps a recoverable history automatically, no thinking required. This one move alone would have saved most people reading this.
2. 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 for this project if it isn't already, and commit a checkpoint right now so I have a safe point to return to. Do this again before any big change."
Now you've got snapshots to roll back to. Make it a habit: before you let Claude do anything large, ask for a checkpoint first.
3. Learn /rewind — and its limits
Keep using /rewind (Esc Esc) for quick undos of Claude's direct edits. Just remember the blind spot from above: it won't save you from a deleted .env, a wiped database, or a file removed by a terminal command. Treat it as your fast everyday undo, not your safety net.
4. Add a real safety net: Undeletable
Steps 1–3 cover a lot. But notice the gap they leave: git and rewind don't protect the files they were never told to watch — your .env, your local database, brand-new files you haven't committed yet. Those are exactly the ones that hurt most when they vanish.
That's the hole Undeletable is built to fill. It's a tiny add-on for Claude Code 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 and get it back. Including the .env and the database that git and rewind quietly skip.
A few honest notes so you know exactly what you're getting:
- It runs locally on your machine. No account, no cloud, no upload of your files.
- It's a one-time $19, not a subscription.
- It's prevention, not magic. It protects files going forward, from the moment you install it. It can't reach back and recover something it never had a chance to copy — so the time to set it up is now, while you're motivated, not after the next scare.
Think of it as the seatbelt for the messy edits where git and rewind look the other way.
You've got this
If you got your files back — great, breathe out. If you didn't, I'm genuinely sorry; that's a rotten feeling, and it's exactly why the setup above exists, so it's the last time.
Either way, take ten minutes today and set up the safety net while it's fresh. Grab the free Claude Code Safety Checklist — it's the calm, plain-English, do-this-then-this version of everything above, 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 git and rewind miss, Undeletable is $19, one time, and lives quietly on your machine.
And if you want to actually get good at Claude Code without the white-knuckle moments, the beginner course ($47) takes you from nervous to confident — but start with the free checklist. No rush.
Related reading: The Beginner's Safety Guide to Claude Code · The Claude Code Playbook · Undeletable
Frequently asked questions
- Does Claude Code's /rewind recover deleted files?
- Only sometimes. /rewind (Esc Esc) undoes Claude's direct edits to files. It does not recover files deleted or overwritten by a terminal command (like rm or mv), and it doesn't 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.
- My /rewind isn't working / won't undo it — why?
- The most common reason is that the change wasn't a direct edit Claude can rewind — it was a terminal command Claude ran, or the file was something rewind never tracked (.env, a database, a brand-new file). In those cases rewind genuinely can't help. Try your Trash, your cloud/Time Machine version history, and your git history instead.
- Can I recover a file Claude deleted if I don't use git?
- Maybe. Check your Trash/Recycle Bin first, then any cloud backup (Dropbox, Google Drive, OneDrive, iCloud) or Time Machine version history. If none of those had it, file-recovery software is a last resort — but if the file was overwritten rather than simply deleted, the old contents may already be gone. No backup plus no git plus an overwrite is the case that often can't be undone.
- How do I recover a deleted .env file in Claude Code?
- .env files are usually not covered by /rewind or git (git is normally told to ignore them on purpose). So check your Trash, your cloud/Time Machine version history, and your editor's local history first. If you had nothing protecting it, you may have to recreate it from your password manager or the services that issued those keys. Going forward, a tool like Undeletable can keep a copy of your .env specifically because the usual tools skip it.
- Does Claude Code edit real files or just copies?
- Real files. Claude Code works directly on the actual files on your computer, live — that's why a mistake is a real change, not a preview. It's also why having a backup or safety net in place matters before you start letting it make big changes.
- How do I stop Claude Code from deleting my work in the first place?
- Four things: keep your project in a backup-synced folder (Dropbox/Drive/iCloud/Time Machine), ask Claude to set up git and make a checkpoint before big changes, use /rewind for quick undos while knowing its limits, and add a real safety net like Undeletable that copies files before Claude touches them.
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