Skip to main content

Command reference

Every example on this page is output captured from the writ 0.1.0 tool. Run ids, hashes, timestamps, and file paths differ on your machine; the shape doesn't. The CLI prints absolute paths; the samples shorten them.

The writ CLI includes every command on this page. The examples that run mission.yaml use the vendor-dossier manifest from Your first mission; the approval and key examples use the approval-demo and keyed-demo manifests from Approvals and budgets and Keys and verification. The --service-db forms act on the database of a writ-mcp or writ-api host, and the coding commands are the operator side of a governed coding task whose agent uses writ-coding-mcp. Those three programs are separate from the writ CLI: see Writ's programs.

Exit codes​

writ uses a small, stable set of process exit codes. Scripts and CI can gate on these directly:

CodeNameMeaning
0OkSuccess / all-valid.
1(unexpected)An unhandled internal error, which is a bug in Writ. Prints Unexpected error: <message> with no stack trace. No anticipated failure maps here.
2ValidationErrorA manifest failed validation, an input file couldn't be read/parsed, or the command line was wrong: no command, an unknown command, a missing or malformed argument, an invalid --pubkey or --signer-mode.
3RunFailedA mission run failed (budget, execution, or authority).
4ApprovalRequiredA mission run is suspended awaiting human approval.
5VerificationFailedOffline receipt-chain verification found at least one failure.
6MissingWorkRecordEvery step ran, but the evidence is degraded (run outcome ExecutedReceiptPendingRecovery): at least one executed step's signed work record is not on the chain (its append failed, or the process died before it), or work-record.jsonl could not be exported. Never reported as clean success. The work records are staged in the run database; writ resume appends them and re-exports.
7PendingReconciliationA wallet payment's outcome is unknown: the run halted and the budget hold is retained pending writ reconcile. Never reported as clean failure or success — funds may have moved.
8VerificationIncompletewrit verify found every receipt valid but had no terminal commitment to check the chain's end against (a bare work-record.jsonl with no run.json, --expect-head, or --pinned-head), so tail truncation can't be ruled out. Pass --allow-no-terminal-commitment to accept the record without one.
9PreflightExpectationUnmetwrit coding preflight-host observed at least one thing other than its expectations file says: a path reachable that shouldn't be (or not reachable that should be), a name present that must be absent, or an elevated token where none was expected.
10RelayUnavailableA Nostr relay named with --relay could not be used: the connection failed, the deadline passed, the relay refused the event or the query, or it answered outside the protocol or the size limits. record publish-head has still written the attestation and the signed event locally, so it can be run again; record verify-head has reached no conclusion.
11WorkRecordDiscardedEvery step ran, at least one executed step has no signed work record, and the operator discarded each missing one with writ outbox discard (run outcome ExecutedReceiptDiscarded). Never reported as clean success. Unlike 6, nothing is left for writ resume to append. Each discard is a signed work_record_discarded receipt in the chain, and run.json lists each record in DiscardedWorkRecords with its reason. A still-pending staged record, or one marked discarded without the command, keeps the run at 6.
130(interrupted)Ctrl-C or SIGTERM. Prints Interrupted. to stderr. A run that had not yet spent or recorded anything has its empty run directory removed.

Every anticipated failure maps to one of these codes, so a caller can tell what kind of problem it hit. Usage mistakes print the problem and a pointer, for example Unknown command 'xyz'. Run writ --help. or No command given. Run writ --help to see the commands.

writ init​

writ init [<dir>]

Scaffolds a mission.yaml + README.md + .gitignore into a directory (default .). Refuses to overwrite an existing manifest.

$ writ init my-mission
Scaffolded mission at my-mission/mission.yaml
Next: edit the goal/vars, then `writ validate my-mission/mission.yaml` and `writ run my-mission/mission.yaml --var target_domain=example.com --var target_name="Example Corp"`.
The scaffold uses model.provider: anthropic, so `run` needs ANTHROPIC_API_KEY set in this shell.
$ writ init my-mission
Refusing to overwrite existing manifest: my-mission/mission.yaml

Exit 2 on refusal, 0 on success.

The scaffolded manifest is a vendor-dossier-shaped mission with model.provider: anthropic and an agent-type step — see Your first mission for what that means for a first run.

writ validate​

writ validate <manifest>

Parses a manifest through the same authoritative parser + validator run uses, and prints either an OK summary or the validation errors. Never mints a credential, calls a capability, or spends anything.

$ writ validate mission.yaml
OK — mission 'vendor-dossier': 3 worker(s), 3 capabilities.
Worst-case total spend: 100 sats (budget cap 200 sats; sum of worker slices 100 sats).
Settlement: simulated. Signing: dev-ephemeral.

A manifest with an allow_local capability gets an extra warning block:

!! 1 capability permit LOCAL targets (allow_local):
! capability 'test.local' permits LOCAL/loopback targets (allow_local) — cloud-metadata endpoints are still denied.
~ Capability 'test.local' sets allow_local=true — it may reach loopback/private targets (cloud-metadata endpoints stay denied). Intended only for local mock/demo endpoints.

validate takes no --var, so it stands in a placeholder for every {{name}} the manifest references. A {{name}} that isn't listed under mission.vars is a warning, not an error, because run --var name=value accepts it. validate still exits 0 when that is the only finding:

~ '{{topic}}' is referenced but not declared in mission.vars; add it there so the manifest lists every value a run must supply.

Error path (exit 2):

$ writ validate /tmp/bad-mission.yaml
Manifest invalid (1 problem(s)):
- mission is missing required field 'goal'.

See the full error catalog in Troubleshooting and every field in the manifest reference.

writ run​

writ run <manifest> [--var name=value]... [--dry-run] [--production] [--output-dir <dir>]
OptionMeaning
--var <name=value>Set a manifest var (repeatable).
--dry-runPlan + cost estimate only; mints nothing, pays nothing, writes no runs/ directory.
--productionFail-closed posture: no dev-ephemeral signer, wallet settlement required. See Security model.
--output-dir <dir>Override the manifest's work_record.output_dir.

