What to do when an AI agent deletes files on your Mac
Recover files an AI agent deleted on your Mac. Find a copy in Git, Time Machine or iCloud, check which session touched the folder and protect the next backup.
Stop the agent’s task, including any helper still working in the same folder. Write down the missing path and when you last saw the files. Then look for the newest surviving copy. A committed source file, an untracked folder of photographs and an iCloud Drive document can disappear from the same Finder window. Each has a different route back.
The first five minutes
- Pause anything still writing there. Cancel an automatic retry or scheduled cleanup. If an editor still shows the missing document, leave it open. Use Save As to preserve its contents under a new name on another volume if one is available.
- Check where you are. In Finder, open the parent folder and check its full path. In a repository, confirm the branch and working folder. An agent can finish a task on another branch or in a second working copy. Search for one distinctive filename to see whether the folder moved.
- Preserve what survived. Record the agent, approximate time, session and affected filenames. Keep the original session available locally. If an older version of the same file has already appeared, save a separate copy of it before restoring anything over it.
| What went missing? | Where to look first | What you can get back |
|---|---|---|
| A local file Git never tracked | Finder Trash, an open editor, Time Machine, another device or an independent copy | The version the editor or backup actually holds. A file that only ever existed in the working folder has no copy in Git. |
| A Git-tracked file | The last commit containing the path, the Git index if you staged recent edits, or a teammate’s copy | Committed contents and possibly staged changes. Later edits may survive in editor history or a backup. |
| A cloud-only or synced file | The service’s web interface, deleted-items view and version history | Whatever the provider retained for that account. For a shared folder, ask its owner to check their view too. |
Recover one file first
For an untracked local file, check Trash. If the item is there, Finder offers File → Put Back. If the agent removed the file from a shell, Trash may be empty. If Time Machine backed up the folder, open its parent in Finder, launch Time Machine and browse to a point before the deletion. Inspect the filename and date, then restore the item. Apple returns it to its original location. If it was your only copy and these checks turn up nothing, pause work on that volume while you decide whether to seek data recovery help. Apple’s Trash guide · Restore a Time Machine backup
For a file in Git, open its history and inspect the contents at a known commit. Run git status in the repository to see what else changed. A narrowly scoped restore can recover a path from a chosen commit or from the index, where Git keeps staged contents. Preview the candidate version first and preserve any surviving edits. An entire project rollback can overwrite unrelated work that happened after the file vanished. Git status · Git’s file restoration reference
For an iCloud Drive file, check Recently Deleted on iCloud.com. Apple allows recovery for up to 30 days unless someone permanently removed the item. Leave iCloud Drive data alone during restoration. Other cloud services set their own retention periods. When the missing item is a database volume, contact the infrastructure provider promptly. In its April 29, 2026 account of a production deletion, Railway confirmed it recovered a customer’s data after the backups disappeared from that customer’s dashboard. Apple’s iCloud recovery instructions · Railway’s incident report
Open the recovered file and check a detail you remember changing recently. If you lost a folder, check the file count against a previous listing and open two or three recent items. Write down the backup time and any newer work still missing before you resume the task.
Check which action reached the folder
Look in the session around the time of the disappearance. Record the tool, working directory, affected path and result. Check helper sessions if the main agent delegated the work. A recorded command establishes what the agent attempted. Its response and the state of the folder help establish what happened. Keep the transcript local because commands and tool responses can contain credentials. Read a Claude Code or Codex session on your Mac
The recovery options depend on the agent and the tool it used. Claude Code’s rewind feature tracks files touched by its editing tools. A file changed only by a shell command falls outside that history, and many helper edits have limited coverage. In a separate January 2, 2026 GitHub report, a Gemini CLI user on Linux described JSON files disappearing during a comparison task. That issue records one user’s experience with their configuration. Claude Code checkpoint documentation · Gemini CLI user report
Protect the next copy
Keep a backup outside the agent’s write access and test that you can restore a single file. Restrict cleanup tasks to folders the agent may change. In Excellent’s November 13, 2026 controlled test, ordinary agents without the folder rule deleted the test backups in five of six unprotected runs. In 18 fully protected folder trials, the macOS sandbox enforced the restriction and the file hashes stayed intact. Each run used a test folder in a fresh, simulated home directory. Study methods and results
Once you’ve accounted for the files, the free scan can check supported local agent logs for recorded actions. Use the security guide to decide which folders the next task may change. Run the free scan · AI agent security for local development



