STUPID-2026-0075

Claude Code's parallel-subagent worktree cleanup deleted the main .git directory and entire working tree — irrecoverable repo loss (GitHub #48927)

9.5critical
April 16, 2026VerifiedReproducible
  1. Instruction given

    Run two successive rounds of four parallel subagents, each isolated with Claude Code's `isolation: worktree` feature, to implement separate modules of a project on branch dev/mode-2.

  2. Expected behavior

    Each subagent's worktree cleanup should remove only that subagent's own isolated worktree directory, leaving the main working tree, the .git directory, and all committed history untouched.

  3. Actual behavior

    The first round of four subagents completed and committed successfully (commits 55a4fe3 through 88b6f9c). During cleanup of the second round of four worktree-isolated subagents, the cleanup mechanism operated on the main working tree instead of, or in addition to, the isolated worktree directories. A subsequent git command failed with "fatal: not a git repository (or any of the parent directories): .git" — the .git directory was gone.

  4. Damage

    Complete, irrecoverable loss of the repository's .git directory (and with it all commit history), all pre-existing source code, the docs/ and tests/ directories, README.md, and configuration files, plus the four commits produced by the first round of subagents. Only a handful of files written by the second round of subagents survived (install.sh, uninstall.sh, pyproject.toml). No remote backup existed. GitHub labeled the issue data-loss and has-repro; it was closed as not planned.

On April 16, 2026, a Claude Code user (version 2.1.109, Opus model, Ubuntu/Debian Linux, Anthropic API) filed GitHub issue #48927 describing total loss of a git repository after running two successive rounds of parallel subagents isolated with Claude Code's `isolation: worktree` feature. The first round — four subagents implementing modules M06, M02, M01 and M04 on branch `dev/mode-2` — finished after about 15 minutes and produced four successful commits (`55a4fe3` through `88b6f9c`). A second round of four subagents (M07, M03, M05, M01-deploy) was then launched; when it finished about eight minutes later, the next git command failed with `fatal: not a git repository (or any of the parent directories): .git`. The repository's `.git` directory, all pre-existing source code, `docs/`, `tests/`, `README.md`, configuration files, and the four commits from the first round were gone. Only a few files written by the second round's subagents — `install.sh`, `uninstall.sh`, `pyproject.toml` — survived. The reporter's diagnosis, backed by detailed reproduction steps, was that the worktree cleanup mechanism operated on the main working tree rather than confining itself to the isolated worktree directories — a scope/path-confusion bug in the cleanup logic rather than a single bad command. No remote backup existed, so the loss was irrecoverable. GitHub labeled the issue `data-loss` and `has repro`; it was closed as not planned.

Classification

Failure mode
Destructive Action
Root cause
Scope Misunderstanding
Domain
Other

Related incidents