What Happens When Multiple AI Agents Edit the Same Repository?
One developer ran Claude Code and Codex in the same repository. Codex shipped frontend work and left unsaved edits. The other session stopped to avoid overwriting them. Since then, the developer follows two rules: start from origin/main and announce deployments beforehand.
When multiple AI agents edit the same repository, separate worktrees reduce the chance of a collision. Someone has to decide who owns the shared interface and which branch lands first. When the agents belong to different people, those decisions need a place everyone can see.

What breaks when agents share one checkout?
Uncommitted files in a shared checkout don't carry an owner. Another agent might build on a half-finished edit. A broad git add could then pull that work into the wrong commit. Git shows a dirty working tree. Sorting out which task each line belongs to is up to you.
One user reported Claude Code and Codex overwriting each other's edits within 20 minutes. Another described the same trouble with three Claude Code tabs: one session might start tests halfway through another's edit. In both reports, the sessions were writing into the same folder.
The Claude Code agent teams documentation recommends assigning teammates different files because simultaneous edits to one file lead to overwrites. We'd write down the intended paths even though a path list isn't a lock. It gives the people involved a chance to notice overlap before both agents are deep into the work.
A path list gives reviewers something concrete to challenge: does this task really need the shared authentication module, or only a caller? The answer may change the split before the work starts. It also tells the reviewer where to look when a task reaches beyond its original scope.
Paths aren't the whole boundary, though. Frontend and API tasks can live in different files. They still share the response shape. We'd name the person responsible for that contract and agree on what a correct response looks like. Otherwise, two tidy diffs can pull the interface in opposite directions. For the separate problem of agents doing the same task twice, see how to keep coding agents from duplicating work.
What does a separate worktree leave shared?
Git worktrees give parallel tasks separate working directories and indexes while sharing repository history. Claude Code can start a session in a worktree when you ask it to. The Codex app offers one for each chat, starting at a detached HEAD by default. Git normally prevents the same branch from being checked out in two worktrees at once.
Both tools document .worktreeinclude for copying selected ignored files, such as a local .env, into a new worktree. That helps with setup, but copying a configuration file doesn't create an independent database or reserve a port. Installed packages, local databases and development servers need their own setup.
One team moved its agents into separate worktrees and found file conflicts easier to manage. Then it faced a new question: could the browser test reach an API or database started for another branch? A service answering on the expected port proved that something was running, not that it matched the code under test.
The team recorded which worktree started each service, along with its process, port and database state. We like that record. A green browser test shows that a service responded. The record helps the team trace it back to a worktree. Unit tests that don't leave the worktree need less setup. For browser and integration tests, we'd check which service handled the request.
What if two changes touch different lines?
Git may combine two edits without reporting a conflict even though the resulting behavior is wrong. One developer had run Claude Code and Codex on separate branches for about eight weeks. Both branches passed CI individually. The worry was that one branch might change a function signature while the other kept calling the old one. How do you catch that before main breaks?
Researchers have measured the collisions Git does flag. In a study of agent-authored pull requests, they replayed 716 evaluable pairs of concurrently open PRs. Among 115 pairs from different agent platforms, 48 had textual conflicts (41.7%). For pairs from the same platform, the rate was 19.8%. The different-platform rate was roughly twice as high, and the study found the difference statistically significant. Such pairs made up only 0.5% of co-active pairs in the underlying dataset. The signature mismatch the developer worried about could merge cleanly and escape this count entirely.
| Git helps with | The team must decide |
|---|---|
| Separate worktrees and branch history | Who owns the shared interface |
| Conflicting edits to the same lines | Whether different edits agree on behavior |
| Recording the resulting commits | Which branch lands first and what needs testing |
A green check tells you the branch passed on its base at the time. Once another branch lands, the combined code is different. We'd test the shared behavior again on that combined version.
Who owns a fix during review?
When a reviewer spots a problem, the note should identify the commit. We'd send the fix back to the author, who already has the task context. The reviewer then has a clear before and after. If the reviewer takes over, they should tell the author so both agents don't keep editing the same lines.
Which branch should land first?
We'd follow the dependency. If one branch defines an interface the other calls, we'd land the interface first. When both tasks touch the same unsettled area, we'd rather run them in sequence than leave two agents guessing at the contract.

The reverse order can work when both sides have already agreed on compatibility. Whichever order you choose, tell the other person. If it changes, their agent may be working against a base that is about to move. The developer who reported the collision announces deployments before they happen. A similar heads-up helps before a merge shifts the shared base.
A trial merge reveals textual conflicts early. Once the interface branch lands, test the dependent branch against the version that actually landed. For an API change, test the request and the response consumed by the other branch. For a database change, run the migration and then the code that reads the updated data. The reviewer needs the commit and services that produced the result.
Agent collaboration between Claude Code and Codex has more on the handoff between the tools themselves.
How do people keep their agents on the same plan?
Your Claude sessions can use cross-session messaging to report what landed. Your teammate's Codex session is outside that conversation. That decision needs a place both people can reach.
In Alook, that decision belongs in the shared thread: who owns the response shape, which branch lands first, and which test the second branch repeats. Agents with access to the thread can read its history. Either person can mark the message and find it again under Marked in the Inbox. Our introduction explains the multi agent collaboration platform in more detail.
Before two people's agents start on the same repository, we'd settle the shared contract and put the intended merge order where both can see it. After the first branch lands, a note about what the second branch needs goes in the same place. One line about a revised response shape may save the next agent from building against yesterday's agreement.
FAQ
Should Claude Code and Codex split by feature or take turns?
Split independent work across separate worktrees. When both tasks depend on an unsettled interface or the same busy files, agree on the contract first and let the agents take turns.
Do Claude agent teams stop teammates from overwriting each other?
Not automatically. Claude's documentation recommends giving teammates different files because edits to the same file may overwrite one another.
Do coding agents need separate machines?
No. Separate worktrees on one machine isolate working files. Tests that depend on shared services or data need their own boundaries too.
Does Alook merge Git branches?
No. Alook gives people and agents a place to discuss decisions and handoffs. Git handles the merge.