updated 2026-11-26·6 min read
Command Line Interface (CLI) Reference
Systems reference for the Stokes CLI: subcommands, flags, POSIX exit codes, CI environment variables, and ANSI terminal rendering.
stokes wraps contract checks, AST diffing, Dual-Zone buffer synthesis, and CI gating in one CLI (curl -fsSL https://trystokes.pages.dev/install.sh | sh). Its subcommands split into three groups: pipeline gates (verify, check, cert, scan, stage-check, bench), synthesis and topology tools (codegen, diff, graph, init), and agent bridges (mcp, audit, remediate).

Global Options & Environment Variables
| Option | Shorthand | Type | Description |
|---|---|---|---|
--version | -V | Flag | Print Stokes engine version and target architecture. |
--help | -h | Flag | Print context-sensitive subcommand help and flags. |
export STOKES_STRICT=1 # Exit 1 on any contract warning or drift
export STOKES_LOCKFILE_PATH=/etc/stokes/prod.lock
export STOKES_NO_COLOR=1 # Disable VT-100 ANSI sequences
export CI=true # Auto-disable interactive animations
export STOKES_AGENT=bob # Preferred remediation agent backend
export STOKES_WORKSPACE=/workspace # Base root for poly-repo evaluation
export STOKES_LOG_LEVEL=info # trace | debug | info | warn | error
Terminal Rendering Engine & Exit Codes
Stokes renders straight to VT-100 escape sequences (\033[<N>A multi-line cursor overwrite, 16.6 ms 60 FPS bracketless loaders, Unicode tree connectors, and ANSI unified diffs). On Windows (win32), it turns on ENABLE_VIRTUAL_TERMINAL_PROCESSING and UTF-8 streams on startup.
| Exit Code | Classification | Semantics | Recommended CI Action |
|---|---|---|---|
0 | Success / Compliant | Emitted columns fit downstream capacity and digests match stokes.lock. | Allow PR merge. |
1 | Contract Breach / Drift | Peak Risk Ratio > 1.0, unhandled .unwrap(), or lockfile mismatch. | Block PR merge and dispatch remediation. |
2 | Configuration Error | Missing stokes.toml, missing stokes.lock, or invalid arguments in --strict mode. | Run stokes init or stokes scan. |
3 | Internal Error | System I/O error or unhandled parser fault. | Inspect logs with STOKES_LOG_LEVEL=debug. |
130 | Interrupted | Received SIGINT (Ctrl+C) or timed out. | Abort pipeline step. |
Subcommand Reference
stokes verify
Primary CI gate executing AST parsing, Cardinality Risk evaluation, 10,000-case IEEE-754 float fuzzing, and Criterion checks:
stokes verify [PATH] [OPTIONS]
| Option | Type | Default | Description |
|---|---|---|---|
PATH | Positional | . | Target workspace path. |
--strict | Boolean | true | Exit 1 on any invariant breach, unwrap, or digest mismatch. |
--consumer PATH | String | None | Downstream consumer repo path for poly-repo checks. |
--producer PATH | String | None | Upstream producer repo path for poly-repo checks. |
--lockfile PATH | String | stokes.lock | Lockfile path for AST digest verification. |
--format FORMAT | String | ansi | ansi, json, or junit. |
stokes verify --strict
stokes verify --consumer=../edge-proxy-service --producer=../analytics-pipeline --strict
stokes verify --format=json > verification-report.json
stokes codegen
Synthesizes Dual-Zone 128 + 72 stack partitioning (ingest_descriptors_dual_zone) into Rust or C++ consumer AST boundaries:
stokes codegen [PATH] [--consumer PATH] [--write] [--export-patch]
Synthesized Dual-Zone Partitioning Output (Rust)
pub const CORE_RESERVED_SLOTS: usize = 128;
pub const ADAPTIVE_SLOTS: usize = 72;
pub const MAX_ACTIVE_FEATURES: usize = CORE_RESERVED_SLOTS + ADAPTIVE_SLOTS;
#[repr(C, align(8))]
#[derive(Clone, Copy, Debug)]
pub struct FeatureDescriptor {
pub id: u32,
pub priority: u8,
pub is_shadow: bool,
pub _pad: [u8; 2],
}
#[inline(always)]
pub fn ingest_descriptors_dual_zone(
source: &mut [FeatureDescriptor],
out: &mut [FeatureDescriptor; MAX_ACTIVE_FEATURES],
) -> usize {
let mut core_count = 0;
for i in 0..source.len() {
if source[i].priority >= 200 && core_count < CORE_RESERVED_SLOTS {
source.swap(core_count, i);
core_count += 1;
}
}
let remaining = MAX_ACTIVE_FEATURES - core_count;
let adaptive = &mut source[core_count..];
if adaptive.len() > remaining {
adaptive.select_nth_unstable_by(remaining, |a, b| b.priority.cmp(&a.priority));
}
let take = source.len().min(MAX_ACTIVE_FEATURES);
out[..take].copy_from_slice(&source[..take]);
take
}stokes mcp
Launches the native JSON-RPC 2.0 MCP server (2024-11-05) over stdio for Cursor, Claude Code, Windsurf, and IBM Bob 2.0. See MCP Protocol Specification.
stokes diff
Computes normalized semantic AST contract diffs across git revisions, ignoring comments and formatting:
stokes diff [REVISION_A] [REVISION_B] [--path PATH] [--stat]
stokes diff origin/main HEAD
stokes diff v1.4.0 v1.5.0 --stat
stokes graph
Emits the directed reachability graph in dot, json, or svg format (--direction lr|td, --output FILE):
stokes graph --format=dot
stokes graph --format=svg --output=docs/boundary-graph.svg
stokes graph --format=json | jq '.edges[] | select(.risk_ratio > 1.0)'
stokes init & stokes scan
stokes init [PATH] [--force]: Scaffoldsstokes.tomland an initialstokes.lock.stokes scan [PATH] [--generate-contract]: Crawls workspace boundaries, updatesstokes.toml, and optionally emitsAGENTS.md.
stokes audit, stokes check, stokes remediate, stokes cert, stokes stage-check, stokes bench
| Command | Usage | Purpose |
|---|---|---|
stokes audit | stokes audit [PATH] [--diff] [--strict] [--agent ...] [--with-bob] [--export-patch] | Dispatches parallel subagents (claude, bob, aider, goose, openhands, generic, patch) and proposes Dual-Zone diffs. |
stokes check | stokes check [PATH] [--consumer PATH] [--producer PATH] [--strict] | Enforces Consumer Expands First across poly-repo PRs in a single static pass. |
stokes remediate | stokes remediate [PATH] [--agent AGENT] [--with-bob] [--export-patch] | Dispatches AST drift constraints and risk ratios to AI agents for repair. |
stokes cert | stokes cert [--output FILE] [PATH] | Computes normalized SHA-256 digests and writes stokes.lock and CONFORMANCE.md. |
stokes stage-check | stokes stage-check [--hook] [--quiet] | Scans git-staged boundary files locally as a pre-commit hook. |
stokes bench | stokes bench [--max-p99-ns=10.0] [--max-heap-bytes=0] | Parses Criterion benchmarks and enforces the 10.0 ns / 0 B heap budget. |
GitHub Actions Verification & Lockfile Integrity Workflow
name: Stokes Boundary Gate
on:
pull_request:
branches: [main, master]
push:
branches: [main, master]
jobs:
verify-contracts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- run: curl -fsSL https://trystokes.pages.dev/install.sh | sh
- name: Run Deterministic Boundary Verification
env:
STOKES_STRICT: "1"
CI: "true"
run: stokes verify --strict --format=ansi
- name: Verify Stokes Lockfile Integrity
run: |
stokes cert --output=stokes.lock.ci
diff -u stokes.lock stokes.lock.ciContinue to CLI Terminal Workflow & Gate Matrix for interactive stokes audit --diff sessions and pre-commit workflows, or Lockfile Specification for stokes.lock internals.