How to Recover Deleted Files from Cursor and Claude Code
Step-by-step guide to recovering files deleted by AI coding assistants. Works for Cursor, Claude Code, and other AI tools.
AI coding assistants are powerful, but they have a tendency to delete things. Sometimes it’s intentional consolidation. Sometimes it’s a misunderstanding. Sometimes the AI just decides a file shouldn’t exist.
Whatever the reason, you need those files back. Here’s how to recover them, organized by what tool you’re using.
Recovering Files in Cursor
Cursor has a checkpoint system that creates restore points when you use Composer. Look in the Composer panel for “Checkpoint created” messages. Each one represents a state you can return to. Click “Restore” on the checkpoint from before the deletion, and your files should come back.
The catch is that checkpoints only cover Composer interactions. If the deletion happened through Tab completions, or if you’ve accepted so many changes that the relevant checkpoint is buried, this won’t help.
For those cases, try Cursor’s inherited Local History feature. Press Cmd+Shift+P (or Ctrl+Shift+P on Windows), type “Local History: Find Entry to Restore”, and search for your deleted file. This feature maintains versions of files you’ve edited, even after deletion.
If the file tab is still open (even if the file on disk is gone), you might be able to recover the content with repeated Cmd+Z. It’s worth trying.
Recovering Files in Claude Code
Claude Code version 2.0 and later includes a rewind feature. Press Esc twice quickly, or type /rewind to open the checkpoint menu. You have three options: restore just the conversation (keep code changes), restore just the code (keep conversation), or restore both.
For file recovery, you’ll usually want “Code only” or “Both.”
The rewind feature is tied to conversation turns, so it works best for recent deletions. If you’ve had a long session with many interactions since the deletion, the restore point might be too far back to be useful.
Git Recovery (Both Tools)
If you were disciplined about committing before AI interactions, Git makes recovery straightforward:
git status # Confirm which files are deleted
git checkout . # Restore all deleted files to their last committed state
For a specific file:
git checkout HEAD -- path/to/deleted/file.ts
If the deletion was already committed (oops), you can still recover:
git log --diff-filter=D --summary # Find the commit that deleted the file
git checkout <commit-hash>^ -- path/to/file.ts # Restore from the commit before deletion
The limitation, of course, is that Git only protects what you committed. If you were iterating quickly without commits, Git can’t help.
System-Level Recovery
When editor and Git recovery fail, check your system backups.
On Mac, Time Machine often has recent versions. Open the folder where files were deleted, enter Time Machine from the menu bar, and navigate back in time.
On Windows, right-click the folder, select “Restore previous versions,” and pick one from before the deletion.
Cloud sync services like Dropbox, Google Drive, and iCloud also maintain version history. Check their web interfaces for recently deleted files.
The Better Approach: Automatic Protection
All of these recovery methods are reactive. They work after something goes wrong, assuming you got lucky with commits or checkpoints or system backups.
A better approach is proactive protection that doesn’t require luck or discipline.
mrq watches your project and captures every file change automatically. No commits to remember, no checkpoints to manage. It runs silently in the background:
mrq watch
When an AI deletes something:
mrq history # See recent snapshots
mrq restore abc123 # Restore to any point
Unlike Git, you don’t have to remember to save. Unlike editor checkpoints, it works regardless of which AI tool caused the deletion. Every state is captured, every file is recoverable.
The next time an AI assistant decides your codebase needs “cleaning up,” you’ll just restore and move on instead of scrambling through recovery options.
Related Reading
- AI Deleted My Code: How to Recover - Emergency recovery guide
- How to Undo Changes in Cursor AI - Complete Cursor undo guide
- How to Undo in Claude Code - Complete Claude Code undo guide
mrq is automatic versioning for AI coding. Every change captured, every file recoverable.
Written by mrq team