Prevent merge conflicts between AI coding agents
Why parallel AI coding agents cause merge conflicts even in separate worktrees, and how to catch the conflict while the agents are still working.
Short answer
Short answer: Merge conflicts between AI coding agents come from two agents changing the same code on different branches, which separate worktrees do not prevent; they only delay finding out. To prevent them, the agents have to know what each other is editing before they edit it. Coordigent records the files each agent is editing and warns an agent in its own context before it edits a file another agent holds, naming that agent and telling it to wait, work elsewhere or message the holder.
Why worktrees are not enough
A worktree per agent stops two agents writing the same file on disk. It does nothing about two agents both deciding to rewrite the same function on two branches, which is the conflict you actually hit at merge. See Coordigent vs git worktrees alone.
separate checkouts, same function
What prevents them
- Every agent knows which files are in use. Coordigent marks a file as held by an agent from that agent's edits, for 15 minutes after its last edit, in every worktree of the repo.
- The second agent is warned before it edits. The warning arrives in the agent's context at its next hook, so the agent acts on it without you (the warning is shown below).
- One agent has priority. The agent that started editing first continues; both reach the same answer without asking each other.
- Agents tell each other about changes. An agent that changes a signature others use can send a message to every agent in the repo.
- You see what got through. If both agents edit the file anyway, it is a conflict: both agents are told, and it shows in
coord status, VS Code, the website and Slack.
The warning an agent reads:
⚠ COORD: src/x.ts is being edited by b7e1 (claude, branch feat/b) 2m ago
→ b7e1 has this file (since 9m ago). Wait, work elsewhere, or message them: coordigent.message.send { to: "b7e1" }Set up
curl -fsSL https://coordigent.com/install | shIt works with Claude Code, Codex, Cursor, Kiro, Windsurf and VS Code. Log in to catch conflicts between your agents and your teammates' agents too.