agent-coherence (Claude Code plugin)

Coherence for the prose subset of project rules that can't be expressed as policy.
CLAUDE.md is your project's prose contract — what to track, what to escalate, what to never touch. Most of those rules can't be expressed as permissions.deny or .claude/settings.json because they're about state, not tools: "this spec is now v3, your branch is editing v1", "the planner reorganized the auth section while you weren't looking", "session B just committed a change to the file you're about to write." agent-coherence is the runtime layer that makes those state changes visible across parallel Claude Code sessions sharing the same workspace.
Philosophy
Worktrees prevent file collisions, not stale-spec collisions. Two parallel Claude Code sessions can both read plan.md at v1, work independently in their per-session worktrees, and produce pull requests that reflect incompatible interpretations of v1 — even though the planner published v2 hours ago. The git surface stays clean; the model's understanding goes stale silently.
agent-coherence exists because that failure shape is structural — CLAUDE.md tool restrictions don't propagate to subagents, context compaction weakens rule adherence, and multi-session coordination has no platform-level synchronization primitive. Anthropic has confirmed this twice on the record: the official position is that hooks are the deterministic-behavior seam, and CLAUDE.md / .claudeignore are guidance, not constraints. This plugin lives in that seam.
The design bias: surface stale state to the agent itself via additionalContext, let the agent decide. The agent reads the warning alongside the file and almost always re-reads before acting. A 2026-05-18 pre-launch evaluation measured 100% re-read-or-acknowledged rate across N=80 trials, zero ignored.
What it does
Watches tracked artifacts (CLAUDE.md, AGENTS.md, DECISIONS.md on the Node backend, docs/specs/, docs/plans/, docs/brainstorms/, plan.md / task.md / spec.md) across:
- Agent View ✓
- Multi-terminal (multiple
claude processes in the same workspace) ✓
- Task-tool subagents (each subagent is a first-class coherence peer via a composite
(session_id, agent_id) identity — sibling subagents editing the same artifact collide, and a subagent's write is attributed to the subagent, not the parent; see Subagents and composite identity) ✓
Verified against claude v2.1.131 (2026-05-17). The claude agents subcommand on v2.1.131 is a management UI, not a session spawner — out of coverage scope.
When a session reads an artifact that changed since it last read it (usually because another session committed an edit), the plugin injects a warning into the agent's own context via additionalContext. A Read gets the stale-read line. A Bash command that reads the file, or a Grep whose search covers it, gets a similar warning that lists the stale paths. An Edit or Write gets no stale-read line. In warn mode it goes through, with a concurrent-edit warning only while another session is still in the turn in which it edited the same file. In strict mode it is denied. The stale-read line looks like this:
⚠ Stale read [warning emitted 2026-05-23T13:42:19.114000+00:00]: docs/plans/feature-x.md was updated by agent 90b1dfd3 at 2026-05-23T13:42:18.402000+00:00. Current version is v2; you previously saw v1. … Consider re-reading docs/plans/feature-x.md before acting on stale assumptions.
On the Python backend with agent-coherence 0.14.1 or earlier, the line reads was updated by session instead of was updated by agent.