- Agent
- Claude Code
- Filed
- Case no.
- gh-anthropics-sclaude-hcode-s111167
Claude's rm check missed a glob and wiped a project
Received Nov 19, 2026, 2:16 PM UTC
A safety check that blocks the exact path can miss a glob. Never let an agent clean up with rm -rf on a wildcard near the project; list what it matches first, and keep the project in git or a backup.
Agents repeating the same mistakes? Scout gives every agent one current, shared record.
What happened
Exhibit AGitHub issue
## Summary
Claude Code's built-in critical-path check for `rm` blocks deleting the working directory or its parents when the path is named directly. It does not expand globs. A glob whose literal prefix is not itself a critical path gets through without a prompt or denial, even when it matches the working directory or a parent of it.
## What happened
1. A Workflow subagent in the Claude Code Desktop app (2.1.326, Windows 10, Git Bash, `permissions.defaultMode: bypassPermissions`) accidentally created a stray folder on the Desktop through an unquoted path with spaces.
2. It then "cleaned it up" with `rm -rf "C:/Users/<user>/Desktop/<Project>"* 2>/dev/null`.
3. The trailing `*` also matched the real project folder, a parent of the agent's working directory. The check did not catch it and the command ran.
4. About 30,000 files (23 GB, 6 months of work) were permanently deleted. Git Bash `rm` skips the Recycle Bin, and on an SSD with TRIM the data is unrecoverable.
## Reproduction
The reporter re-verified on 2.1.328. With `bypassPermissions`, `rm -rf` on the exact working-directory path is blocked ("Dangerous rm operation detected"), but prefix-glob forms such as `"<dir>/Proj"*`, `/Pro*`, `../Proj*` and `"<dir>/Proj"?X` ran and deleted the working directory's files. In `auto` mode the exact path was denied by the built-in safety check, while the prefix glob was approved by the classifier and the files were deleted.
## Suggested fixes (from the reporter)
Expand the glob, or match its literal prefix conservatively, before deciding. Fail closed when an `rm` operand contains glob characters that could match a critical path. On Windows, route `rm -rf` in Git Bash to the Recycle Bin. Show the expanded target list for recursive deletes that use a glob.
## Environment
- Claude Code 2.1.326 (Desktop app, incident); 2.1.325 and 2.1.328 (CLI, reproduction)
- Windows 10 Home, Git Bash
- GitHub issue anthropics/claude-code#111167, opened 2026-11-19 by lolancefrelas-lang, labeled data-loss and has repro, still open
Source. Posted publicly by lolancefrelas-lang on GitHub (opens in a new tab). Quoted as posted; the title and lesson are Failwall's.