STUPID-2026-0145

Claude Code ran rm -rf on duplicate photo folders before verifying an earlier move had actually worked, destroying ~2,969 irreplaceable personal photos (GitHub #92737)

6.0medium
September 7, 2026Source checked

Why 6/10

About 2,969 personal photos were deleted after an unverified move. They may be partially recoverable.

Scope
2/4
One project, repository, server or service, or a cost above roughly $10,000
Recoverability
2/3
Partly lost, or loss reported without saying whether it was recovered
Did it happen
2/2
Happened in real use
Beyond the user
0/1
Only the user's own non-production work

The score is the sum of these four factors. How each factor is scored · scored 2026-10-29

Guardrail rules for this command

Recursive deletes: make your agent stop and ask before running these. Free to copy; written in each tool’s documented format.

Claude Code · the agent in this incident
{
  "permissions": {
    "ask": [
      "Bash(rm -r*)",
      "Bash(rm -fr*)",
      "Bash(rm -R*)",
      "Bash(find * -delete*)",
      "PowerShell(Remove-Item *)",
      "Bash(cmd /c rmdir *)",
      "Bash(cmd /c del *)"
    ]
  }
}
Add to .claude/settings.json in the project (or ~/.claude/settings.json for every project). Each matching command then asks you first, including in auto mode.

Stronger control: Turn on the sandbox (/sandbox): shell commands can then write only to the project, a temp folder and directories you add. It runs on macOS, Linux and WSL2; on native Windows Claude Code runs commands unsandboxed. Docs

Codex
prefix_rule(pattern = ["rm", ["-r", "-rf", "-fr", "-R"]], decision = "prompt", justification = "Recursive delete: confirm the target first")
Save as ~/.codex/rules/stupidllm.rules and restart Codex. Codex's docs describe rules as controlling commands run outside its sandbox, and mark them experimental.

Stronger control: Keep Codex's OS sandbox on (it limits writes, typically to the workspace) and leave approvals on for sessions that can reach data you cannot lose. Docs

Gemini CLI
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["rm -r", "rm -fr", "rm -R"]
decision = "ask_user"
priority = 100
denyMessage = "Destructive command: needs a human to confirm (stupidllm.com)"
Save as ~/.gemini/policies/stupidllm.toml. Workspace-level policy files are disabled in Gemini CLI, so this must be the user-level folder.

Stronger control: Policies in ~/.gemini/policies apply in every approval mode unless a rule's modes field narrows them. Docs

Copilot CLI
copilot --deny-tool='shell(rm)'
Pass on the command line. Copilot CLI matches the program name (and git/gh subcommands), so this blocks the whole command, not just its dangerous form.

Stronger control: Avoid --allow-all-tools on a machine with data you cannot lose; --deny-tool takes precedence over it. Docs

What these cannot do: a pattern rule matches the command text the agent writes. In Anthropic’s words it “isn’t a security boundary around the program”: /bin/rm, sh -c or a script that runs the same thing gets past it (STUPID-2026-0124 got past a guard with cmd /c). Use the sandbox as well, and keep backups of what you cannot lose.

  1. Instruction given

    Organize photos in a `sort/` folder on the user's Desktop, which contained duplicate year folders — `2013` alongside `2013a`, `2014` alongside `2014a`, `2015` alongside `2015a` — by merging the "a" duplicates into the originals and removing the now-redundant "a" folders.

  2. Expected behavior

    After moving files out of a folder, verify that the destination file count matches the source count before deleting the source. If the counts don't match, stop and investigate rather than deleting. Never run `rm -rf` on user data without that verification, and prefer staging the files or keeping a backup over an immediate destructive delete.

  3. Actual behavior

    Claude wrote a move script that used `export -f` to export a shell function — a construct that works in bash but silently fails in zsh, the user's actual shell, so the intended file moves never happened. A second script it tried had its own bug: `find -maxdepth 1` missed files sitting in subdirectories. Without checking that the destination counts (1,722 files for `2013a`, 986 for `2014a`, 261 for `2015a`, by Claude's own earlier tally) actually matched what had landed in the merged folders, Claude ran `rm -rf` on the "a" folders.

  4. Damage

    Approximately 2,969 irreplaceable personal photos were permanently deleted, since the move that was supposed to precede the delete had silently failed. The reporter described being extremely distressed, and separately emptied the Trash during the same session, compounding the loss. The files may be partially recoverable with data-recovery software, but that isn't guaranteed. The issue is labeled `bug`, `data-loss`, `area:bash`, and `high-priority`, and remains open with no maintainer fix at the time of writing; a non-maintainer commenter suggested count-gated cleanup and `rsync --remove-source-files` instead of move-then-delete.

Full write-up

On September 7, 2026, a Claude Code user (@ycarlson) filed GitHub issue #92737 after asking Claude to tidy up a sort/ folder on their Desktop that held duplicate year folders from a photo import — 2013 next to 2013a, 2014 next to 2014a, 2015 next to 2015a. Claude tallied the duplicates first (1,722 files in 2013a, 986 in 2014a, 261 in 2015a) and wrote a script to move them into the originals. That script used export -f to export a shell function, which works in bash but silently fails in zsh — the user's actual shell — so none of the files were moved. A second attempt used find -maxdepth 1, which missed files sitting in subdirectories and so still didn't fully reconcile the folders.

Claude then ran rm -rf on the "a" folders to finish the cleanup, without first checking that the destination counts matched what it had tallied going in. Because the earlier move had silently failed, the delete simply destroyed the original files: roughly 2,969 personal photos gone, with no backup. The reporter called the loss irreplaceable and said they were extremely distressed, and noted they had also emptied their Trash during the session, removing another avenue for recovery. The issue carries the labels bug, data-loss, area:bash, and high-priority. No Anthropic maintainer has commented; a non-maintainer reply recommended gating any future cleanup on matching find | wc -l counts and using rsync --remove-source-files in place of a separate move-then-delete, and suggested data-recovery software as a next step, with no guarantee of success.

Classification

Failure mode
Destructive Action
Domain
Other
OWASP Agentic Top 10 (our mapping)
ASI02 Tool Misuse and Exploitation list
MIT AI Risk Repository (our mapping)
7.3 Lack of capability or robustness taxonomy

Related incidents

Cite this record
StupidLLM. "STUPID-2026-0145: Claude Code ran rm -rf on duplicate photo folders before verifying an earlier move had actually worked, destroying ~2,969 irreplaceable personal photos (GitHub #92737)." AI Agent Incident Database, 2026. https://www.stupidllm.com/incident/STUPID-2026-0145/ (accessed 2026-11-11). CC BY 4.0.

← STUPID-2026-0144By IDSTUPID-2026-0146 →

Get told when an agent breaks something

We document AI agent failures daily, severity-scored against a published scale. Each Monday, if any scored 7 or above that week — deleted data, leaked secrets, broken production — you get one email with the sources. When nothing did, you get nothing.

This database is callable over MCP — query it from inside your agent.