Two AI coding agents, one file: detecting overlapping edits with exit code 3
aisync is a local hub for Multi-Agent Context Management, Coordination & Observability. This post covers the coordination part: how two coding agents on one machine find out they are about to edit the same file.
aisync is a local hub for Multi-Agent Context Management, Coordination & Observability. This post covers the coordination part: how two coding agents on one machine find out they are about to edit the same file.
The problem
Run Claude Code and Codex in the same repository and nothing stops both from rewriting app/payments/refunds.py. Each tool only sees its own session, so the clash shows up later as a confusing merge or a silently overwritten fix.
What aisync does about it
An agent declares a claim on the files it is about to touch. If another agent already holds a claim on those files, the CLI refuses with exit code 3, so a script or a hook can stop instead of editing.
I ran this in a throwaway virtualenv with AISYNC_HOME pointing at a temp directory, so it did not touch my real hub (aisync 0.2.9):
pip install aisync-cli
aisync init
aisync claim -a claude-code -p api -f app/payments/refunds.py -m "refund fix"
# claimed api [app/payments/refunds.py] for claude-code until 05:28 (exit 0)
aisync claim -a codex -p api -f app/payments/refunds.py -m "sdk upgrade"
# OVERLAP: claude-code is working on api [app/payments/refunds.py] until 05:28: refund fix
# stop and coordinate with claude-code, or pick other files (exit 3). Your claim is noted, so claude-code can see you are waiting. (exit 3)
aisync release -a claude-code -p api
# released 1 claim(s)
aisync claim -a codex -p api -f app/payments/refunds.py -m "sdk upgrade"
# claimed api [app/payments/refunds.py] for codex until 05:28 (exit 0)
aisync verify
# journal chain intact (exit 0)
Three details from that run. The refused claim is still recorded, so the first agent can see someone is waiting. aisync claims lists both. And claims carry an expiry: the output above says until 05:28 for a claim made around 03:28, so about two hours.
The observability half
Every claim, release and other agent event goes into a journal in the hub, which is a plain git repo. Each event stores the id of the one before it, so aisync verify can detect an edited or removed entry.
Limits
- Claims are cooperative. They are not operating-system locks: an agent that never calls
aisync claimcan still edit the file. - Hash-chain verification detects changes to recorded events. It does not prove that every action an agent claimed actually happened.
- Native hooks exist for Claude Code, Codex and Cursor. Other agents need to call the CLI or the MCP server themselves, and instruction files alone give standing rules but no claim enforcement.
It needs Python 3.11+ on macOS or Linux, and has no runtime dependencies. MIT licensed.
Earlier post: https://dev.to/maxont/aisync-one-local-hub-for-rules-and-coordination-across-ai-coding-agents-4egp
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.