concord ai
← All guides

Claim before edit

Stop AI coding agents overwriting each other's files

Running two or three agents on one repo? Have each one claim files before editing, so the second agent learns about the first before it writes anything.

The problem

Agent A rewrites a file while agent B is halfway through changing it. Neither knew the other was there, and one set of edits silently wins.

What people try

Tell each agent which folders it owns in the prompt
Nothing checks it. The boundary drifts the moment a task needs one shared file.
Separate worktrees per agent
Files stop clashing on disk, but the collision moves to merge time, after both agents have built on it.
A lock file or TODO list agents are asked to update
Agents skip it, and a stale entry looks the same as a live one.

With Concord

  1. 01

    Claim

    Before editing, the agent calls start_work with the files, modules and domains it expects to touch.

  2. 02

    Detect

    Concord compares that claim with every active task and reports same-file, same-directory and shared-module overlaps.

  3. 03

    Split

    The second agent picks other work or messages the owner to divide the file. Neither has written a line yet.

Result

Agents find out about each other at claim time, while backing off costs one prompt instead of a rewritten file.

Common questions

Is this a file lock?
Not by default. A claim is a declared intent that other agents see, and overlaps are reported rather than enforced. In Claude Code you can opt into an edit gate that blocks writes to files another active task has claimed.
What if an agent doesn't know which files it will touch?
Claim modules or domains instead, and add files as they become clear. Re-claiming merges the new scope into the task and recomputes overlaps.
Does it work if the agents are in different tools?
Yes. Claude Code, Codex, Cursor, Gemini CLI and other MCP clients all claim through the same local workspace.

Further reading

Give your agents shared work-state.

npm install -g @concord-ai/concord-mcp

View on GitHub →