Guide

File claims for coding agents

A claim is a promise: “I am changing these paths for this task.” It only works if every agent reads the promises before editing and something stops the ones that don’t. Here is how to build that, and how Chain does.

Why rules files are not enough

The usual first attempt is a line in CLAUDE.md or .cursorrules: “Do not edit files another agent is working on.” Agents follow it most of the time. On a shared repo, the remaining times are the ones you remember. A rule is advice; what you want is a check that runs before every write, whether or not the model paid attention.

Claims, not locks

A file lock in the operating-system sense is the wrong shape. Agents work in separate worktrees, so there is no single file to lock, and a lock says nothing about why it is held. A claim is a path pattern plus a task: auth/* for “Password reset flow”, held by Max’s Claude Code. Other agents can see who holds it and what for, and decide whether to wait, queue, or do something else.

Chain’s board is a list of these claims, plus tasks and a log, and it is the same list on every member’s Mac. Agents get it as tools: board to read, claim to take paths (which fails if someone holds them), release to give them back, log to write a line.

Enforce with the hook the agent already has

Every major agent can run a script before a tool call and let it veto the call. Claude Code’s PreToolUse hook runs “before a tool call executes” and can block it. Codex CLI has a PreToolUse hook too, which can deny with a permissionDecision or exit code 2. Cursor’s preToolUse fires “for all tool types” and treats exit code 2 as deny. Chain installs one hook for whichever agent you open. On every write it checks the target path against the board: if another agent holds it, or the path is outside what agents may edit, the write is refused and the agent is told who has it and why. The agent sees a clear error, not a silent overwrite.

⚠ payments/charge.ts is claimed by Sam (Fix checkout double charge) · skipped

Release, and expire

A claim that outlives its owner blocks the whole team. Two things have to be true: claims are released when the task finishes, and claims are released when the agent dies. In Chain, done runs the tests, merges if green, pushes and releases the claims in one step, and a session that stops unexpectedly has its claims released at once.

Cross-machine claims need a server, or a push

A claim stored in a local file is only visible on that machine. For a team you need shared state that every Mac reads: either a git ref that everyone pushes and fetches, or a small service. Chain uses a relay that carries only claims, tasks, log lines, branch names and merge results. Code and API keys never pass through it, and on Enterprise you can host the relay yourself.

Putting it together

Worktree for isolation, claims for intent, hook for enforcement, release on done, expiry on crash, one shared board. The parallel agents guide walks through the sequence; the CLI reference lists every board command.