12 Agents on the Same Branch: The Git Chaos Nobody Warned You About
12 Agents on the Same Branch: Git Chaos and the Fix
Running a dozen AI agents on the same git branch sounds like maximum productivity. In practice, it's maximum chaos. Here's what actually happens and how to fix it.
The File Stomping Problem
Agent A reads a file, plans its changes, and starts writing. Meanwhile, Agent B reads the same file, makes different changes, and commits. When Agent A tries to commit, the file has changed underneath it. Best case: a merge conflict. Worst case: Agent A silently overwrites Agent B's work.
With 12 agents, this isn't occasional - it's constant. Every shared configuration file, every utility module, every build file becomes a collision point.
Merge Conflicts Cascade
One conflict doesn't just block one agent. It can stall the entire pipeline. Agent C depends on Agent B's changes, which are blocked by a conflict with Agent A. Meanwhile Agents D through L are all making commits that will conflict with the eventual resolution.
The conflict resolution itself burns tokens - agents read the conflict markers, try to resolve them, sometimes make it worse, and the whole cycle repeats.
Git Worktrees as Isolation
The solution is git worktree. Each agent gets its own working directory on its own branch.
for i in $(seq 1 12); do
git worktree add ../project-agent-$i -b feature/agent-$i
done
Now each agent works in complete isolation. No file stomping, no merge conflicts during development. You merge branches when each agent's work is complete and reviewed - a much more controlled process.
The Remaining Challenge
Worktrees solve file-level conflicts but not logical conflicts. Two agents can each write valid code that's incompatible when combined. This requires careful task decomposition upfront - assign agents to non-overlapping modules and keep shared interface changes to a single agent.
Twelve agents can be productive. They just can't share a branch.
Fazm is an open source macOS AI agent. Open source on GitHub.