STUPID-2026-0097
Claude Code appended a stray "~/" to a cleanup command and wiped a developer's entire Mac home directory, unrecoverable due to SSD TRIM
Why 9/10
An entire Mac home directory, Keychain credentials included, was destroyed. TRIM made recovery impossible.
- Scope
- 3/4
- A whole machine or drive, an organisation's production system or data, or many credentials
- Recoverability
- 3/3
- Permanently lost or irreversible, including data that was exposed
- Did it happen
- 2/2
- Happened in real use
- Beyond the user
- 1/1
- Production systems, customers or third parties, or credentials and sensitive personal data
The score is the sum of these four factors. How each factor is scored · scored 2026-10-29
Status and what to do
- Affected
- Claude Code on macOS; the version is not recorded.
- Fix status
- No fix linked · The source is a blog write-up of a user's Reddit post; no vendor issue or fix is linked.
- Mitigation
- Turn on Claude Code's sandbox (/sandbox). Its docs say sandboxed commands can write only to the working directory, a per-user temp directory and folders you add, so a home-directory delete fails. The record does not say whether it was on. Source
- Last reviewed
- 2026-10-29 · Report a correction to this record
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 *)"
]
}
}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")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)"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)'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.
Instruction given
Clean up an old repository by removing its tests/, patches/, and plan/ directories.
Expected behavior
Scope the delete to the three named project directories and leave everything else, including the user's home directory, untouched.
Actual behavior
Claude Code ran `rm -rf tests/ patches/ plan/ ~/`, appending a trailing `~/` after the three intended targets. The shell expanded `~/` to the user's home directory, and the recursive delete removed Desktop, Documents, Downloads, the Library folder (application state for every installed app), the macOS Keychain, and all local credentials — including Claude Code's own stored authentication.
Damage
The developer's entire Mac home directory was destroyed: years of project files, personal photos, SSH keys, git config, and every credential stored in Keychain. Because the drive was an SSD with TRIM enabled, freed blocks were zeroed at the controller level, so no forensic or file-recovery tool could bring anything back. The user reported no successful recovery.
Full write-up
A developer using Claude Code (posting on Reddit as u/LovesWorkin) asked the agent to clean up an old repository by removing its tests/, patches/, and plan/ directories. Claude Code instead ran rm -rf tests/ patches/ plan/ ~/ — the trailing ~/ after the three real targets expanded to the user's home directory, and the whole thing was deleted: Desktop, Documents, Downloads, the Library folder, Keychain, SSH keys, and every other credential on the machine, including Claude Code's own login. Because the underlying SSD had TRIM enabled, the freed blocks were zeroed immediately, so none of the standard undelete or forensic recovery approaches could get any of it back. The original report reached roughly 1,500+ upvotes within hours and was amplified by Simon Willison, and Docker's engineering blog later cited it by name as the case study motivating sandboxed execution for coding agents — isolating the agent's filesystem so a ~/ expansion resolves to a disposable workspace rather than the real home directory. This is the same failure class as the root-level rm -rf in STUPID-2026-0042 and the EXIT-trap $HOME wipe in STUPID-2026-0094, but a distinct mechanism (an unscoped path appended to an otherwise-correct multi-target delete command) on a different platform (macOS rather than WSL2/Ubuntu).
Classification
- Agent
- Claude Code
- Failure mode
- Destructive Action
- Root cause
- Tool Misuse
- Domain
- Infra
- 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
- Source
- Blog Post
Related incidents
Cite this record
StupidLLM. "STUPID-2026-0097: Claude Code appended a stray "~/" to a cleanup command and wiped a developer's entire Mac home directory, unrecoverable due to SSD TRIM." AI Agent Incident Database, 2026. https://www.stupidllm.com/incident/STUPID-2026-0097/ (accessed 2026-12-04). CC BY 4.0.
← STUPID-2026-0096By IDSTUPID-2026-0098 →
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.