← ClaudeAtlas

concurrent-subagents-share-one-checkout-and-contend-on-headlisted

Two or more subagents dispatched at the same repository by absolute path run in ONE working directory and contend on HEAD, so one agent's commit lands on another's branch and a rebase retargets a branch its author does not own. Use when: (1) about to dispatch more than one agent that will run git in the same repo, whether or not their FILES overlap; (2) a pre-launch check concluded "no collision" on the basis of file-overlap or different-repos reasoning; (3) `git log` on your branch shows a commit you did not author, or `git status -sb` reports ahead/behind counts that make no sense for a branch you just pushed; (4) an agent reports it rebased or committed and the result appears on someone else's ref; (5) `git branch -a --contains <sha>` returns only a branch belonging to different work. File-overlap analysis cannot see this class: the contention is on HEAD and the index, not on paths. The fix is worktree isolation at dispatch, not coordination after the fact.
MrBinnacle/skills · ★ 0 · AI & Automation · score 62
Install: claude install-skill MrBinnacle/skills
# Concurrent subagents share one checkout and contend on HEAD ## Problem You dispatch two agents to do independent work in the same repository. You check for collisions by asking whether they touch the same files. They do not, so you launch both and tell the user they cannot collide. They collide anyway. A working directory has exactly one HEAD, one index, and one set of refs. Two agents running `git checkout`, `git commit` and `git rebase` in that directory are writing to shared mutable state that no file manifest describes. Observed failure, S308: agent A created its branch and wrote a file. Before it committed, the parent session ran `git checkout main` then `git checkout -b` in the same directory. Agent A's commit landed on the **parent's** new branch. Agent A then ran `git rebase origin/main`, believing it was on its own branch, and rebased a branch it did not own. Both pieces of work survived, but for a while one agent's commit existed only inside a branch belonging to unrelated work, and the parent pushed it there. ## Context / Trigger conditions - More than one agent will run git in the same repository, concurrently. - A dispatch names a repository by absolute path with no isolation set. - You reasoned about collision risk in terms of files, directories, or "different repos" and concluded the agents are independent. - `git status -sb` reports ahead/behind numbers inconsistent with what you just pushed. - `git log --oneline origin/main..<your-branch>` lists a