Planned (--dry-run):

$ writ run mission.yaml --var target_domain=example.com --var target_name="Example Corp" --dry-run
Running mission 'vendor-dossier' (run vendor-dossier-20261117-002809-06f257b3e1d94e1799d95bf179c4570d) — dry run, no spend...
· infra-researcher/mission.dns.whois 5 sats planned
· compliance-researcher/mission.compliance.search 12 sats planned
· writer/mission.compose.dossier 0 sats planned

Run vendor-dossier-20261117-002809-06f257b3e1d94e1799d95bf179c4570d: Planned
Spent 0 / 200 sats · settlement simulated · 0 receipt(s)

Completed (real run — see Your first mission for the full walkthrough):

$ writ run mission.yaml --var target_domain=example.com --var target_name="Example Corp"
Running mission 'vendor-dossier' (run vendor-dossier-20261117-002810-53a59cab5a76490480b2142075b6cb2d)...
· infra-researcher/mission.dns.whois 5 sats Executed (simulated)
· compliance-researcher/mission.compliance.search 12 sats Executed (simulated)
· writer/mission.compose.dossier 0 sats Executed

Run vendor-dossier-20261117-002810-53a59cab5a76490480b2142075b6cb2d: Completed
Spent 17 / 200 sats · settlement simulated · 3 receipt(s)
Outputs:
- runs/vendor-dossier-.../infra.json
- runs/vendor-dossier-.../compliance.json
- runs/vendor-dossier-.../dossier.md
- runs/vendor-dossier-.../work-record.jsonl
- runs/vendor-dossier-.../usage.json
- runs/vendor-dossier-.../run.json
- runs/vendor-dossier-.../report.html
Verify: writ verify runs/vendor-dossier-... --pubkey 93178da572... --signer-mode dev-ephemeral

Exit 0. The Verify: line is printed for every completed run and is ready to paste. A Model line appears only when a step called a model, and then includes the call count and list-price cost billed to your provider account (for example Model claude-cli · 2 call(s) · $0.117 billed to your claude-cli account (list price, not part of the sats budget)). If an HTTP provider's API key variable is unset, the run fails pre-flight with Pre-flight check failed: model provider 'anthropic' needs an API key, but ANTHROPIC_API_KEY is not set in this shell. ... (exit 3) before any capability is invoked.

Suspended for approval (exit 4; see Approvals and budgets). A run started with WRIT_ROOT_KEY set and a persistent signer prints the commands that continue it:

$ writ run mission.yaml
Running mission 'approval-demo' (run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931)...
· buyer/mission.data.premium 0 sats ApprovalRequired

Run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931: ApprovalRequired
Spent 0 / 50 sats · settlement simulated · 0 receipt(s)
Outputs:
- runs/approval-demo-.../work-record.jsonl
- runs/approval-demo-.../usage.json
- runs/approval-demo-.../run.json
- runs/approval-demo-.../report.html
Suspended — pending approval #1. Approve with: writ approvals approve 1 --run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931
Then continue the run with: writ resume approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931 mission.yaml
Spend requires human approval.

A run that cannot be resumed (no WRIT_ROOT_KEY, or a dev-ephemeral signer) says so instead:

Suspended — pending approval #1.
This run cannot be resumed: it started without WRIT_ROOT_KEY. To approve and continue a run, set WRIT_ROOT_KEY to a secret you keep and use work_record.signing: key-file (or env), then run the mission again.

A dry run of a mission that calls a model ends with a note that says what the run will need for it, for example Note: This mission calls a model: provider 'anthropic' needs ANTHROPIC_API_KEY at run time (not set in this shell). writ validate prints the same note. Neither fails because of it.

Wallet-mode real-money banner (printed before anything executes, never on a dry run):

WARNING: wallet settlement — this run makes REAL Lightning payments, bounded by the mission budget (100 sats total).

Missing a required --var:

$ writ run mission.yaml --dry-run
Manifest invalid: Manifest references variable '{{target_name}}' but no --var target_name=... was supplied.

Exit 2.

writ resume​

writ resume <run-id> <manifest> [--var name=value]... [--production] [--output-dir <dir>]

Continues an existing run: one suspended for approval (exit 4), one whose process was interrupted (a crash, a kill, a power loss), or one that finished with degraded evidence (exit 6). It reopens the run's own database and its progress journal (progress.jsonl), reuses the credentials the run already issued, restores the steps that completed (their outputs feed later steps exactly as before), and resolves every interrupted call from the ledger by the call's idempotency key:

  • a call that finished is answered from the ledger and is not run again;
  • a call that never reserved budget is proven unpaid and is issued again once, under a new key;
  • a call whose payment may have gone out but was never recorded keeps its budget hold and halts the run for writ reconcile (exit 7); it is never executed again;
  • a work record that was staged but not appended is appended.

It needs the same manifest and --var values (checked against the journal), the same WRIT_ROOT_KEY the run started with, and a persistent receipt signer (work_record.signing: env or key-file); Approve and resume a run, end to end sets these up. Resuming a completed run re-exports its work record and changes nothing else. Exit codes are those of writ run.

$ writ resume approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931 mission.yaml
Resuming mission 'approval-demo' (run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931)...
· buyer/mission.data.premium 20 sats Executed (simulated)

Run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931: Completed
Spent 20 / 50 sats · settlement simulated · 1 receipt(s)
Outputs:
- runs/approval-demo-.../premium.json
- runs/approval-demo-.../work-record.jsonl
- runs/approval-demo-.../usage.json
- runs/approval-demo-.../run.json
- runs/approval-demo-.../report.html
Verify: writ verify runs/approval-demo-... --pubkey 3b2b9a7e0db5ae925b90f772737618fe99ddf0af751ed4013d8a43192dec9a3a

