Merge conflicts used to be a once-a-week annoyance: two people touched the same file, git couldn’t reconcile the changes automatically, and you spent ten minutes picking through <<<<<<< markers. Then AI coding agents entered the picture, each one capable of touching a dozen files in a single task, and suddenly conflicts show up daily — sometimes several times an hour if you’re running more than one agent against the same codebase.
The instinct is to blame the agents for writing sloppy code. That’s usually not it. Merge conflicts multiply with AI coding agents because agents work fast and broad, touching more files per task than a human typically would in the same span of time, which means the odds of two independent tasks overlapping on the same lines go up sharply. This post covers why that happens and the workflow changes that bring conflict rates back down.
Why Agents Produce More Conflicts Than Humans
A human working on a bug fix tends to touch the files directly involved and stop there. An agent asked to do the same fix will often also update a related test, adjust a type definition, tidy an import, and touch a changelog — genuinely helpful, but it multiplies the surface area of the diff. When two agents are running concurrently against the same repository, the probability that their two “helpful but broad” diffs overlap on the same file, sometimes the same lines, rises fast.
The other factor is speed. A human PR might take a day between “I started” and “I opened the PR,” giving natural time for a teammate’s overlapping change to land and get noticed. An agent can go from prompt to finished diff in minutes, so several agents can produce conflicting changes before anyone has a chance to see the overlap coming.
The Real Fix: Don’t Let Agents Share a Working Directory
Most merge conflict advice focuses on resolving conflicts well — smaller commits, rebasing often, clear commit messages. All of that still helps, but it treats the symptom. The actual fix for agent-driven conflicts is upstream of any of that: give each agent an isolated git worktree and branch so their in-progress edits never touch the same working directory in the first place.
# Two agents, two isolated worktrees, two branches
git worktree add ../repo-agent-a -b agent/refactor-api
git worktree add ../repo-agent-b -b agent/add-logging
# Each agent works entirely inside its own folder
cd ../repo-agent-a && claude # agent A never sees agent B's files
cd ../repo-agent-b && claude # and vice versa
This doesn’t eliminate merge conflicts entirely — two branches can still touch the same lines of the same file when it’s time to merge — but it eliminates the far more dangerous failure mode of two agents silently overwriting each other’s uncommitted work before either one even reaches a commit. A real merge conflict, at least, git shows you plainly; a silent overwrite in a shared working directory doesn’t announce itself at all.
Conflicts That Still Happen, and How to Handle Them
Even with full worktree isolation, conflicts happen at merge time whenever two branches genuinely edited the same lines. The difference is that now you’re resolving a normal, visible git conflict instead of untangling a corrupted working directory.
| Conflict type | Cause | Fix |
|---|---|---|
| Same file, different lines | Two agents added unrelated code nearby | Usually auto-merges; verify with a quick diff read |
| Same file, same lines | Two agents solved overlapping problems | Manual resolution — read both intents, decide which wins |
| Deleted vs. modified | One agent removed a file another agent edited | Decide if the file should still exist; rarely auto-resolvable |
| Renamed vs. modified | One agent renamed a file another agent edited by old path | Git usually detects the rename; verify the edit carried over |
A useful habit: merge the smaller, more contained branch first. It reduces the surface area the second merge has to reconcile against, and it means any conflict resolution happens against a smaller diff rather than two large ones at once.
Reviewing Before You Merge, Not After
The other lever worth pulling is reviewing each agent’s diff before merging, not after a conflict forces your hand. This is a habit worth building into the prompts you give coding agents — asking them to keep changes scoped to what was requested makes conflicts less likely in the first place, and a quick diff scan before merge catches an agent that quietly touched more than it needed to.
Designing Tasks to Avoid Overlap in the First Place
The cheapest conflict is the one that never gets created, which means the task breakdown you hand to each agent matters as much as the isolation around it. Before kicking off two agents at once, it’s worth a quick check: do these two tasks plausibly touch the same files? If a refactor and a feature addition both need to modify the same core module, running them in parallel guarantees a conflict at merge time no matter how well-isolated the working directories are.
A few ways to reduce overlap by design:
- Split by directory or module, not just by feature description, when you can — two agents working in genuinely separate parts of the codebase can’t conflict even on the same lines.
- Sequence dependent tasks rather than parallelizing them; if task B needs task A’s output, running them at the same time only guarantees a conflict, not a time savings.
- Keep shared files (config, shared types, core utilities) as single-owner tasks — assign changes to those files to one agent at a time rather than letting multiple sessions touch them independently.
This kind of task design pairs naturally with the prompting habits that keep each agent’s diff scoped to what was actually asked — tight scope and non-overlapping tasks are two sides of the same conflict-prevention coin.
Getting Started
- Audit whether your current agent workflow gives each task its own worktree and branch, or whether agents share a single checkout — the latter is the real source of most “conflicts.”
- Start giving every agent task its own
git worktree addbefore you begin, even for small ones; the habit costs seconds and saves cleanup time later. - Review each branch’s diff before merging rather than after a conflict appears, so you catch overlapping changes early.
- To skip the manual worktree bookkeeping entirely, download Agents — every session runs in its own isolated worktree and branch automatically, with a right-side diff panel so you can review and merge cleanly. The app is a 7-day free trial, then a one-time $9.99 with no subscription.
Merge conflicts aren’t going away as long as more than one person — or agent — touches the same repository, but the version of them worth worrying about should be the visible kind git shows you, not the silent kind caused by two processes sharing a folder they shouldn’t. See the Wikipedia entry on merge conflicts for the underlying mechanics, and the Agents product page for how branch-per-task isolation looks in practice.