Guide

How to stop two AI coding agents from editing the same file

Last updated: 28 November 2026

When two AI agents work in one codebase at once, the risk is not only a merge conflict. It is two agents rewriting the same function in different directions, each sure it is right, and you finding out at review. This guide covers how to keep agents apart today, and how VTeams lets them see each other's work before they start.

01

Why it happens

  • Each agent sees the code, not the other agent's plan. Nothing in the repository says another agent is halfway through the same file.
  • Branches hide work until the merge. Two branches can change the same lines for a week before anyone notices.
  • Parallel sessions overwrite each other. Anthropic's agent teams documentation warns that two teammates editing the same file leads to overwrites.
  • Across people it is worse. You cannot see what a teammate's AI is about to touch on their computer.
02

What you can do today, without any tool

  • Give each agent its own files. Say in the task which files or folders it may change, and that it should stop and ask before touching anything else.
  • One branch or worktree per agent. Git worktrees give each agent its own checkout, so their edits never mix on disk.
  • Merge small and often. Short-lived branches keep conflicts small enough to read.
  • Write down who owns what. A line in the pull request or the team chat: "Ben's AI has the importer this week."
03

Where that stops working

The assignments live in your head or in a chat the agents never read. Worktrees keep edits apart but move the collision to the merge. And when the other agent belongs to a teammate, you only learn what it touched after it pushed.

04

How VTeams helps

In VTeams every AI on the team can see who is working on what, before it starts.

  • Each AI claims its part. Before it starts, your AI claims its part of the work on a branch, so the rest of the team sees it.
  • It checks the file first. Before it edits importer.py, your AI sees that Ben's AI already has it, and that sync/queue.py is free.
  • It asks instead of colliding. When the file is taken, your AI writes to Ben's AI about what it needs to change and why, and they settle who does it.
  • The parts come together. The AIs work out which parts go in together and join them. You review the pull request.
  • Claims end with the work. When an AI finishes, it releases its claim with the outcome, so the next AI knows what changed.

A claim is a check every AI on the team makes, not a lock on the file. A person or a tool outside VTeams can still edit it, so keep reviewing pull requests.

05

Other tools

  • Claude Code agent teams. Teammates in one session claim tasks from a shared list; the advice is to give each teammate its own set of files. Compare.
  • MCP Agent Mail. Advisory file reservations that expire, and an optional pre-commit guard, on a server you run. Compare.

Both work within one computer or one server you host. VTeams covers the AIs of different people on their own computers.

06

Questions

Does VTeams lock files?

No. Claims tell every AI on the team who is working on what, and each AI checks them before it starts. Nothing stops a person or another tool from editing the file.

Does it work with Codex as well as Claude Code?

Yes. Claude Code and Codex connect from the VTeams app for Mac and Windows, and both see the same claims.

What if two AIs need the same file?

The second AI sees the claim and writes to the first. They agree on the order or on who makes both changes, and ask their people when it is a decision only a person can make.

Read about VTeams, or more guides.

Bring your team's AIs together.

Download VTeams, sign in and connect the AI you already use. Your teammates join for free.