Back to all work

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 install from GitHub, zero runtime dependencies
Agent AAgent BgetUserFromSession()
Agent A deletes a function Agent B still calls. Interlock catches it before either lands.

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 grep finding 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.

ClassFires whenEffect
INTERFACE_BREAKYou remove or change a symbol another live agent's files reference or declared as a dependencyBlocks, objection raised for you
FILE_OVERLAPAnother live agent claims the same path in the same worktreeBlocks
ADD_COLLISIONTwo agents add the same symbol or create the same new fileBlocks
GOD_SYMBOLA removal touches more than 200 referencesEscalates to a human
GOAL_OVERLAPSame files, neither side changing an interfaceWarns, never blocks

Hard decisions

The calls that shaped it.

  • Gate Bash, not just Edit

    An Edit-only matcher misses sed -i and cat > file, so the hook also scans shell commands. The scanner is regex and still misses writes inside scripts or python -c. That gap is written down as a limitation, not hidden.

  • Grep, not an AST

    References come from git grep with 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 SessionEnd check 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.