How lockwire wires into Claude Code, Codex, other agents via skills, and MCP.
/plugin install lockwire@lockwire installs three things at once, declared in .claude-plugin/plugin.json:
hooks/hooks.json— aPreToolUseandPostToolUsehook, both matchingEdit|Write, each runningnode ${CLAUDE_PLUGIN_ROOT}/dist/cli.js hook claude-pre|claude-post, and aSessionStarthook (claude-session) that says when the plugin is older than the lockwire that stamped the lockfile.mcp.json— thelockwireMCP server, run the same wayskills/lockwire/SKILL.md— usage guidance loaded when the agent is working with docs
Updates. The manifest sets no version, so Claude Code versions the plugin by the commit it was installed from, and every push to main is an update; a pinned version would keep every user on the copy they first installed. Updating needs claude plugin update lockwire@lockwire, or auto-update turned on for the marketplace (off by default for third-party marketplaces), which then shows Plugin updated: lockwire · Run /reload-plugins to apply. The README has the .claude/settings.json that turns it on for everyone on a repository.
The plugin and the lockwire from npm are separate installs that update separately, so one can be older than the lockwire that last wrote lockwire.lock. An older lockwire would misread what a newer one stamped, reporting drift that isn't there or, on re-linking, downgrading the anchor. So each anchor records what it takes to read it (its fingerprint version, and a level once a change needs one), and a lockwire that can't read an anchor leaves it as written and says to update:
- Claude Code — the
SessionStarthook adds a line to the session's context, so Claude tells you and suggestsclaude plugin update lockwire@lockwirethen/reload-plugins. - Any MCP client — the same line comes back in the server's
initializeinstructions. - The CLI — a
warning:on stderr (stdout,--jsonand--formatstay parseable) namingnpm install -g lockwire@latest.
check skips those anchors (they aren't counted, and can't fail the run), and link, ack and repoint refuse them until lockwire is updated. This is a check against the lockfile, not against npm: lockwire makes no network calls, so it never asks what the latest version is.
PreToolUse (before an Edit or Write lands): normalizes the touched file's path, looks up every anchor targeting it, and — if any exist — injects them as additionalContext:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"additionalContext": "lockwire: documentation makes claims about this code:\n- CLAUDE.md asserts \"`createSession` takes a `UserId` and returns a `Session` valid for 24 hours.\" about src/auth/session.ts#createSession [tiers: sig]\nIf this edit changes what any of these claims assert, update the doc and run `lockwire link <doc>`."
}
}If other docs make claims about the file that nobody has linked — a marker with no anchor behind it, so nothing is checking it — the same context also lists them, with their sentences, so the agent doesn't break an unprotected claim unknowingly:
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"additionalContext": "lockwire: these docs also make claims about this code that nobody has linked, so nothing is checking them:\n- NOTES.md:3 asserts \"`createSession` is only ever called with a valid `UserId`.\" about src/auth/session.ts#createSession (not linked yet)\nTreat them as real claims. Run `lockwire link NOTES.md` so lockwire checks them."
}
}These are advisory in every mode: only anchored claims can be acknowledged, so only they can make ask or deny prompt or block. Finding them used to mean walking the tree and reading every doc on each edit. The hook now keeps a doc index in .lockwire/cache/doc-index.json (git-ignored; init writes .lockwire/.gitignore). Each edit validates it with a stat of every recorded directory and doc — no walk, no reads — and re-lists or re-reads only what moved: in a repo of 20,600 files and 600 docs that is about 5 ms, and the hook costs the same as with the scan off. The scan keeps a 750 ms budget as a backstop; if a cold build in a huge repo runs out of it, the hook shows the anchored claims alone, notes it in .lockwire/hook.log, and lockwire index builds the index once without a budget. Turn the whole thing off with hook.unlinkedClaims: false.
The index fails towards re-reading. Entries modified within 2 s of the index being written are re-checked every time; a changed docs/exclude config, a corrupt file or an index older than a day is rebuilt from scratch; a build that ran out of budget is never saved. The one thing it can't see is a doc whose content changes while its size and modification time stay exactly the same (a deliberate touch -r-style restore), the same limit make and git's own index have — lockwire index --rebuild fixes it, and so does the daily rebuild. lockwire_claims_for uses an existing on-disk index if there is one, and otherwise builds its own — in memory, for the life of the server: the first call reads the docs, every later call only re-validates (about 3 ms in the 20,600-file repo, against about 35 ms for a fresh scan), and a doc added, edited or deleted while the server runs is picked up by the very next call. It never writes the on-disk index, which is why the tool can stay annotated read-only.
PostToolUse (after the edit lands): re-fingerprints the touched file, diffs against the stored anchors, and — if any bound tier moved — reports it:
{
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": "lockwire: this edit drifted documentation claims:\n- CLAUDE.md on src/auth/session.ts#createSession is now drifted (sig)\nUpdate the doc and run `lockwire link <doc>`, or `lockwire ack`/`lockwire waive` if this is expected."
}
}If the edit was to a doc that has markers no anchor backs, PostToolUse also says so ("…has markers that no anchor backs, so those claims are not being checked") and tells the agent to run lockwire link <doc>. No anchors touch the file → both hooks emit nothing and exit 0. This is the common case; the hook is silent almost all the time.
Set in .lockwire/config.json's hook.mode:
| Mode | PreToolUse behavior |
|---|---|
advisory (default) |
Injects context only. Never blocks, never prompts. |
ask |
Injects context and sets permissionDecision: "ask" — Claude Code prompts the user to confirm. |
deny |
Injects context and sets permissionDecision: "deny" — blocks until the claim is acknowledged. |
Start with advisory. A tool that blocks on day one gets uninstalled on day one; deny is for a team that has already lived with advisory and wants a stricter gate for a specific repo.
The hooks run in every repo you edit, so they only do anything in a repo that has opted in: it has a lockwire.lock or a .lockwire/config.json. Anywhere else the hooks — PreToolUse and PostToolUse, Claude Code and Codex — print nothing, don't scan the docs, build an index or log errors, and create no files: no .lockwire/ directory, nothing in git status.
Every hook handler is wrapped in a try/catch. Any exception — a malformed lockfile, an unparseable file, a permissions error — is written to .lockwire/hook.log and the hook exits 0 with no output. A broken hook can never break a tool call. This is tested behavior, not a hope: test/hook-failopen.test.ts runs all four adapters against a corrupt lockfile, a merge-conflicted lockfile, a corrupt config.json and malformed stdin, and asserts exit 0, no output, and the error in hook.log. The mechanism is src/hook-common.ts's logHookError and both adapters' outer try/catch.
Same two events, via lockwire hook codex-pre|codex-post, wired into ~/.codex/hooks.json or config.toml:
{
"hooks": {
"PreToolUse": [{ "matcher": "apply_patch", "hooks": [{ "type": "command", "command": "node", "args": ["<path-to-lockwire>/dist/cli.js", "hook", "codex-pre"] }] }],
"PostToolUse": [{ "matcher": "apply_patch", "hooks": [{ "type": "command", "command": "node", "args": ["<path-to-lockwire>/dist/cli.js", "hook", "codex-post"] }] }]
}
}Codex delivers file edits as apply_patch calls with the patch body in tool_input.command; the adapter extracts the touched file path from the patch header and doesn't need to understand the patch body itself.
A verified caveat, stated plainly. apply_patch hook emission was broken in Codex before 0.123.0 (fixed 2026-04-23) — if you're on an older Codex, upgrade. Separately, deny enforcement has had scattered, version- and platform-dependent gaps that are still being reported as of September 2026 (openai/codex#27833, open). This is why lockwire defaults to advisory everywhere: advisory mode only needs a hook to fire, which is solid on any current Codex. If you set hook.mode: "deny" on Codex, treat it as best-effort until that issue closes — ask degrades to advisory automatically, since Codex hooks can deny a call but can't rewrite its input to prompt the way Claude Code does.
Any agent that reads npx skills add-style skills (Cursor, Gemini CLI, OpenCode, Windsurf, and others) picks up the root SKILL.md, which teaches the agent to run lockwire check/lockwire refs/lockwire link directly rather than relying on a write-time hook. Wiring an actual PreToolUse-equivalent hook for a specific agent is that agent's own hook configuration format — point it at lockwire hook claude-pre (the payload shape is the more common one) or write a thin adapter; the core logic in src/hook-common.ts is agent-agnostic and the two existing adapters are ~30 lines each.
lockwire mcp starts a stdio MCP server exposing:
| Tool | Arguments | Purpose |
|---|---|---|
lockwire_claims_for |
path, symbol? |
What does documentation assert about this code? Call before editing. Returns { anchors, unlinked }: the claims lockwire is checking, and claims written in a doc about this code that nobody has linked yet (with their sentence), which nothing is checking. |
lockwire_refs |
path, symbol? |
Reverse lookup — which anchors reference this code. Anchors only; for unlinked claims too, use lockwire_claims_for. |
lockwire_status |
scope? |
Current status of every anchor, optionally glob-filtered. |
lockwire_verify |
doc |
Check one document before committing it: returns { anchors, unlinked } — its anchors' statuses, and any markers in it that no anchor backs. |
lockwire_history |
ref |
Ledger timeline for an anchor id, a path#symbol, or a doc — the query nothing else in this space has. |
lockwire_link |
doc, reviewed? |
Scan a doc for markers and stamp fresh fingerprints. |
lockwire_ack |
anchor, resolution, note? |
Record that drift was handled. |
lockwire_waive |
anchor, reason, expires |
Time-boxed, logged, expiring waiver. |
lockwire_tasks |
paths?, changed? |
The work queue: every claim that needs attention, as a task saying what is wrong and what to do. Read-only. |
lockwire_task_context |
id |
One task in full: the whole claim, the bound code or value as stamped and as it is now, and the claim's history. Read-only. |
lockwire_resolve |
id, note? |
After editing the doc, re-stamp that one claim — checked first, refused (with the reason) if it still doesn't hold. |
lockwire_repoint |
anchors?, to?, dryRun? |
After moving code to another file: point each claim whose symbol moved there unchanged at its new path#symbol and rewrite its marker. to (with one anchor) picks the new home when the code is in several places. A bound tier that differs there stays drifted. |
The server also offers a fix-docs prompt (optional scope) that walks an agent through the loop below.
lockwire has no model of its own and never writes a sentence. It tells the agent you already run — Claude Code, Codex, Cursor, anything that speaks MCP — exactly which claims are wrong, gives it what it needs to fix each one, and checks the fix. The loop:
-
lockwire_taskslists what needs attention. Each task has anid, akind, the doc and the claim's line, a one-linesummary, andresolutionsin order of preference:Kind Meaning code-changedThe bound code changed in a tier the claim depends on. value-wrongA number (or string) in the sentence no longer matches the value it's bound to. value-changedA bound value moved and the sentence states nothing lockwire can compare it with. claim-editedSomeone reworded the claim; the code didn't move. target-missingThe bound symbol, key or file is gone (or outside the repository). When its code moved unchanged to another file, the summary says where and the first resolution is lockwire_repoint.marker-removedThe marker was deleted from the doc. unlinkedA marker nobody has linked: nothing is checking the claim under it. Its id is unlinked:<doc>:<marker line>:<key>, where the key is a hash of the marker's target and claim — so the id still finds the marker after lines above it move, and never lands on a different marker that has taken its line. -
lockwire_task_contextreturns the whole claim sentence and the target as stamped and now: the declaration of the bound function or class, or the value. The stamped side comes from git — the first commit at or after the one recorded when the claim was stamped where the code fingerprints exactly as stamped (claims are usually stamped before the change is committed). If no commit has it exactly, you get the closest one withexact: falseand a note saying so. -
The agent edits the doc. It changes the sentence, the number, or the marker's target — never the code or data to match a doc.
-
lockwire_resolvere-stamps that one claim and nothing else in the doc, then re-checks it from scratch. A value claim whose number still disagrees is refused with the reason ("the claim states 14.0ms but results/bench.json#latency.p50 is 15.1"), as is a marker whose target still doesn't exist; a removed marker is refused with what to do instead. The agent'snoteand its identity (the MCP client's own name, e.g.claude-code,codex) go into the claim's history. Resolving a claim that is already fresh is a no-op. -
A claim that no longer applies is retired with
lockwire_ack(superseded) instead.
Every task's line is where the claim is now, read from the doc at the time of the call. paths can name docs, code files or directories (docs/). Writes are serialised per repository — the MCP server queues parallel calls, and separate processes (hooks, the CLI) take a .lockwire/lock file, which lockwire init git-ignores — so an agent issuing resolves in parallel loses none of them. A claim that is waived or superseded isn't resolved: lockwire_resolve says so and writes nothing.
To run the loop unattended — locally or in CI, opening a pull request — use lockwire autofix. The same loop also runs by hand from a shell with lockwire tasks, lockwire task <id> and lockwire resolve <id> — see cli.md.
Tested on a real repository. We replayed a real rerun from a public research repo whose agents write reports from results files: with markers added to the report beforehand, the rerun produced nine value-wrong tasks (every number whose value moved past its stated precision), and the fix the repo's own agent made a minute later resolved all nine — lockwire confirmed each corrected number against the data.
lockwire_history is the one query that doesn't exist anywhere else in the documentation-drift space — see docs/comparison.md. Every other tool we found answers "is this doc stale right now"; none answer "this claim has broken four times, here's each commit and each actor."