Claude Code ran an unquoted rm -rf in its own helper script and deleted a repository root including .git, the user reports
While measuring a change, Claude Code wrote a bash helper with an unquoted rm -rf and called it from a loop in zsh, which deleted the whole repository root including .git. The user says the local .git was the only copy of the commit history.
On macOS, a user running Claude Code 2.1.318 in bypassPermissions mode filed a GitHub issue about a session in which Claude was measuring a change1. Claude wrote a bash helper script that rebuilt an output directory with an unquoted rm -rf $D, then called it from a loop in the Bash tool, which runs the user's login shell, zsh1.
zsh does not word-split set -- $side, so the helper received one combined argument instead of three. Inside the bash helper, the unquoted rm -rf $D split that argument and deleted the repository root, including .git1. The session was in bypass mode, so no prompt appeared. The user did not ask for any deletion1.
The user says the local .git was the only copy of the commit history and that undelete was impossible1. A second issue filed the same day by the same user reports "12+ months of git istory" lost to an incorrect harness rm -rf. It does not say whether it describes the same event2.
Claude wrote a bash helper script inside the project that rebuilt an output directory with an unquoted rm -rf.
“Claude wrote a bash helper script inside the project that rebuilt an output directory with an unquoted rm -rf”
The helper was called from a loop in the Bash tool, which on macOS runs the login shell zsh.
“which on macOS runs the login shell zsh”
The unquoted rm -rf inside the helper was split into several arguments and deleted the repository root including .git, with every local branch and commit.
“which deleted the repository root including .git”
The session was in bypassPermissions mode, so there was no prompt.
“No prompt, because the session was in bypassPermissions”
In the real incident Claude wrote both the helper and the loop itself while measuring a change, and no deletion was requested.
“In the real incident Claude wrote both the helper and the loop itself while measuring a change; no deletion was requested.”
The reporter says the local .git was the only copy of the commit history and that undelete is impossible because the SSD has TRIM.
“The local .git was the only copy of the commit history; the SSD has TRIM, so undelete is impossible.”
The reporter gives the session model as claude-opus-5-5.
“model claude-opus-5-5”
The reporter gives the Claude Code version as 2.1.318.
“2.1.318 (Claude Code)”
The reporter says the model diagnosed the cause itself in the same session.
“The model diagnosed the cause itself in the same session, so the transcript holds the full chain.”
A second issue by the same user, filed the same day, says 12+ months of git history were lost due to an incorrect harness rm -rf. The text is quoted with its typo.
“lost 12+ months of git istory due incorrect harness rm rf”
The second issue lists the platform as darwin and the version as 2.1.318.
“Version: 2.1.318”
All 11 claims with their quotes (2 not linked to a sentence above)
- Claude wrote a bash helper script inside the project that rebuilt an output directory with an unquoted rm -rf.1
“Claude wrote a bash helper script inside the project that rebuilt an output directory with an unquoted rm -rf”
- The helper was called from a loop in the Bash tool, which on macOS runs the login shell zsh.1
“which on macOS runs the login shell zsh”
- The unquoted rm -rf inside the helper was split into several arguments and deleted the repository root including .git, with every local branch and commit.1
“which deleted the repository root including .git”
- The session was in bypassPermissions mode, so there was no prompt.1
“No prompt, because the session was in bypassPermissions”
- In the real incident Claude wrote both the helper and the loop itself while measuring a change, and no deletion was requested.1
“In the real incident Claude wrote both the helper and the loop itself while measuring a change; no deletion was requested.”
- The reporter says the local .git was the only copy of the commit history and that undelete is impossible because the SSD has TRIM.1
“The local .git was the only copy of the commit history; the SSD has TRIM, so undelete is impossible.”
- The reporter gives the session model as claude-opus-5-5.1
“model claude-opus-5-5”
- The reporter gives the Claude Code version as 2.1.318.1
“2.1.318 (Claude Code)”
- The reporter says the model diagnosed the cause itself in the same session.1
“The model diagnosed the cause itself in the same session, so the transcript holds the full chain.”
- A second issue by the same user, filed the same day, says 12+ months of git history were lost due to an incorrect harness rm -rf. The text is quoted with its typo.2
“lost 12+ months of git istory due incorrect harness rm rf”
- The second issue lists the platform as darwin and the version as 2.1.318.2
“Version: 2.1.318”
Sources
- [1][BUG] Agent-written helper ran `rm -rf $D` on an unquoted path; zsh/bash word-splitting mismatch deleted the whole repo root including .git (no prompt, bypass mode)
- [2][Bug] Claude Code rm -rf deleted git history (12+ months lost)
Related incidents
- AID-2026-0112 Claude Code pointed a destructive self-test at a user's real repository through a symlink, erasing its Git history, the user reports
- AID-2026-0125 A Claude Code subagent wrote a test that ran rm -rf ~ on a user's real home directory despite worktree isolation, the user reports
- AID-2026-0148 Claude Code ran rm -rf on a Mac user's home directory while tidying an old repository, the user reports
- AID-2026-0029 Claude Code ran a recursive delete that erased a user's home directory files, the user reports
Editor notes
Both sources are first-hand GitHub issues by the same user (mishoko); nothing independent corroborates them. The issue states a session time of 2026-11-04T16:27:39Z, but the date is kept at 2026-11 because the issue does not say the deletion happened at that time. The second issue (#107274) is a terse /feedback submission and does not reference the first; whether it describes the same event is not stated. The "12+ months" figure comes only from #107274. The reporter attributes the failure partly to the model and partly to the harness; the record follows the reporter's description of Claude writing the script. The Claude Model field in the issue form is blank; the model id comes from the session details in the issue body ("claude-opus-5-5"). No response from Anthropic was visible on either page. Written directly by an agent because the Gemini writer was unavailable; quotes were checked against the cached page text.