STUPID-2026-0125

Claude Code created a directory literally named "~", then an unquoted rm -rf * expanded into it and started deleting a developer's real home directory

7.0high
November 28, 2025Source checkedRepro reported

Why 7/10

The agent began wiping a real home directory. The report gives no size, and recovery was still in progress at filing.

Scope
3/4
A whole machine or drive, an organisation's production system or data, or many credentials
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

    Not stated in the issue. The reporter describes Claude Code's own actions in an unspecified prior session: it created a directory literally named `~`, then later ran `rm -rf *` in that directory's parent — the user did not ask for any deletion.

  2. Expected behavior

    Claude Code should never create a directory literally named `~`, and should never execute an unescaped wildcard delete like `rm -rf *` without confirming exactly what it would match — particularly not a command that can expand to include the user's actual home directory.

  3. Actual behavior

    In a prior session, Claude Code created a directory literally named `~` "in error." It later ran `rm -rf *` in that directory's parent, and — per the reporter — the shell expanded the glob to include that `~` entry, which resolved into the user's real home directory, so the delete began recursing into it.

  4. Damage

    The reporter says Claude Code "proceeded to start wiping my home directory" and that recovery was "continuing to be super frustrating" as of filing; no file count or size is given. Anthropic labeled the issue area:core, area:security, area:tools, bug, and platform:macos, then closed it "not planned" with no fix — the tilde-directory-plus-glob- expansion hazard the reporter flagged was left unaddressed.

Full write-up

A Claude Code user running v2.0.55 on macOS (via a PyCharm terminal) reported that, in a prior session, the agent had created a directory literally named ~ — the reporter calls it a glitch, with no indication of how the name arose. Later in that same session, Claude Code ran rm -rf * in the parent directory. Because a literal ~ entry was sitting there, the shell's glob expansion carried the deletion into the reporter's actual home directory, and it began recursing through it.

The reporter didn't quantify what was lost, only that the agent "proceeded to start wiping my home directory" and that recovering from it was "continuing to be super frustrating" at the time of filing. Their ask was narrow and specific: never run rm -rf * instead of naming exact directories, and treat a directory named ~ as the red flag it is — at minimum, stop and ask before either one executes. Anthropic tagged the issue area:core, area:security, area:tools, bug, and platform:macos, then closed it as "not planned." No fix was linked in the report, and the combination that caused it — Claude Code creating a stray ~ directory, then later deleting into it via an unescaped glob — remains possible today.

Classification

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

Related incidents

Cite this record
StupidLLM. "STUPID-2026-0125: Claude Code created a directory literally named "~", then an unquoted rm -rf * expanded into it and started deleting a developer's real home directory." AI Agent Incident Database, 2026. https://www.stupidllm.com/incident/STUPID-2026-0125/ (accessed 2026-11-17). CC BY 4.0.

← STUPID-2026-0124By IDSTUPID-2026-0126 →

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.