A resume that cannot be safe is refused before anything is opened, and changes nothing (exit 3). With a different WRIT_ROOT_KEY:

$ writ resume approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931 mission.yaml
Resuming mission 'approval-demo' (run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931)...
Resume refused: WRIT_ROOT_KEY is not the authority key run 'approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931' was started with (its journal does not authenticate under it), or the journal was edited. Nothing was changed.

Only one process runs a run at a time: writ run and writ resume hold run.lock in the run directory, and a second process is refused.

writ approvals​

writ approvals list (--run <run-id> | --service-db <path> [--workspace <ws>])
writ approvals approve <id> (--run <run-id> | --service-db <path> [--workspace <ws>])
writ approvals deny <id> (--run <run-id> | --service-db <path> [--workspace <ws>])

All three take --runs-root <dir> (default runs). Give exactly one of --run and --service-db; both or neither exits 2.

$ writ approvals list --run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931
Pending approvals for run 'approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931':
#1 mission.data.premium 20 sats — buyer:data.premium
resource /fetch → api.example.test (invocation #1); valid 15 min once approved
$ writ approvals list --run keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32
No pending approvals for run 'keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32'.
$ writ approvals approve 1 --run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931
Approved #1. Continue the run with: writ resume approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931 <manifest> (the manifest it started with).

Approving twice:

$ writ approvals approve 1 --run approval-demo-...
Could not approve #1: Approval request is already approved.

Exit 2.

Denying an id that doesn't exist:

$ writ approvals deny 999 --run approval-demo-...
Could not deny #999: Approval request not found.

Exit 2.

After approving, continue the run with writ resume. Re-running the manifest with writ run starts a new run that cannot see this run's approvals. See Approvals and budgets.

On a service host​

With --service-db, the same verbs act on a writ-mcp or writ-api host's database (its WRIT_DB_PATH), in the given workspace (default WRIT_WORKSPACE, else default). This is how the operator decides a spend an agent-role host is holding. Run it with the host's WRIT_ROOT_KEY in the environment. Before reading anything else it checks that key against the database (the host records its key when it starts, so start the host once first), and it works on a database at this build's schema version without creating or upgrading it: to upgrade, stop the host and run writ db upgrade. A wrong key, an unbound database, or another schema version exits 2 and changes nothing.

$ writ approvals list --service-db ./host/writ.db
Pending approvals in workspace 'default' of ./host/writ.db:
#1 writ.demo.search 10 sats writ #1
resource /search → capabilities.writ.example (invocation #1); valid 15 min once approved
$ writ approvals approve 1 --service-db ./host/writ.db
Approved #1. The agent's retry of the same call now runs; the approval is consumed by exactly one invocation.

A coding scope-expansion request is refused here as on the run path; decide it with writ coding approvals.

writ issue​

writ issue --service-db <path> --principal <name> [--scope <capability|ns.*|*>] [--budget <sats>] [--per-call <sats>]
[--ttl-minutes <n>] [--depth <n>] [--purpose <text>] [--workspace <ws>] [--json]

Issues a root writ on a writ-mcp or writ-api host's database and prints its credential, for the operator to hand to the agent. An agent-role host serves no issue tool, so this is how its agent gets authority. It reads the host's settings from the environment, as the host does: WRIT_ROOT_KEY (required: the host's own value, checked against the database before anything is written), WRIT_CAPABILITIES for a concrete --scope, WRIT_WORKSPACE, and the budget and TTL defaults. --depth defaults to 1. It makes the same database checks as writ approvals --service-db.

$ writ issue --service-db ./host/writ.db --principal researcher --budget 200 --per-call 25
Issued writ #1 to 'researcher' in workspace 'default': scope writ.*, 200 sats total, 25 per call, delegation depth 1, expires 2026-11-15T07:54:19Z.
Hand this credential to the agent and to nobody else; it is a bearer token for spend up to those bounds:
MDAxZWxvY2F0aW9uIHdyaXQ6Ly9hdXRob3JpdHkKMDA1YWlkZW50aWZpZXIg...

--json prints one object with credentialId, credential, and the bounds. Without WRIT_ROOT_KEY:

$ writ issue --service-db ./host/writ.db --principal researcher
Writ service configuration is not usable:
- WRIT_ROOT_KEY is required: set it to the host's value. A writ issued under any other key does not verify on the host, and the audit events this writes must verify alongside the host's own.

Exit 2.

writ revoke​

writ revoke <credential-id> (--run <run-id> | --service-db <path> [--workspace <ws>])

The kill switch: revokes a credential and its entire delegated subtree. Writ checks revocation whenever it verifies a credential, so a revoked credential fails verification even though the macaroon itself is still well formed. writ revoke records the revocation as a signed audit row under the key in WRIT_AUDIT_KEY (any secret you choose and keep); without it, the command stops with AuditKeyNotConfigured (exit 2), and --development-audit-key uses a key built into Writ, for tests only. With --service-db it revokes on a writ-mcp or writ-api host's database (revoking is the operator's on those hosts), with the host's WRIT_ROOT_KEY in the environment and the same checks as writ approvals --service-db.

$ writ revoke 1 --run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931
Revoked credential #1 and its delegated subtree. Any token in that subtree now fails verification.

Revoking the same credential again succeeds again (it is idempotent):

$ writ revoke 1 --run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931
Revoked credential #1 and its delegated subtree. Any token in that subtree now fails verification.

A credential id that never existed:

$ writ revoke 9999 --run approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931
Credential #9999 was not found in run 'approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931'.

Exit 2.

writ record​

writ record show <run-id>
writ record export <run-id> [--out <dir>]
writ record publish-head <run-id> [--out <file>] [--post <url>] [--key <path>] [--relay <wss-url>] [--relay-timeout <s>] [--json]
writ record verify-head <run-id> --relay <wss-url> --pubkey <hex> [--revocations <file>] [--relay-timeout <s>] [--json]

record show​

Human-readable summary — see Your first mission for a full captured example.

record export​

Without --out, prints the signed chain (work-record.jsonl) to stdout, one JSON object per line. With --out <dir>, writes a shareable bundle: work-record.jsonl, run.json, report.html, usage.json, the signer records of a key-signed run (signer-identity.json, and rotations.jsonl and revocations.jsonl when the run has them), and a manifest.json listing each file's SHA-256 and the chain head. It never includes writ.db, key material, or step outputs (see Run artifacts and export). A recipient verifies the bundle directory with the signer's public key, which you give them separately.

$ writ record export keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32 --out share-bundle
Exported run 'keyed-demo-20261117-002151-f665d63865054f42a2bdc7b8c21c7a32' to <your directory>/share-bundle
work-record.jsonl (1504 bytes, sha256 fa86bd0a321fab11f05de3add6c78c3c1837d2091ffa89ad200ee651ed8cd8c8)
run.json (2115 bytes, sha256 75baefa915634c7c24bde4744ad36123eed0f76c867b17df02f2a255f45f6ea5)
report.html (3776 bytes, sha256 b17704f88a3431762f97ae5219c1a28cb6d5330c0f39936a2ec9b67e40f18b38)
usage.json (182 bytes, sha256 e230184836060050d94f7016905ac25349993f830db241a16e2379a6737d2cae)
signer-identity.json (531 bytes, sha256 a7e7fefe3d966d03e2e2685516f1376bb3248600245affa9364bdb46231d2a07)
manifest.json
Chain head: 0:526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a (1 receipts).
Not included (never exported): writ.db and its sidecars, key material, and step outputs.
Recipient check: writ verify <this directory> --pubkey <signer pubkey hex> --expect-head 0:526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a

record publish-head​

Signs a head attestation over the run's terminal receipt, using the run's own signer key (or a successor of it, per the run's rotation records), and writes <run>/head-attestation.json. It needs the key on disk, so a dev-ephemeral run, whose key was never written, is refused (exit 2):

$ writ record publish-head smoke-20261117-002246-a33f66e03fa5434ebd1e0279df95a1ed
Run 'smoke-20261117-002246-a33f66e03fa5434ebd1e0279df95a1ed' was signed with a dev-ephemeral key, which existed only in the process that ran it, so no key can attest its head. Use work_record.signing: env or key-file for runs whose head you publish. Nothing was written.

See Keys and verification for the walkthrough with a persistent key.

With --relay <wss-url>, the attestation is also published to that Nostr relay, a relay you choose, so a copy of the head is held outside the machine that ran the run. wss://agents.lightningenable.com is a public relay that accepts these events. No relay is contacted without --relay. A relay is not a transparency log: it can withhold or lose a later head, so publish to and check more than one relay to detect a withheld head.

  • Before anything is signed for a relay, the run's local chain is verified as writ verify does, anchored at the run's own signer. A chain that does not verify exits 5, and nothing is written or sent.
  • The event is kind 38410, an addressable kind dedicated to Writ head attestations. It is signed by the same key that signed the attestation. A Writ receipt key is a BIP-340 secp256k1 key, which is what a Nostr key is, so the event's author is the receipt signer (or the successor key that attested).
  • Its content is the attestation JSON exactly as written to head-attestation.json. Its tags are d = writ.head:<run-id>:<seq>, the NIP-32 label ["L","writ.run"] and ["l","<run-id>","writ.run"], seq, count, head, key_id, protocol and alt. When a successor key attests, the event also carries one rotation tag per signed rotation record from the run's signer to that key (at most 16).
  • Each head position is its own event, so publishing a later head does not replace an earlier one on the relay.
  • The signed event is also written to <run>/head-attestation.nostr.json. The private key is wiped from memory before any file is written or the relay is contacted.
  • Only wss:// is accepted, of printable ASCII, with no user information, query string, fragment or percent-encoding. --relay-timeout (1 to 120 seconds, default 15) bounds the whole exchange. A relay that refuses the event, times out, or cannot be reached exits 10; everything is still written locally, and running the command again retries.
  • --json prints one JSON object on stdout on every path, including usage errors (outcome, exit_code, errors, and when they exist the attestation's fields, the files written, the relay's status and event id, and the --post status).

What the relay sees. A relay is public. It learns the run id, the receipt count, the head hash, the signer's key id, the time of the attestation, the signer's public key (which links every run that key signs), and any rotation records between the run's signer and the attesting key. No receipt contents, prices, endpoints, prompts or outputs are sent.

record verify-head​

Checks the copy a relay holds against the local record. It reads only and publishes nothing.

  1. It verifies the local run directory as writ verify does, under --pubkey (the trust anchor). A local chain that does not verify exits 5 before the relay is asked. A run with no run.json (an in-progress or interrupted run) is accepted at this step, so deleting run.json is not caught here; the relay's heads are the end-of-chain check this command adds.
  2. The run's rotations.jsonl and revocations.jsonl must be readable and well formed. An unreadable file or a malformed line exits 5 (local_records_invalid) rather than counting as "no records".
  3. It asks the relay for every event of kind 38410 labelled with this run, from any author. It does not filter by author, because the set of authors would have to come from the directory under test.
  4. It treats everything the relay returns as untrusted, and sets an event aside only when it is provably not a head of this run by the anchor's key chain: its shape, id or signature does not hold and it does not claim this run under a key on the anchor's chain (anyone can send such an event), it names another run in every run field (l, d parsed exactly as writ.head:<run-id>:<seq>, and the content's run_id) or is another kind, or its author has no validly signed rotation path from --pubkey in any record the command holds (the run's rotations.jsonl and the rotations every returned event carries). Those are counted as invalid or foreign.
  5. An event whose author does have such a path must be fully usable, or the outcome is not match: exactly one of each tag the command relies on, each agreeing with the attestation in its content; an attestation that names this run and is signed by the event's author; an author the chain resolves to, not through a rotation dated after its old key's revocation; and an author not revoked before the attestation. An event that fails any of these is counted as blocking.
  6. If the validly signed rotation records rooted at --pubkey fork (one key with two different rotations that are not dated after its revocation) or loop, which key is in force cannot be decided: the outcome is key_chain_ambiguous (exit 5). Two copies of one rotation (the same signed statement, however encoded or re-signed) are one rotation. Signature and key hex must be lowercase.
  7. Every remaining head must name a receipt the local chain holds, with the same hash.
ExitOutcomeMeaning
0matchEvery head this relay returned is the local head or an earlier receipt of it. The output says how many local receipts are newer than the latest published head.
8not_publishedThe relay returned no valid head for this run. That is also what a deleted or withheld publication looks like, so it is not evidence either way.
5mismatch, key_chain_ambiguousA returned head is past the end of the local chain (a rollback: receipts the relay saw are missing locally), names a different hash at a position the local chain holds (a fork), or two returned heads disagree at one position; or a head signed by a key on the anchor's chain cannot be used (blocking); or the key chain forks or loops. Also local_chain_invalid and local_records_invalid.
10relay_unavailable, relay_incomplete, relay_alteredThe relay could not be used; or it returned as many events as this command asks for (500), so its answer may have been cut; or it returned an event that claims this run under a key on the anchor's chain but whose id or signature does not verify, so it altered data (for example stripped a tag). No match is claimed.

What match means. match means the local record is consistent with what this relay returned, and nothing more. A relay that withholds a later head, or has lost it, makes a rollback look like a match. Checking more than one relay reduces that risk; this command checks one.

Relay limits. A relay whose own per-query limit is below 500 can cut the answer without saying so, and the cut can drop the head that disagrees. Check a relay whose limit you know, or several.

Junk under the run id. Anyone can post events labelled with a run id. Strangers' events are set aside and counted, but 500 of them fill the answer and force relay_incomplete. That can prevent a match; it can never produce one.

A compromised key. Whoever holds any key on the anchor's chain, including a revoked one, can sign a second rotation or an unusable head and so force key_chain_ambiguous or mismatch. That is deliberate: it is a real incident, and the operator should see it rather than a match.

Key holder. None of this protects against whoever holds the signing key: they can publish a different head at the same position, or delete events (the relay supports NIP-09 deletion).

Revocations. The run directory's revocations.jsonl can be deleted by whoever can edit the directory. Deleting it can only make more heads count (a revoked key's later heads are then accepted), so it cannot hide a head that contradicts the local chain; but it does let receipts or heads signed with a revoked key after its revocation pass. Pass --revocations <file> with a copy you keep elsewhere to use that instead.

writ reconcile​

writ reconcile <run-id> [--invocation N] [--resolve paid|not-paid [--allow-unconfirmed-not-paid]]
writ reconcile --service-db <path> [--workspace <ws>] [--invocation N] [--resolve paid|not-paid [--allow-unconfirmed-not-paid]]
writ reconcile (<run-id> | --service-db <path> [--workspace <ws>]) --apply-proof-journal [--yes] [--allow-legacy-proof-lines]

writ reconcile records each decision as a signed audit row under the key in WRIT_AUDIT_KEY, as writ revoke does; without it, the command stops with AuditKeyNotConfigured (exit 2).

With --service-db, the same reconciliation runs against a writ-mcp or writ-api host's database (its WRIT_DB_PATH) in the given workspace (default WRIT_WORKSPACE, else default). It is an operator command: it needs the database file. A running host also offers the same reconciliation to its operator role (writ_reconcile on a --role operator server, POST /v1/reconciliations/{invocationId}/resolve with the operator token); agents reach neither. WRIT_ROOT_KEY must be set to the host's value: the command refuses without it, and refuses a key that verifies none of the database's existing audit events, so every audit row it writes verifies alongside the host's own. The database must be at the schema version of the writ you run; --service-db never upgrades a host's database. For an older one, or one without a database identity, stop the host, run writ db upgrade <path>, and start the host again. Use one root key per service database, and never reuse a root key on another database or bring one back after it has been replaced.

Run writ reconcile from a shell configured with the wallet the host or run pays from (the same LND_*, NWC_CONNECTION_STRING or Strike settings), so the wallet that answers a lookup is the wallet that paid.

--resolve not-paid on a hold with a payment hash. Writ first asks the wallet to look the payment up by the hash in the hold's signed audit record, and accepts the attestation only when the wallet reports the payment failed. When that record names the kind of wallet that paid (LND, NWC, Strike), only that kind of wallet can confirm it. A hold counts as having no payment hash only when its signed record says so. Otherwise Writ refuses, prints a code, changes nothing, and exits 7:

CodeWhat the wallet saidWhat to do
wallet_reports_paidThe payment went out.Run writ reconcile without --resolve to settle it from the wallet's answer. --allow-unconfirmed-not-paid does not change this.
wallet_cannot_confirmIt could not tell (an in-flight payment, a lookup that timed out, or Strike, which has no lookup by hash); another kind of wallet answered than the one that paid; or the hold has no signed record of its payment hash.Wait and retry, run from a shell configured with the wallet that paid, or check the payment by its hash yourself.
no_lookup_walletNo wallet that can look payments up is configured.Check the payment by its hash yourself.

Plain writ reconcile and a resumed run follow the same rules when they ask the wallet: a not-paid answer returns the hold only from the kind of wallet that paid, about the hash in the signed record, and otherwise the hold stays pending. A record written by an earlier Writ names no wallet; resolve such a hold with --resolve not-paid.

When you have checked the payment yourself and it failed, add --allow-unconfirmed-not-paid. The signed audit event for the reconciliation records which way the attestation was accepted (walletCheck is confirmed-not-paid or unconfirmed-override), which wallet answered (wallet), and which kind of wallet paid (walletPaidWith).

$ writ reconcile vendor-dossier-... --invocation 3 --resolve not-paid
Could not reconcile invocation 3 (no_lookup_wallet): A not-paid attestation on a row with a payment hash needs the wallet that paid to report the payment failed. No wallet that can look payments up is configured, so nothing can confirm the payment failed. Check the payment by its hash in your wallet; if it failed, re-run with --allow-unconfirmed-not-paid, which the audit log records. Nothing was changed.

Exit 7.

An invocation that carries a payment proof (the executor returned a preimage) is resolved as paid for exactly the proven amount, with or without --resolve paid, whatever state it is in; --resolve not-paid is refused for it, because the proof shows the payment went out. The proof journal. If the host could not write a payment proof to its database, it appends it to <database>.proofs.jsonl beside it: hash and amount only, never the preimage, in a file created owner-only (a protected ACL on Windows, mode 0600 on POSIX). Each line is authenticated with an HMAC-SHA256 keyed from the host's audit key material (the same key that signs its audit events, under its own domain), over the database's identity, workspace, invocation id, payment hash, amount, and timestamp. A journal line applies only in the database it was written for. Every Writ database gets its own identity when it is created, or when an upgrade brings it to schema version 13; a copy, backup or restore of the file keeps it, and the database refuses an update or deletion of it. Applying the journal is an explicit step:

  • Plain writ reconcile only reports that a journal with N unapplied lines exists.
  • --apply-proof-journal lists every line and what it would do. Nothing is applied without --yes.
  • A line is applied only if its MAC verifies with this host's key, it names this database's identity, and it is consistent with the ledger: the invocation exists in the workspace, the amount is positive and no more than the hold reserved for that call, the call was reserved at some point, and the invocation is not already settled under a payment hash. Each line applies at most once.
  • A line that fails any check is refused and reported by line number (exit 2). The journal file is never edited or deleted.

Legacy journal lines. A line written before its database had an identity names no database, so it is refused unless you add --allow-legacy-proof-lines to --apply-proof-journal. With it, a legacy line applies only in a database that an upgrade gave an identity (writ db upgrade, a host's start, or a command that opens a run's database), and only when the line was recorded before that upgrade; it still passes every other check, and its audit event records journalLine: legacy-allowed-by-operator. Use it only for lines you know were written for this database.

--resolve not-paid on a pending invocation with no payment hash (one routed to reconciliation because it sat reserved too long) is refused until the paid-call runtime bound has passed since its reservation: a paid call is cancelled after at most 10 minutes (two HTTP requests of at most 100 s each and a wallet payment of at most 120 s, plus slack), so after that no execution of it can still be running. The message says from when it is allowed.

Resolves a budget hold retained because a wallet payment's outcome was unknown (exit 7). Simulated-settlement runs never produce a pending hold:

$ writ reconcile approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931
No invocations pending reconciliation for run 'approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931'.

Exit 0.

$ writ reconcile approval-demo-... --resolve maybe
--resolve must be exactly 'paid' or 'not-paid' (was 'maybe').

Exit 2.

See Approvals and budgets for the full reconciliation model.

writ db​

writ db status <database>
writ db upgrade <database>

A Writ database records its schema version in SQLite's PRAGMA user_version. status prints it, the version this build understands, and any pending upgrade steps, and changes nothing. upgrade writes a backup beside the database (<db>.backups/<db-name>.schema-v<from>-<stamp>.bak, in an owner-only directory), then applies every pending step in one transaction. Every other command that opens an older run database performs the same upgrade, with the same backup, implicitly; a command given --service-db never upgrades a host's database and tells you to run writ db upgrade with the host stopped. Upgrading a database to schema 13 charges earlier late payments that exceeded a cap to the links that had room, which lowers those links' remaining budget; writ db upgrade lists each charge, and a host or command that upgrades a database implicitly reports the totals. A database written by a newer Writ is refused and left unchanged (exit 2). To roll back, stop every Writ process using the database and replace it with the backup; there are no down-migrations.

$ writ db status runs/approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931/writ.db
Database: <your directory>/runs/approval-demo-20261117-002310-8cd93b408d164e67a903ca0b80dea931/writ.db
Schema version: 12
This build: 12
Status: current.

writ outbox​

writ outbox list (<run-id> | --service-db <path> [--workspace <ws>] [--previous-root-key-env <NAME>]) [--json] [--runs-root <dir>]
writ outbox discard (<run-id> | --service-db <path> [--workspace <ws>]) --invocation <id> --reason <why> [--json]
writ outbox resign --service-db <path> [--workspace <ws>] --invocation <id> --previous-root-key-env <NAME> [--json]

The operator's tool for staged work records (the receipt outbox) that the recovery job will not append on its own. A paid call's work record is staged before the ledger moves, with a MAC keyed from the host's WRIT_ROOT_KEY; writ resume (for a run) or a service host's restart appends it when the MAC verifies under the current key and the request matches the ledger. Run any host that stages receipts with a persistent WRIT_ROOT_KEY, and drain the outbox before rotating the key (restart the host, check that writ outbox list shows nothing pending, then rotate). Keep the host database writable only by the host account. Use one root key per service database: never reuse it on another database, and never bring it back after it has been replaced. Point the command at the same database path the host uses (its WRIT_DB_PATH), not a copy.

Before you run resign or discard: stop the service host, or make sure no writ run or writ resume is running the run. The commands refuse while the run holds run.lock, or while a service host holds <db>.host.lock (hosts hold it for as long as they run, and do not start while the command holds it). writ issue, writ approvals and writ revoke --service-db do not take that lock and work while the host runs.

  • list reads only. For each pending record: invocation, capability, amount, payment hash, staged time, one reason code, whether the MAC verifies and under which key (mac_verified_under), the re-sign cross-check's verdict, the proof events for the invocation (how many count as evidence for this record, how many do not, and how many verify but name another payment; not checked without WRIT_ROOT_KEY), and the actions open to you. list offers resign when every check it can run passes (the same checks resign runs), so pass the same --previous-root-key-env to list as you would to resign; resign can still answer unchanged, or refuse while a host holds the database lock. When WRIT_ROOT_KEY is not the host's current key, list offers resign for no record and prints the refusal resign would give. Reason codes: mac_invalid, unkeyed (re-sign on a service database, or discard), ledger_mismatch, invocation_missing, request_unreadable (discard), and the ones the recovery job handles by itself: replayable, awaiting_ledger (reconcile first), already_on_chain, no_receipt_owed. Discarded records are listed with their reasons and whether their signed discard receipt is on the chain. Without WRIT_ROOT_KEY the MACs are reported not_checked.

  • resign (service databases only) re-authenticates a record under the host's current key. Use it after a key change, for a record this host staged under its earlier key. Put the previous WRIT_ROOT_KEY in an environment variable and pass the variable's NAME with --previous-root-key-env (the key is never written on the command line, printed or recorded); it must be a key that signed a host.key_bound record in this file, and WRIT_ROOT_KEY must be the host's current key. Evidence under it counts only from its first period, before the binding that replaced it. If the previous key was replaced because it may have been exposed, use discard, not resign. resign replaces the record's MAC and nothing else, and only when all of these hold:

    • the record's own MAC verifies under the previous key, and the times it carries predate the key change (the binding that replaced the previous key);
    • every request field with a stored counterpart matches the ledger: invocation and workspace; capability (record, request and invocation); payment hash and proven amount of the invocation's recorded proof; authority mode and connector; payment-verification time and request time within the invocation's lifetime; the result code against the outcome recorded for a keyed call; the principal and authority hash of the invocation's credential; no other receipt for the same payment; and no proof event that verifies under a key you hold naming another payment;
    • for a paid record, a proof event with the same payment hash and amount (a reconcile event only with a Paid verdict) verifies under the current key, or under the previous key with a time before the key change.

    Without --previous-root-key-env it refuses with previous_root_key_required; a record that does not verify under the previous key is refused with record_not_authenticated. Discard either. The output says which key the record verified under (mac_verified_under) and which key the proof event verified under. The signed receipt_outbox.resigned audit event records the evidence, the binding record the previous key verified, and the digest before and after. Restart the host to append the receipt.

  • discard writes a record off. Use it for a record you cannot explain, for one the cross-check refuses, and for every stranded record on a run (a run's records and its journal are keyed from the same root key, so a record on a run whose MAC does not verify was not written by the run's own process: resign refuses it with resign_not_available_on_run). The record is kept; your --reason goes into a signed receipt_outbox.discarded audit event, together with the invocation's capability, credential and the payment hash the ledger records at that moment. The next writ resume of a run, or the host's next start, appends a signed receipt of result code work_record_discarded (reason code operator_discarded) stating those facts, to the chain the terminal commitment covers; it is not appended when the invocation or its credential was missing at the discard, and list shows whether it is on the chain. A run then ends ExecutedReceiptDiscarded (exit 11) and lists the record in run.json's DiscardedWorkRecords; writ verify counts the discard receipts and prints a warning for each. A record the recovery job appends or will append (replayable, awaiting_ledger) is refused (not_stranded), whatever its current status. A record marked discarded without the command is put back to pending by the next recovery.

Both write commands need WRIT_ROOT_KEY, and check it before they take the lock. On a service database the key must match the newest key binding the host recorded at its start (host.key_bound); a host restarted under a new key records a new binding, so its new key matches. On a run, the run's journal must authenticate under it. The database's schema version is read without changing it; an older version is refused with the writ db upgrade command to run. Each write is one transaction holding the audit event and the record's update: an interrupted command changes nothing and can be run again, and running it again after it succeeded changes nothing (unchanged). Neither writ-mcp nor the HTTP API exposes these commands.

Exit 0 when the command did what was asked, including an idempotent no-op; exit 2 when it refused or the input was wrong. With --json, one object on stdout on every path; a refusal carries error.code: usage_error, target_not_found, target_busy, host_settings_invalid, root_key_missing, root_key_unrecognized, root_key_not_bound, previous_root_key_missing, previous_root_key_unrecognized, previous_root_key_required, record_not_authenticated, schema_error, store_error, not_staged, not_pending, not_stranded, cross_check_failed, no_receipt_owed, resign_not_available_on_run, concurrent_change.

A run with a record that does not verify under its key:

$ writ outbox list demo-run
Receipt outbox of run 'demo-run': 1 pending, 0 discarded by the operator.
Root key: recognized (MACs checked under it).
invocation 1 mission.data.lookup 5 sats payment hash f76a0574fc945a9ec02b074dab53b62c17bdf8916b5abfa1edcaef12136153c1 staged 2026-11-15T08:29:06Z invocation Settled
reason: mac_invalid — its MAC does not verify under the run's key, so the run's own process did not write it as it stands
MAC: invalid; cross-check: passes
proof events: 1 verify under this key, 0 do not
actions: discard

$ writ outbox discard demo-run --invocation 1 --reason "does not verify under the run key; not written by this run"
Discarded the staged work record of invocation 1 (audit event 4). Its receipt stays missing and is reported as discarded: the run ends `ExecutedReceiptDiscarded` (exit 11) on its next `writ resume`, which also appends a signed record of the discard.

Exit 0. writ outbox resign demo-run ... exits 2 with resign_not_available_on_run. The next writ resume ends Run demo-run: ExecutedReceiptDiscarded, exit 11, and writ verify on the run (exit 0: the chain that exists is intact) prints OK — verified 2 receipt(s), 1 of them a discard record (work_record_discarded). and adds:

WARNING: receipt 1 (signed) records that the work record of invocation 1 (mission.data.lookup, payment hash f76a0574fc945a9ec02b074dab53b62c17bdf8916b5abfa1edcaef12136153c1) was discarded by the operator: no receipt describes that call.
WARNING: run.json (unsigned) records 1 work record(s) discarded by the operator; no receipt exists for them: invocation 1 mission.data.lookup 5 sats payment hash f76a0574fc945a9ec02b074dab53b62c17bdf8916b5abfa1edcaef12136153c1 — reason: does not verify under the run key; not written by this run.

writ keys​

writ keys init [--out <path>] --operator-name <name> [--operator-url <url>] [--operator-contact <c>]
writ keys show [--key <path>] [--identity <path>]
writ keys rotate [--key <path>] [--operator-name <name>] [--operator-url <url>] [--operator-contact <c>]
writ keys revoke [--key <path>] --key-id <id> [--reason <text>]

The full walkthrough with real output (init, show, rotate, and revoke, and what each does to writ verify) is in Keys and verification. Quick reference:

$ writ keys init --operator-name "Example Operator" --operator-url https://operator.example --operator-contact ops@operator.example
Created receipt signing key: keys/receipt.key (private; no other account is granted access)
Created signer identity: <your directory>/keys/signer-identity.json (public; ships with every run)
key_id: 48d196ae736139f2
pubkey: 1f9a2598...82b214ca
operator: Example Operator (https://operator.example) <ops@operator.example>

Next: in mission.yaml set
work_record:
signing: key-file
key_file: keys/receipt.key
and share the pubkey with anyone who will run `writ verify`.

keys init refuses to overwrite an existing key (exit 2); keys show prints the public identity only, never the private key; keys rotate replaces the key in place and archives the old one; keys revoke appends a signed revocation that writ verify honors going forward.

writ verify​

writ verify [<work-record>] --pubkey <hex> [--algorithm <alg>] [--key-id <id>] [--signer-mode <mode>]
[--expect-head <seq:hash>] [--summary <run.json>] [--record <work-record.jsonl>]
[--require-identity] [--identity <path>] [--rotations <path>] [--revocations <path>]
[--pinned-head <attestation.json>] [--allow-no-terminal-commitment]

<work-record> is a run directory or an exported bundle (containing work-record.jsonl and, when present, run.json and the signer records), or a direct path to work-record.jsonl. It reads signer-identity.json, rotations.jsonl and revocations.jsonl from beside the work record unless --identity, --rotations or --revocations names another file. Fully offline: no database, no network, no access to the machine that produced the run.

--pubkey must be the signer's 32-byte public key as 64 hex characters (an optional 0x prefix is accepted). Anything else is a usage error (exit 2): Invalid --pubkey '<value>': expected the signer's 32-byte public key as 64 hex characters ... Copy SignerPublicKeyHex from the run's run.json. Likewise --signer-mode must be production or dev-ephemeral.

Incomplete (exit 8). When nothing binds the end of the chain (no run.json terminal commitment, no --expect-head, no --pinned-head), every receipt can be valid and the record can still have been shortened. verify then says so instead of printing OK:

$ writ verify runs/keyed-demo-.../work-record.jsonl --pubkey 1f9a25988803ebda461fc30b4e29f9149b94b95d4c2d885179ab7ce082b214ca
INCOMPLETE — 1 receipt(s) verified, but no terminal commitment is available, so tail truncation cannot be ruled out.
Chain head: 0:526ba45c4d925e41bb7845bc2910150a2994e9367cc6537298adac7d074b4c3a
Verify the run directory (with its run.json), or pin the head with --expect-head <sequence>:<hash> or --pinned-head; pass --allow-no-terminal-commitment to accept a legacy record without one.

--allow-no-terminal-commitment accepts a record that has no terminal commitment: OK — verified N receipt(s). with exit 0 and a warning. When --expect-head alone binds the tail, a successful verify prints Chain ends exactly at the pinned head — tail truncation ruled out.

Success:

$ writ verify runs/vendor-dossier-... --pubkey 93178da572906641b34888d269d5ed2eefab89ba4202c729fa3f8d9f6a579e4c --signer-mode dev-ephemeral
WARNING: this work record is signed with a dev-ephemeral (throwaway) key — it is NOT production evidence.
OK — verified 3 receipt(s).
Chain head: 2:488827ea923b46b63824c23404de16fdf3bd02f830b7432c1ceee52794672ba2
Terminal commitment verified — this export cannot be truncated undetected.
WARNING: no signer identity record — the chain is not bound to a named operator (pass --require-identity to fail instead).

Wrong public key, on the key-signed run:

FAILED — 3 problem(s) across 1 receipt(s):
[row 0] 5fab3d822eb24a29a5d95e21375e94d1: signature verification failed
the run summary's terminal commitment signature does not verify under the supplied public key — refusing to trust it (the run summary may have been tampered with).
the signer identity record describes key 48d196ae736139f2 (1f9a25988803ebda461fc30b4e29f9149b94b95d4c2d885179ab7ce082b214ca), which is not the --pubkey you pinned and is not reachable from it: key 48d196ae736139f2 is not reachable from the trusted anchor 66687aadf862bd77: no rotation record continues from key 66687aadf862bd77. — the record does not belong to a key you trust.

Exit 5.

--require-identity on a chain with no identity record:

WARNING: this work record is signed with a dev-ephemeral (throwaway) key — it is NOT production evidence.
FAILED — 1 problem(s) across 3 receipt(s):
--require-identity: no signer identity record was found and the chain is not bound to one.

Exit 5.

Tampered receipt field:

FAILED — 1 problem(s) across 1 receipt(s):
[row 0] 5fab3d822eb24a29a5d95e21375e94d1: receiptHash does not match the recomputed canonical hash (tampered field)

Exit 5.

More on --require-identity, --rotations, --revocations, --pinned-head, --expect-head, and what each shows: Keys and verification.

Help for each command​

writ --help lists the commands and the global options, and writ <command> --help (for example writ record publish-head --help) prints that command's arguments and every option with its description. The installed tool is the reference for its own help text; the synopses and option tables above summarize it.