Cursor deleted my files: recovery steps and settings that prevent it
If Cursor deleted files, stop the agent and stop writing to the disk. Then open the checkpoint timeline in the chat and restore the point before the deletion, which reverts your files to that state. If the agent deleted with a terminal command, the checkpoint will not bring the files back, so go straight to Git. After that come the Trash and Time Machine (open it from Spotlight, in the Other folder). Cursor's checkpoints are stored locally and separate from Git, so Git and backups are your second line.
Finding a project folder empty after an agent session is stressful, and other users have reported similar losses. The steps below go from the quickest to the most thorough. Take them in order, and leave the settings until your files are back.
01What to do first when Cursor deleted files
The aim of the first minutes is simple: keep whatever is still on the disk and find the quickest copy.
- Stop the agent and stop using the Mac. Stop the running task and close the chat so the agent cannot run another command. Every moment of use risks overwriting the deleted data for good.
- Look at the checkpoint timeline in the chat. It only helps if the agent used its file-editing tools; see the next section.
- Check Git. If the project was committed, the files are likely in it.
- Check the Trash, then Time Machine.
02Restore a Cursor checkpoint
After Cursor deleted files, the checkpoint is the quickest thing to try. A Cursor checkpoint is a snapshot of your codebase taken during an Agent session. The agent creates them automatically before it makes significant changes, and they capture the state of all modified files. To restore one, click any checkpoint in the chat timeline to preview your files at that point, then restore to revert all files to that state. Restoring a checkpoint reverts files only. It does not remove messages from the conversation.
Warning: restoring reverts all files to that state, so a good edit made after the checkpoint goes too. Copy out anything you still need first.
One limit matters after a deletion. Restore Checkpoint only undoes edits the agent made with its file-editing tools. Changes it made by running terminal commands, such as a Python or sed script, or through subagents, and edits you made yourself, stay in place. A user on the Cursor forum wrote that a PowerShell deletion could not be recovered from the checkpoint, as far as they tried. If the checkpoint does not bring the files back, move on to Git. There is more on restoring a Cursor checkpoint.
03Bring files back from Git
If the deleted files were tracked in Git (saved into the project history), restoring one is a single command. Git's documentation shows it for a file deleted by mistake, which it gets back from the saved copy:
git restore <file>Put the real path in place of <file>. Warning: this replaces the file in your folder with the saved copy, so edits to that file that you never committed are lost. Name the files one by one, because Git removes a tracked path that does not exist in the saved copy. The full guide, including older commits, is on restore a deleted file in Git.
Cursor itself expects this. Agents can modify workspace files without approval, except configuration files, and changes save immediately to disk. Its security page says to always use version control so you can revert changes.
04Trash and Time Machine
When Cursor deletes a file from the agent chat, do not assume it went to the Trash: look there, but be ready to use the other steps. Changes the agent makes are written to your workspace on disk straight away, so a backup that predates the session is what holds the old version.
Dragging items to the Trash does not delete them until the Trash is emptied. Select the item and use File > Put Back to return it. If the Trash was emptied, Apple warns that the items are permanently deleted.
Time Machine is next. Open the folder that held the files, then open Time Machine: press Command-Space, type Time Machine and open it (it sits in the Other folder). Select the items and click Restore. Restored items return to their original location. Even without the backup disk attached, local snapshots may hold earlier versions of files. They are created hourly and kept for up to 24 hours, or until the disk needs space. The full steps are on restore from Time Machine and recover deleted files on a Mac.
If a whole user folder is gone, Migration Assistant can restore all personal files, apps and everything in your user account from a Time Machine backup. On an SSD, a drive feature called TRIM makes recovery much harder. That is why a backup beats any recovery tool.
05Why is Cursor deleting everything?
A Cursor agent can change workspace files without asking you, except configuration files, and in Run Everything (YOLO) mode every tool call runs automatically. So one bad run can reach a lot of files.
A forum thread from June 2025 shows how that goes. A user running Cursor in YOLO mode (the same Run Everything mode, where the agent runs commands without asking) said it tried to delete some old files, failed the first time, and ended up deleting everything on the computer. Cursor staff replied by asking whether file deletion protection in the Auto-run settings was enabled, and recommended running YOLO mode in a virtual environment.
In another thread, a user reported that delete protection did not stop the agent from calling PowerShell Remove-Item -Recurse -Force on a folder. So treat a setting as a guard, not as a guarantee.
06Settings that limit deletes
Run modes live in Settings > Agents > Approvals & Execution in the desktop app. Cursor calls Auto-review the safest useful setup for most people: it runs known-safe calls, puts shell commands in a sandbox when it can, and has a classifier (a separate AI model that reviews a call before it runs) check anything else. A sandbox is a limit the system enforces around a command, so it cannot freely read protected files, write outside approved paths or reach arbitrary network destinations. Auto-review is not a security boundary, because the classifier can make mistakes. So turn it on, and keep Git as well.
| Setting | What it does |
|---|---|
| File-Deletion Protection | Prevents the agent from automatically deleting files, including rm commands |
| External-File Protection | Prevents automatic creating, modifying or deleting of files outside the workspace |
| Run Everything (YOLO) mode | Every tool call runs automatically |
| Other protections | Can require approval even when a mode would otherwise run automatically |
Cursor's docs describe run modes as best-effort guardrails rather than a hard security boundary. That is why version control and backups come first. For the full settings, see Cursor sandbox, Cursor YOLO mode and Cursor security.
07What to take from this
If Cursor deleted files, work from the quickest fix to the widest net: checkpoint, Git, Trash, Time Machine. Commit before an agent session, because committing before an agent session is the most reliable way to roll back. If you are on a different tool, the same steps apply on Claude Code deleted files and Codex or Gemini CLI deleted files. If the loss is a database, go to AI deleted my database. For the pattern behind these cases, read when an AI agent goes rogue.
If Cursor deleted files with a terminal command, the checkpoint may not hold them. A checkpoint brings files back afterwards; it does not show what ran on the Mac. Artificial Immunity's free, open-source core watches Cursor sessions and every program start on your Mac and reports what it finds, without stopping anything.
FAQ
Why is my Cursor deleting everything?
A Cursor agent can change workspace files without asking you, except configuration files, and in Run Everything (YOLO) mode every tool call runs automatically. In one forum report, a user running Cursor in YOLO mode says it tried to delete some old files, failed the first time, and ended up deleting everything on the computer. That is one user's account.
Where can I find recently deleted files?
Check the Trash first, since items stay there until it is emptied. Emptied items are permanently deleted, so after that your options are Git and Time Machine.
Where does Cursor save files?
Agent changes save immediately to disk in your workspace. Cursor checkpoints are stored locally and separate from Git.
Can I recover a file I accidentally deleted?
Often, yes. Try a Cursor checkpoint, which reverts files to the state you pick, then Git, then the Trash and Time Machine. The order and limits are on this page.
Does Cursor's delete protection stop every delete?
Cursor describes File-Deletion Protection as preventing the agent from automatically deleting files, including rm commands. A user on the Cursor forum reported that it did not stop a PowerShell Remove-Item command, so keep Git and backups as well.
Should I commit before an agent session?
Yes. A Cursor forum reply says committing before an agent session is the most reliable way to roll back. Cursor's security page says to always use version control.
Related guides
Sources
- Cursor docs, agent overview (checkpoints)
- Cursor docs, run modes
- Cursor docs, agent security
- Cursor forum, restore checkpoint reply
- Cursor forum, deletion thread (user report)
- Cursor forum, delete protection and checkpoint (user report)
- Git documentation, git-restore
- Apple Support, restore files
- Apple Support, back up with Time Machine
- Apple Support, empty the Trash
- CleverFiles, recover files with Terminal
- Artificial Immunity