Commands
The cairn CLI surface beyond the core run/spec/authoring commands. Each page below documents one command family — flags, flow, and when to reach for it. Every command supports --format json|yaml|md and has a stable JSON schema; no interactive prompts on --json/--yaml paths.
A command-line usage error (an unknown flag or command, a missing option value or required argument) exits 2, on every command, and never 1, which means a failed outcome: a typo cannot read as a red test. --help and --version exit 0. See the exit-code table in the README.
Maintenance
- Doctor & clean —
cairn doctorprobes the environment;cairn cleanprunes old run directories.
Page inspection
- Discover & snapshot —
cairn discover/cairn snapshotreturn the accessibility tree and locator inventory for a live page.cairn discovercan start from a setup (--use,--from-spec) and leaves a session journal;cairn discover sessionslists journals andcairn discover export --from-sessionwrites a spec from one. - Journey briefs —
cairn export briefcompiles a spec into operator instructions for a fragile environment; MCPcairn_accompany_*is the live try-then-ask loop.
Authoring
- Project catalog —
cairn catalog --querylists the actions, vars, verifiers, environments, flows and checkpoints a project already has. - Author a spec from a request — the recipe from a few sentences to a promoted spec;
cairn init agent-kitwrites a short version into yourAGENTS.md. - Lint, finish, promote —
cairn spec lint [--fix]gives fix-its before a run,cairn spec finishlints + runs cold + stamps when green,cairn spec promotemoves a green draft out offlows/_drafts.
Sessions
- Checkpoints & login —
cairn logincaptures a session by hand;cairn checkpointmanages resumable checkpoints. Captures record their scope (--envbaseUrl,--ttl),checkpoint list --jsonshows each one's health, and a run refuses an expired or other-origin checkpoint.
Evidence
- Stash —
cairn stashpersists run packs in the local file.cheap vault for retention-safe search. - Clip —
cairn clipcuts named clips from a run video via vidtrace. - Process monitoring —
--monitorsamples the browser process tree; themonitorstep andprocessverifier assert on it. - Stats —
cairn stats --group-by <label-key>aggregates labeled runs (cairn run --label key=value) into A/B cohorts (--labelfilters,--invocation <id>keeps onecairn run's runs) with pass rate, duration percentiles, optional domain metrics fromoutcomes/*.raw.json, and ASCII charts in markdown. Pair with--beforehooks for domain path flips before a suite.--repeat/--matrixrun many labeled iterations in one command, and--afterhooks can dropdiagnostics/report.jsonwhose numeric fields feedcairn stats --metric; the configmetrics:probes write the same keys (<name>.delta) without a script.
Failure → code
- Investigate & audit —
cairn investigatestashes an existing run for optional code search;cairn auditrecords a Playwright video and uses file.cheap/vecgrep only when stash or connection is requested. - Annotate —
cairn annotatepins cairntrace findings to codemap symbols;--auto-annotatedoes it per run.
Environment
- Secrets —
cairn secretschecks the TinyVault secrets provider. - Config composition — top-level
vars,environments.<n>.extends, vars that reference vars,include:andenvironments.<n>.include(per-environment var files) keep a value in one place;cairn config vars [--env] [--unused] [--used-by <spec>]shows where each var is defined, its value per environment and what reads it, andcairn config validatereports composition errors, dead vars and include overrides. - Services —
cairn services statusand the config-driven docker/seed/tmux lifecycle (top-level, or declared per environment);cairn services up/downkeep the stack running between runs under an owner lock, andcairn run --reuse-servicesruns against it.services up/down/restartrefuse (exit 4) while a livecairn runholds the config'srun.lock.cairn run --services-dry-runprints the whole plan without running anything. - Service operations —
cairn services restart <window...>(Ctrl-C, wait for the exit, resend the command, wait for the new generation'sreadyOn; refuses windows the config does not own) andcairn services logs <window> [--since-restart] [--wait <regex>] [--follow]; tmux windows'restartpolicy andhealthcheck.onUnhealthyare supervised during a run;services.tunnels,services.provisioner(up/down/exports, always torn down, a faileddownis exit 8) andservices.files(atomic validated writes). There is noservices exec, on purpose. - Seed transaction —
services.seed.phases,commit: afterPostCommands, objectpostCommands(when,continueOnError,timeout) andexpectOutputfor a seed that prints an error but exits 0. - Engine pin — config
requires: { cairntrace: <range> }(exit 4 on an older cairn) andruntimes.node/CAIRN_NODE;cairn doctor [--config <path>]reports both. - Run policy — the config
run:block (lock,preflight,verifyClean,finally) andservices.teardownentries withcritical: truemake a barecairn runsafe: exit 4 for a refusal before anything starts, exit 8 when a critical teardown failed, exit 9 for a dirty machine after the run. A preflight check'swhen: { suite, env }limits it to some suites.cairn run --bailskips the remaining specs after the first failure (--no-bailoverrides a suite'sbail);cairn docs run-policymaps a wrapper script's jobs to config;cairn doctor --orphans [--kill]lists and ends cairn-owned browser survivors. - Suites — the config
suites:registry:cairn run --suite <name> --env <env>runs a named, ordered spec set with the environment's vars,processEnv(exported to every process of the run),labels(stamped on every run), once-per-run before/after hooks,parallel,bailand seed skips (per environment too);cairn suites listshows the specs each suite resolves to per environment. - Metrics — the config
metrics:probes (command + parse, or http + json path) sampled around each spec or iteration intodiagnostics/metrics.jsonanddiagnostics/report.json, ready forcairn stats --metric <name>.delta. - Delegated runners —
environments.<n>.runner: { command, cwd?, env?, timeoutMs?, idleTimeoutMs?, cancelGraceMs? }hands acairn run --env <n>to a command that runs it on another machine (contracturn:cairntrace.dev:delegate:v1) while the local process keeps the journal, the run directories, the exit code and Ctrl-C / Studio Stop. On the remote side,cairn logs --invocation <id|label:cairn.delegate=<id>> --follow --relay [--wait-timeout 10m]prints the events stream the runner pipes back. The runner's exit code is checked against that stream and the copied run directories. - Fixtures —
cairn fixtures list | status | ensure | reset | teardown | sweepdrive the configfixtures:registry (exec / mongo / http test data) outside a run;cairn run --allow-fixture-writeslets fixtures write on a shared or protected environment (never underpolicy.mutations: deny).
The core commands
The run/spec/authoring surface is documented elsewhere and is not duplicated here:
- Quickstart —
cairn run, first spec. - Authoring — tags, labels,
--before/--afterhooks,cairn stats. - Steps / Verifiers — the typed vocabularies.
- Snippets —
imports:/use:. - MCP —
cairn mcpand thecairn_*tool family.
Run cairn explain --format json (or MCP cairn_explain) for the machine-readable current surface, including every flag.
See also
- Overview — what cairntrace is
- Configuration — config keys the commands read
- Troubleshooting — common command failure modes