The AI was "cleaning up" and now files are gone. Stop and breathe: there's a good chance you can get them back. If Claude Code or Cursor deleted your files, work through these steps in order and don't let the AI run anything else until you're done.
First: stop the AI
Don't send another request, and don't accept more changes. Every extra action makes recovery harder. If the AI is still running, stop it.
Step 1: try the tool's own undo
Cursor: scroll up in the chat to a checkpoint from before the deletion and restore it. This works for changes the AI made through its editing tools.
Claude Code: type /rewind (or press Esc twice with an empty input box), pick the prompt before the deletion, and restore the code.
The catch, from Claude Code's own docs: checkpoints only track edits made through the AI's file-editing tools. Files deleted by a terminal command like rm are not tracked, so rewinding won't bring them back. If that's what happened, go to Step 2.
Step 2: use git
If your project uses git, open a terminal in the project folder and run:
git status
Deleted files that git knew about show up as "deleted". To bring back all tracked files to your last save point:
git restore .
This also undoes any other unsaved changes, so only do it if you're happy going back to the last commit. To bring back one file only, use git restore path/to/file.
If the AI made a commit that deleted things, git log --oneline shows recent commits; our undo guide explains git revert and rescuing "lost" commits with git reflog.
Step 3: other places copies may live
- Your computer's trash or recycle bin, if files were deleted through the editor rather than a terminal command.
- Your editor's local history. Cursor is built on VS Code, which keeps a local history of files you've edited; try the Timeline view on a file in the same folder.
- GitHub or another remote, if you pushed recently.
- Backups such as Time Machine on a Mac or File History on Windows.
- Your hosting provider, if the site was deployed: the live build may still have the files.
If nothing works
Be honest with yourself about what's gone, rebuild from what you have, and treat it as the push to set up the habits below. It's a painful lesson most builders learn exactly once.
Stop it happening again
- Make git save points before every big request. See git for vibe coders.
- Add a rule that the AI must ask before deleting files or running
rm,git reset --hard,git cleanorgit push --force. See Cursor rules for beginners and what to put in CLAUDE.md. - Push to a private GitHub repository so there's a copy off your machine.
Get the rules ready-made
The "ask before risky actions" and "no destructive git without a yes" rules are both in our free starter pack, for Cursor and Claude Code. The Ship-Safe Starter Kit adds a plain-English git undo cheat sheet for exactly this moment.
Vibe Shipped is independent and not affiliated with Cursor (Anysphere, Inc.) or Anthropic, PBC. Written with AI assistance and reviewed by a human.
Want these rules ready-made?
The free starter pack has them, set up for Cursor and Claude Code.