Interlock
A coordination layer for several AI coding agents working on one repo. Agents declare what they intend to change, and it blocks interface-level conflicts before either one lands them.
- Year
- 2026
- Role
- Solo. Design, build, release
- Stack
- Python, Claude Code hooks, git, pytest
- Ships as
pip installfrom GitHub, zero runtime dependencies
The problem
Parallel agents break each other in ways a file lock can't see.
Agent A removes getUserFromSession. Agent B is building on it. Both sessions report success, and nothing looks wrong until the repo stops building.
The removal and the dependency live in different files, so nothing overlaps and a lock table stays quiet. The conflict has to be caught at the interface, while both agents are still running.
What I built
Hooks as the gate, git grep as the detector, agents as the negotiators.
interlock init writes four hooks into .claude/settings.json, so every agent on the repo is coordinated with no per-session setup. Each agent declares a goal, the files it will touch and the symbols it will remove, change, add or depend on.
A blocking PreToolUse hook checks every write against the other live declarations. When a conflict fires, Interlock raises the first objection on behalf of the agent that would break, and the two settle it with objection, offer, accept or refuse. A human is asked only on deadlock or a repo-wide change.
- stateThe only module that touches disk. Every write goes through
flock, and state lives in the git common dir so all worktrees share it. - detectFile, interface, add-collision and goal-overlap rules, with
git grepfinding who references what. - hooksParses hook payloads, scans Bash commands for write shapes and runs the gate.
- negotiateThe four verbs, plus timers for absent agents, silence and a two-round cap before escalation.
Five kinds of conflict
A conflict needs contention: another live agent standing in the same place. Updating 40 unclaimed call sites is ordinary work.
| Class | Fires when | Effect |
|---|---|---|
INTERFACE_BREAK | You remove or change a symbol another live agent's files reference or declared as a dependency | Blocks, objection raised for you |
FILE_OVERLAP | Another live agent claims the same path in the same worktree | Blocks |
ADD_COLLISION | Two agents add the same symbol or create the same new file | Blocks |
GOD_SYMBOL | A removal touches more than 200 references | Escalates to a human |
GOAL_OVERLAP | Same files, neither side changing an interface | Warns, never blocks |
Hard decisions
The calls that shaped it.
Gate Bash, not just Edit
An
Edit-only matcher missessed -iandcat > file, so the hook also scans shell commands. The scanner is regex and still misses writes inside scripts orpython -c. That gap is written down as a limitation, not hidden.Grep, not an AST
References come from
git grepwith word boundaries. It is noisy alone, so a hit only counts when it meets another live agent's declaration. Tree-sitter stays on the roadmap until the noise proves real.Raise the first objection itself
In early live runs agents exchanged zero messages: a block that listed options read as permission to stop and ask a human. Now the block gives one imperative next step and Interlock files the objection, so a negotiation never waits on both agents acting.
Publish where it fails
The README lists failures from real multi-agent runs. The worst: a blocked agent said it would resume, exited, and left the repo broken, so the block caused the breakage it exists to prevent. It is mitigated with a
SessionEndcheck for unfinished removals, and the full fix is on the roadmap.
Where it is now
A tested CLI, designed and built in one day and checked against live agent runs.
- 148 testspytest, CI on Python 3.9 to 3.13
- Zero runtime dependencies
gitis the only external binary - Install
pip install git+https://github.com/mithun0524/interlock. Not on PyPI yet - 31 commitsApache-2.0 licensed