CLI Reference
CLI Reference
Section titled “CLI Reference”ContextBrew provides a CLI with three command aliases: ctxbrew (brand alias, used in these docs), ctx (power shortcut), and contextbrew (the npm binary name). All three are interchangeable.
Every command below is real and verified against ctxbrew --help. A
docs-CLI conformance checker (scripts/check-docs-cli-conformance.ts)
runs in CI and fails on NEW references to commands that do not exist —
a baselined ratchet, so this page keeps tracking the real CLI as it
grows.
Global Options
Section titled “Global Options”| Option | Description |
|---|---|
--version |
Print the installed version |
-h, --help |
Show help for any command |
Project Commands
Section titled “Project Commands”ctxbrew init
Section titled “ctxbrew init”Create a new ContextBrew project in the current directory.
ctxbrew init --name my-projectctxbrew init --name my-project --type web-appctxbrew init --name my-project --no-prompt # non-interactivectxbrew init --from-code . # hypothesis DDD spec from existing TS sourcectxbrew init --promote hypothesis.requirements # flip a hypothesis file to authoritativectxbrew init --name my-project --dry-run # preview, write nothingctxbrew init --name my-project --force # allow re-init over an existing projectctxbrew init --name my-project --root ~/code/api # target a directory you're not standing in| Flag | Description |
|---|---|
--name <name> |
Project name (required) |
--type <type> |
empty, web-app, enterprise, microservices, realtime, data-centric, mobile, free, agentic, api-service, desktop-app, ml-pipeline, influx |
--no-prompt |
Skip interactive prompts |
--dry-run |
Print what init would create, write nothing |
--force |
Allow re-init over an existing .contextbrew/project.yaml (rewrites the config) |
--root <path> |
Project root to initialize (default: the current directory) |
--from-code [path] |
Generate a hypothesis spec from existing source code |
--promote <file> |
Promote a hypothesis CBRL file to authoritative status |
This creates .contextbrew/ with project.yaml, state.json, and a folder
per model family (ddd/, cbrl/, usm/, scm/, dsm/, esdm/), plus
generated/, recipes/, and knowledge/.
ctxbrew project
Section titled “ctxbrew project”Project the model canon into plain markdown so any agent (or human) can read project state with zero ContextBrew runtime — one question maps to one file, generated truthfully from the typed models:
ctxbrew project # all four, at the project rootctxbrew project --only goal # just GOAL.md (repeatable flag)ctxbrew project --check # CI: exit 1 when any file is stalectxbrew project --out docs/generated| File | Question it answers |
|---|---|
GOAL.md |
What do I do now? |
CONTEXT.md |
What is this project? |
ROADMAP.md |
Where am I in the big picture? |
CHECKPOINT.md |
Where did the last session leave off? |
Guard: a target file that was not ContextBrew-generated (no
ctxbrew:generated stamp) is refused — a hand-written GOAL.md is
never clobbered without --force. Each file carries a provenance
address (projection:<target>:<hash8>) resolvable with ctxbrew why.
Under ctxbrew watch, every brew cycle refreshes the projections
automatically.
ctxbrew scan [<path>]
Section titled “ctxbrew scan [<path>]”Read-only repository preview — see what ContextBrew extracts before
creating anything. Writes nothing inside the target (the guarantee, not a
courtesy): extraction runs in memory, no .contextbrew/ is created.
ctxbrew scan . # scan the current directoryctxbrew scan . --json # machine-readable reportctxbrew scan . --out ../report.jsonctxbrew scan . --lang ts # extraction is TypeScript/TSX only today, honestlyExit codes: 0 report produced · 1 nothing extractable · 2 operational
error or usage refusal. Promote a scan into a real project with ctxbrew init --from-code.
ctxbrew status
Section titled “ctxbrew status”Show project completeness metrics.
ctxbrew detect-stack · ctxbrew export-stack
Section titled “ctxbrew detect-stack · ctxbrew export-stack”Auto-detect the tech stack from project files (writes project.yaml) and
export stack context for AI coding tools.
Brownfield import
Section titled “Brownfield import”ctxbrew import-js . # topic-map knowledge graph + readable digestctxbrew import-js --list-clusters # review suggested bounded contextsctxbrew import-js --promote-cluster <id> # emit BoundedContextMap candidatesctxbrew import-js --export-models all # map to context-map / DDD / SIM exportsctxbrew init-from-code . # hypothesis DDD spec from TS sourcectxbrew import-spec-kit # import from GitHub Spec Kit layoutsctxbrew import-bmad # import from BMAD method outputctxbrew import-structurizr # import Structurizr workspacectxbrew db pull --dialect postgres # live Postgres catalog → DSM modelctxbrew db pull
Section titled “ctxbrew db pull”Pull a live Postgres schema into a DSM model file (default ./dsm.json).
The connection string is read from the DATABASE_URL environment
variable ONLY — never a flag, never printed, never logged.
DATABASE_URL=postgres://user:pass@host:5432/db ctxbrew db pull --dialect postgresctxbrew db pull --dialect postgres --schema public --out dsm.json --dry-runctxbrew db pull --dialect postgres --from-json catalog.json # offline: same pipeline on a captured catalog| Flag | Description |
|---|---|
--dialect <name> |
Source database dialect (v1: postgres) |
--out <file> |
Output DSM file (default ./dsm.json) |
--schema <name> |
Postgres schema to capture (default public) |
--from-json <file> |
Run the pipeline on a captured catalog JSON instead of a live connection |
--dry-run |
Pull and validate but do not write the output file |
--force |
Write the model even when validation reports errors |
--json |
Emit a machine-readable summary on stdout |
Authoring Models
Section titled “Authoring Models”Models are authored as plain text files under .contextbrew/<family>/
(for example .contextbrew/ddd/order.domain) or on the visual canvases in
the Studio. There is no single model meta-command — each format has
its own command family with five verbs:
ctx ddd validate <file> # parse + validate; exit 1 on any errorctx ddd export <file> # canonical DSL (default) or JSONctx ddd import <file> # canonicalization passctx ddd stats <file> # top-level collection sizesctx ddd diff <before> <after> # semantic diff (report only — exit 0 regardless)export also converts through registered framework exporters — other
tools’ native formats, driven by the same command:
ctx scm export screen.scm.json --to scm/mermaid-flowchart-outctx ddd export order.domain --list-exporters # enumerate exporters for a format--to <exporterId> picks its own output format, so --to and
--format are mutually exclusive.
The same five verbs are registered for ddd, usm, cbrl, scm,
dsm, sim, absl, c4, context-map, and esdm (acm is
deliberately not registered — it has its own ctxbrew acm command).
Two formats carry extra verbs:
ctx cbrl check <files...> --baseline cbrl-baseline.json# validation-only CI gate: exit 1 on NEW error findings vs the baseline# (warnings never gate). Flags: --update-baseline, --ddd <files...># (aggregates become the cross-link source of truth), --format text|json
ctx cbrl publish <files...> --out cbrl-spec-pack# self-contained HTML spec pack: table of contents, requirement matrix,# search, print stylesheet. Flags: --out <dir>, --title <t>, --format html
ctx scm discover ./src --out scm.json# discover screens + navigations from route-file conventions# (Next.js App Router, Expo Router, React Router). Flags:# -f/--framework next|expo|react-router|auto, --drift-vs <scm.json>,# --report-out <file>, --fail-on-drift (exit 1 on drift findings), --jsonNew to a project and not sure who your users are? The USM persona starter library ships ten archetypes:
ctxbrew personas list # list every persona archetypectxbrew personas seed # dry-run seed into a fresh registryEvery format has a committed JSON Schema: run ctxbrew schema ddd
(below) to print it, or see File Schemas.
Generate
Section titled “Generate”ctxbrew generate # all targets, from .contextbrew/cbrl/ + .contextbrew/ddd/ctxbrew generate --target vitest # failing-first unit tests (scaffold stubs fail by design)ctxbrew generate --target gherkin # Gherkin scenarios from CBRL acceptance criteriactxbrew generate --target openapi # OpenAPI from SCM/DSMctxbrew generate --target prompts # agent-ready prompt packsctxbrew generate --target semgrep # security rulesctxbrew generate --target eslint # quality rulesctxbrew generate --target ci # CI pipeline artifactsctxbrew generate --aggregate Order # one aggregate only| Flag | Description |
|---|---|
--target <t> |
gherkin, vitest, openapi, prompts, semgrep, eslint, ci, all (default all) |
--aggregate <name> |
Filter to a single aggregate |
Outputs land in .contextbrew/generated/<target>/. Generated tests are
fail-closed scaffolds — they fail until a real implementation makes them
pass. That is the point: a test that passes on an empty implementation proves
nothing about your spec.
Verification Commands
Section titled “Verification Commands”ctxbrew lint # spec-closure lint: parse + cross-model + coverage (--json, --gate, --strict, --max-findings, --report)ctxbrew lint-esdm # ESDM-specific lintctxbrew check # spec validators + evidence fingerprints + ledger staleness # + CBT drift + churn freshness → one auditable drift scorectxbrew check --gate # CI mode: exit 1 when a signal failsctxbrew stale # staleness listing (--gate, --max-age-days, --json)ctxbrew cbt verify # constraint-behavior-test drift registryctxbrew acm matrix # access-control matrix and coveragectxbrew acm audit-log # who changed which rule, newest firstctxbrew acm check-coverage # exit 1 if any screen has no rulectxbrew acm generate <projectId> # regenerate projections via the Studio APIctxbrew acm export-policy --file models/acm.json --target opa # file-based: cerbos|opa|cedar (--out writes to a file)ctxbrew validate-consistency # cross-model consistencyctxbrew why # explain a spec decisionctxbrew verify <file>
Section titled “ctxbrew verify <file>”Verifies the Ed25519 signature and content hash of a signed recipe export
(produced by ctxbrew recipe export --format signed-json). This is artifact
integrity verification — it is not a test runner. Exit 0 valid / 1 invalid.
ctxbrew score
Section titled “ctxbrew score”ctxbrew score --cmbf . # Layer-1 CMBF: AST-level model↔code alignmentctxbrew score --semantic-debt . # governed-term compliance + name driftctxbrew score --composed . # three-pillar completeness scoreExactly one mode flag required.
ctxbrew cmbf score [path]
Section titled “ctxbrew cmbf score [path]”The ContextBrew Moat Framework score — four deterministic instruments
(drift score, completeness ratio, coverage closure, gate pass rate).
Missing inputs warn, never throw; exit is always 0.
ctxbrew cmbf score . --format md # human-readable report (default)ctxbrew cmbf score . --format json # deterministic machine output| Flag | Description |
|---|---|
--format <fmt> |
json (deterministic) or md (default md) |
--drift-signals <file> |
DriftScoreInput JSON (default <path>/.contextbrew/cmbf/drift-signals.json) |
--gate-reports <file> |
DriftReport[] JSON (default <path>/.contextbrew/cmbf/gate-reports.json) |
Release Gates & Governance
Section titled “Release Gates & Governance”ctxbrew gate
Section titled “ctxbrew gate”Runs the five release-gate checks and — with --evidence — produces a
hash-chained evidence bundle plus a PR/MR receipt. Exit 0 pass,
1 fail (including the case where every check came back
not-implemented — a gate never passes on no signal), 2 operational
error.
ctxbrew gate # all five checksctxbrew gate -t schema_evolution_safe # a subset of gate typesctxbrew gate --evidence --receipt md # bundle + markdown receiptctxbrew gate --receipt-out receipt.md --emit-ci github| Flag | Description |
|---|---|
-p, --project <dir> |
Project root (the .contextbrew tree to read) (default .) |
-t, --gate-type <id...> |
Restrict to gate type id(s) — see Release Gates for the five ids |
--evidence |
Write the hash-chained evidence bundle to .contextbrew/evidence/<ts>.json |
--receipt [format] |
Render the receipt (format: md) |
--receipt-out <file> |
Write the receipt to a file instead of stdout (implies --receipt md) |
--observed-calls <file> |
ObservedContractCall[] JSON (drift_resolved observed side) |
--esdm-baseline <file> |
Baseline ESDM model (schema_evolution_safe before-side) |
--eval-suites <dir> |
Directory of generated eval suites (*.test.ts) |
--emit-ci <target> |
Also write the CI receipt publisher: github | gitlab | both |
In CI, exit 1 blocks the build. The gate types, what each one proves,
and the fail-closed / honest-not-implemented semantics are documented
on Release Gates.
ctxbrew evidence verify <bundle>
Section titled “ctxbrew evidence verify <bundle>”Verifies a gate-evidence bundle’s hash chain — tamper detection for the
artifact ctxbrew gate --evidence writes. Each check result is
hash-chained to the previous one (genesis: the bundle manifest’s own
hash), so any edit to a recorded verdict breaks the chain. Exit 0
chain intact / 1 tamper detected.
ctxbrew evolution check <before> <after>
Section titled “ctxbrew evolution check <before> <after>”Schema-evolution compatibility check for .requirements, .dsm, .sim, and
.absl files (DSL or serialized JSON). The verdict comes from the
schema_evolution_safe gate under a versioning policy.
ctxbrew evolution check old.requirements new.requirements --policy semver --format md| Flag | Description |
|---|---|
--policy <id> |
Override: semver | calver | immutable (a declared policy in the models loses to this flag) |
--format <fmt> |
text | json | md (default text) |
Exit 0 pass, 1 fail-or-not-implemented, 2 operational error.
Policy semantics are documented on Release Gates.
ctxbrew observe k8s
Section titled “ctxbrew observe k8s”Captures Kubernetes deployments/services/ingresses via kubectl and
diffs the observed cluster state against the declared C4/SIM models
(findings: missing-in-cluster, undeclared-workload, replica-mismatch).
ctxbrew observe k8s --c4 models/c4.json --sim models/sim.jsonctxbrew observe k8s --from-json snapshot.json --json # offline pathctxbrew observe k8s --gate # CI: exit 1 on error findings| Flag | Description |
|---|---|
--kubeconfig <path> |
Kubeconfig file (passed to kubectl) |
-n, --namespace <name> |
Cluster namespace (default: kubectl context default) |
--context <name> |
kubectl context to use |
--from-json <file> |
Read a captured observed document instead of invoking kubectl |
--c4 <file> |
Declared C4 model file (deployment view source) |
--sim <file> |
Declared SIM model file (service/contract source) |
--json |
Emit machine-readable JSON (observed + report + gate) |
--gate |
Gate mode: exit 1 on error-severity findings |
Recipes
Section titled “Recipes”ctxbrew recipe create --aggregate Order # .contextbrew/recipes/recipe-001.{json,md}ctxbrew recipe listctxbrew recipe execute <id> [--agent claude-code] [--run] [--watch]ctxbrew recipe status <id>ctxbrew recipe report <id> [--output <file>]ctxbrew recipe assign <id> --agent <type>ctxbrew recipe export [--recipe <id>] [--format <fmt>] [--output <file>] [--strategy test-first]Export formats: markdown, json, claude-mdc, cursorrule, copilot,
plain-text, signed-json, ctxbrew, skill-md, skill-md-bundle. Signed exports are
verified with ctxbrew verify.
Agent anchor files
Section titled “Agent anchor files”ctxbrew recipe claude-md [--sections <list>] [--stdout] # CLAUDE.mdctxbrew recipe agents-md [--stdout] # AGENTS.mdctxbrew recipe cursor-rules [--stdout] # .cursor/rulesctxbrew recipe copilot-instructions [--stdout] # .github/copilot-instructions.mdRecipe Server (version control)
Section titled “Recipe Server (version control)”Recipe Server commands operate on a remote recipe repo (--repo-id <id>,
created by recipe init --project-id <id> --name <name>):
ctxbrew recipe init --project-id <uuid> --name mainctxbrew recipe push --repo-id <id> --message <msg> --recipe-id <rid>ctxbrew recipe log --repo-id <id> [--branch main] [--oneline]ctxbrew recipe branch list <repo-id>ctxbrew recipe branch create <repo-id> --name <branch> --commit <hash>ctxbrew recipe tag create <repo-id> --name v1 --commit <hash>ctxbrew recipe merge <repo-id> --source <branch> --target <main> [--strategy <s>]ctxbrew recipe diff --repo-id <id> --from <hash> --to <hash>ctxbrew recipe sync --repo-id <id> [--direction push|pull|both] [--dry-run]Execution Engine
Section titled “Execution Engine”ctxbrew generation create # start a hosted generation runctxbrew generation list # runs + costsctxbrew generation show <id>ctxbrew generation stream <id>ctxbrew generation cancel <id> | retry <id> | download <id>ctxbrew compare create | list | show | verdict # side-by-side output comparisonctxbrew provider list | show | models | update | healthctxbrew orchestrate next # RDOS-aware next-work orchestrationNative Review & Repair (visual context v2)
Section titled “Native Review & Repair (visual context v2)”The agent-side accountability surface over a connected Studio origin:
inspect a native object, submit review and repair intents, reconcile
receipts by their ORIGINAL command id. Inspection is credential-free; every
write is forwarded unchanged and the service’s strict parser is the only
gate. A NATIVE-SAVE receipt is never a definition-review approval, and
unknown never means “resubmit”.
ctxbrew review inspect --origin <studio> --project <uuid> --artifact <uuid> \ --model ddd --kind aggregate --id <local-id> [--json] # emit the inspection filectxbrew review links --inspection <file> # typed representation links (no network)ctxbrew review submit --origin <studio> --inspection <file> \ --decision approve|needs_work [--reason-stdin] # expectations travel unchangedctxbrew review revoke --origin <studio> --inspection <file> \ --decision-id <uuid> [--reason-stdin] # revoke the active recorded decisionctxbrew review command-status --origin <studio> --command-id <uuid> # read a review receiptctxbrew review repair --origin <studio> --file <intent.json> \ [--project <uuid>] # one strict native repair intent (add_back_action)ctxbrew review repair-status --origin <studio> --command-id <uuid> # reconcile a repair by its ORIGINAL idctxbrew review workflow-context --origin <studio> --project <uuid> \ --target-type <type> --target-id <id> --actor <actor-id> \ --purpose repair|review # runtime context of one workflow targetctxbrew review workflow-run --origin <studio> --project <uuid> \ --operation <operation> --action <action> --target-kind <kind> \ --target-id <id> --expected-target-version <n> --expected-revision <rev>The headless code-transition surface (VOIT) rides the same discipline — frozen plans and a durable journal, no effects on reads:
ctxbrew transition targets # registered implementation targetsctxbrew transition adoption # evidence-backed adoption assertions (append-only)ctxbrew transition prepare # owned isolated candidate + frozen source-move planctxbrew transition apply # execute a FROZEN plan (E10 readiness gate)ctxbrew transition journal status --run <runId> # known-unknown steps + next actionctxbrew transition journal reconcile --run <runId> # reconcile interrupted steps against ACTUAL stateMCP Server
Section titled “MCP Server”ctxbrew mcp setup --agent claude-code # or: cursor | windsurf | codex | orca | genericctxbrew mcp serve # stdio serverSee MCP for the 75 tools the server exposes — including
the author tool (five authoring verbs: specify for a USM story,
aggregate for DDD, screen for SCM, table for DSM, rule for ACM),
the per-format *_update_node write tools, and the native review & repair
family (submit_object_review, submit_native_repair, …).
Memory & Decisions
Section titled “Memory & Decisions”ctxbrew log "chose Redis over Kafka — p99 latency" # one-line decision capturectxbrew timeline # the memory, read back in orderctxbrew decisions # .dec text projectionctxbrew ingest-decisions # ingest decision recordsSchema
Section titled “Schema”Print the normative JSON Schema of any ContextBrew file format — the same schemas documented in File Schemas.
ctxbrew schema # list every format (id, version, summary)ctxbrew schema ddd # print the ddd schema JSONctxbrew schema ddd -o ddd.schema.jsonctxbrew schema --all # every schema as one JSON documentNext Steps
Section titled “Next Steps”- Quick Start — the five-minute loop
- CBRL Syntax for the requirements language grammar
- API Reference for the HTTP API
