Writing · 2026-09-27
Coding agents without locks
How I run coding agents from three vendors on the same code at the same time, and what broke before it worked.
I run Claude Code, Codex, and Grok as engineers on the same repositories. Eleven seats in all: seven Claude, three GPT, one Grok, spread across five machines, plus the agent that lives inside the personal assistant they help build. They edit the same files, often on the same day, sometimes in the same hour.
Why not just take turns
Because the whole point is throughput. One agent building the weather viewer while another rewrites a book chapter while a third audits the orbit pipeline is what makes a seven-person volunteer group look like a company. Serializing them throws that away. And locks have a specific failure: an agent waiting on a lock held by an agent that crashed, or that is thinking for twenty minutes, is the most expensive idle there is.
The check
The tool is called filesafe and it does three things.
After you read a file, you note it: filesafe note <path>. That records the file's hash against your agent identity.
Before you write, you check it: filesafe check <path>. Exit 0 means nobody has changed it since you noted it; write. Exit 3 means it changed under you. Re-read, re-apply your change to the new content, and check again.
If you want to know who touched it, filesafe who <path>.
Claude Code runs the check from a pre-write hook, so it can't forget. Codex and the other agents are told, in the shared README, that they have to call it themselves. That asymmetry is the price of vendors having different hook systems, and it's written down so nobody assumes the other agent is protected.
There is no lock. Two agents can both note a file, both edit it, and the second one to write gets exit 3 and merges. The common case, two agents on different files, costs nothing.
The claim
There is one thing that behaves like a lock, and it's deliberately narrow. The mutation claim guards Docker operations, config writes, and restarts, because two agents restarting the same container is not something a hash check can save you from. It has never guarded file edits. The etiquette: prepare everything unclaimed, claim last, keep it to minutes, release immediately. If you don't need it, don't take it.
The two failures
Rules like this fail silently, so I went looking.
The first: a script printed filesafe's status as information and then wrote the file anyway. The check ran, said exit 3, and nothing gated on it. The fix was to make the write conditional on the exit code, and to write the trap up in the shared notes that agents search.
The second: agent identity, when the identity variable wasn't set, fell back to the process ID. Every shell was a new agent. Every check was against a note nobody had made, so every check returned exit 0 and every write looked safe. The evidence was 5,242 orphan identity slots. The fix was to require a stable identity per seat and to fail loudly without one.
Both are in the record as traps with their reintroduction vectors, in a file agents are told to grep before they touch anything nearby.
What makes it hold
Three other things carry the load with the check.
A shared memory. Every seat syncs one operator-memory repository hourly. A new agent reads three files and a router and knows what's live, what's open, and which document owns the task. Decisions have numbers and a "why."
Dated reports. Every change gets one: what was done, what was measured, what's open. Two hundred and thirty-five since August. When two agents' work collides in a way the check can't see, the reports are how you find out.
Cost routing. The expensive model plans and consolidates; cheaper models build in parallel. This matters for concurrency because parallel is only cheap if the parallel agents are.
Would I do it this way on a team of people
I did, at the Joint Typhoon Warning Center, with Sailors instead of models: a shared standard, code review, a written record, and nobody waiting on anybody. Agents just made the rules cheaper to enforce. The part that interests me is how much a few careful people can now keep moving at once.