STUPID-2026-0129
Claude Code's own `git worktree remove --force` followed NTFS junctions and destroyed their targets on an emergency disk reclaim, while shell-level Remove-Item, rm -rf and shutil.rmtree all left the same junctions untouched (GitHub #84162)
Why 6/10
Junction targets were destroyed by git worktree remove. The amount actually lost is not quantified.
- 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 and Destructive git: 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 *)",
"Bash(git reset --hard*)",
"Bash(git clean *)",
"Bash(git push --force*)",
"Bash(git push -f*)",
"Bash(git stash drop*)",
"Bash(git filter-repo*)",
"Bash(git worktree remove *)"
]
}
}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")
prefix_rule(pattern = ["git", "reset", "--hard"], decision = "prompt")
prefix_rule(pattern = ["git", "clean"], decision = "prompt")
prefix_rule(pattern = ["git", "push", ["--force", "-f"]], decision = "prompt")
prefix_rule(pattern = ["git", "stash", "drop"], decision = "prompt")
prefix_rule(pattern = ["git", "filter-repo"], decision = "prompt")
prefix_rule(pattern = ["git", "worktree", "remove"], decision = "prompt")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)"
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["git reset --hard", "git clean", "git push --force", "git push -f", "git stash drop", "git filter-repo", "git worktree remove"]
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)' --deny-tool='shell(git reset)' --deny-tool='shell(git clean)' --deny-tool='shell(git stash)' --deny-tool='shell(git filter-repo)' --deny-tool='shell(git worktree)'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
No explicit instruction to delete anything. Claude Code automatically creates an isolated git worktree per isolated agent and per workflow step on Windows; none of the resulting worktrees were ever auto-removed, so they accumulated to 136 registered worktrees (~130GB, ~945,000 files) by the time of filing. On 2026-07-08, the user ran an emergency disk-space reclaim that called `git worktree remove --force` on the accumulated worktrees.
Expected behavior
Removing a worktree directory should remove only that worktree. Where a worktree's `node_modules` (or any other path inside it) contains an NTFS directory junction pointing elsewhere on disk — including back into the main tree's own data directories — the removal should delete the junction link itself, not recurse into whatever it points to.
Actual behavior
`git worktree remove --force` recursed through the NTFS junctions and deleted their targets outright, destroying files outside the worktree being removed; the junction's directory shell was left behind with its contents gone. The reporter isolated the exact mechanism by testing five different removal methods against the same junctioned worktree: PowerShell 7.5.8 `Remove-Item`, Windows PowerShell 5.1 `Remove-Item`, Git Bash `rm -rf`, and Python's `shutil.rmtree` all left the junction target intact — only `git worktree remove --force` followed the link and destroyed what it pointed to. A full night of remediation afterward reclaimed zero bytes, because every one of the 136 worktrees had to be individually proven safe to remove before touching it.
Damage
The junction targets reached by the 2026-07-08 `git worktree remove --force` run were destroyed — files gone, empty directory shells left behind — though the issue does not quantify how much data that run destroyed specifically; the 130GB/945,000-file figure is the size of the worktree backlog at filing time, not the measured loss. About 30% of one week's usage was spent on diagnosis and cleanup that recovered nothing. The issue was filed with the `area:core` label, received no maintainer response, and was closed as not planned.
Full write-up
On August 5, 2026, a Claude Code user (ThatDragonOverThere) filed anthropics/claude-code issue #84162 describing a Windows-specific data-loss mechanism inside the product's own worktree cleanup. Claude Code creates an isolated git worktree for each isolated agent and each workflow step; on this user's machine none of them were ever automatically removed, and they had piled up to 136 registered worktrees — roughly 130GB and 945,000 files — by the time the issue was filed.
On July 8, 2026, the user ran an emergency disk-space reclaim that called git worktree remove --force across the backlog. Several of the accumulated worktrees had node_modules directories containing NTFS junctions — created by the package manager to point back into the main tree's data directories — and git worktree remove --force followed those junctions and deleted what they pointed to, rather than deleting the junction link itself. The directory shells at the junction paths survived; their contents did not.
What makes the report unusually solid is the reporter's isolation of the exact culprit. Suspecting any recursive-delete tool might be at fault, they tested five different removal methods against the same junctioned worktree: PowerShell 7.5.8's Remove-Item, Windows PowerShell 5.1's Remove-Item, Git Bash's rm -rf, and Python's shutil.rmtree all left the junction target untouched. Only git's own worktree remove --force recursed into it and destroyed the contents — a narrower and more specific finding than earlier junction-related Claude Code reports, which had implicated the shell-level delete commands themselves (see STUPID-2026-0123) rather than git's built-in worktree removal.
The remediation that followed reclaimed nothing: each of the 136 worktrees had to be individually proven safe before it could be removed, consuming about 30% of the user's week. The issue carries the area:core label, drew no maintainer response, and was closed as not planned.
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
- Github Issue
Related incidents
Cite this record
StupidLLM. "STUPID-2026-0129: Claude Code's own `git worktree remove --force` followed NTFS junctions and destroyed their targets on an emergency disk reclaim, while shell-level Remove-Item, rm -rf and shutil.rmtree all left the same junctions untouched (GitHub #84162)." AI Agent Incident Database, 2026. https://www.stupidllm.com/incident/STUPID-2026-0129/ (accessed 2026-11-22). CC BY 4.0.
← STUPID-2026-0128By IDSTUPID-2026-0130 →
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.