Skip to content

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.

Option Description
--version Print the installed version
-h, --help Show help for any command

Create a new ContextBrew project in the current directory.

Terminal window
ctxbrew init --name my-project
ctxbrew init --name my-project --type web-app
ctxbrew init --name my-project --no-prompt # non-interactive
ctxbrew init --from-code . # hypothesis DDD spec from existing TS source
ctxbrew init --promote hypothesis.requirements # flip a hypothesis file to authoritative
ctxbrew init --name my-project --dry-run # preview, write nothing
ctxbrew init --name my-project --force # allow re-init over an existing project
ctxbrew 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/.

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:

Terminal window
ctxbrew project # all four, at the project root
ctxbrew project --only goal # just GOAL.md (repeatable flag)
ctxbrew project --check # CI: exit 1 when any file is stale
ctxbrew 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.

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.

Terminal window
ctxbrew scan . # scan the current directory
ctxbrew scan . --json # machine-readable report
ctxbrew scan . --out ../report.json
ctxbrew scan . --lang ts # extraction is TypeScript/TSX only today, honestly

Exit 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.

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.

Terminal window
ctxbrew import-js . # topic-map knowledge graph + readable digest
ctxbrew import-js --list-clusters # review suggested bounded contexts
ctxbrew import-js --promote-cluster <id> # emit BoundedContextMap candidates
ctxbrew import-js --export-models all # map to context-map / DDD / SIM exports
ctxbrew init-from-code . # hypothesis DDD spec from TS source
ctxbrew import-spec-kit # import from GitHub Spec Kit layouts
ctxbrew import-bmad # import from BMAD method output
ctxbrew import-structurizr # import Structurizr workspace
ctxbrew db pull --dialect postgres # live Postgres catalog → DSM model

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.

Terminal window
DATABASE_URL=postgres://user:pass@host:5432/db ctxbrew db pull --dialect postgres
ctxbrew db pull --dialect postgres --schema public --out dsm.json --dry-run
ctxbrew 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

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:

Terminal window
ctx ddd validate <file> # parse + validate; exit 1 on any error
ctx ddd export <file> # canonical DSL (default) or JSON
ctx ddd import <file> # canonicalization pass
ctx ddd stats <file> # top-level collection sizes
ctx 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:

Terminal window
ctx scm export screen.scm.json --to scm/mermaid-flowchart-out
ctx 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:

Terminal window
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), --json

New to a project and not sure who your users are? The USM persona starter library ships ten archetypes:

Terminal window
ctxbrew personas list # list every persona archetype
ctxbrew personas seed # dry-run seed into a fresh registry

Every format has a committed JSON Schema: run ctxbrew schema ddd (below) to print it, or see File Schemas.

Terminal window
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 criteria
ctxbrew generate --target openapi # OpenAPI from SCM/DSM
ctxbrew generate --target prompts # agent-ready prompt packs
ctxbrew generate --target semgrep # security rules
ctxbrew generate --target eslint # quality rules
ctxbrew generate --target ci # CI pipeline artifacts
ctxbrew 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.

Terminal window
ctxbrew lint # spec-closure lint: parse + cross-model + coverage (--json, --gate, --strict, --max-findings, --report)
ctxbrew lint-esdm # ESDM-specific lint
ctxbrew check # spec validators + evidence fingerprints + ledger staleness
# + CBT drift + churn freshness → one auditable drift score
ctxbrew check --gate # CI mode: exit 1 when a signal fails
ctxbrew stale # staleness listing (--gate, --max-age-days, --json)
ctxbrew cbt verify # constraint-behavior-test drift registry
ctxbrew acm matrix # access-control matrix and coverage
ctxbrew acm audit-log # who changed which rule, newest first
ctxbrew acm check-coverage # exit 1 if any screen has no rule
ctxbrew acm generate <projectId> # regenerate projections via the Studio API
ctxbrew acm export-policy --file models/acm.json --target opa # file-based: cerbos|opa|cedar (--out writes to a file)
ctxbrew validate-consistency # cross-model consistency
ctxbrew why # explain a spec decision

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.

Terminal window
ctxbrew score --cmbf . # Layer-1 CMBF: AST-level model↔code alignment
ctxbrew score --semantic-debt . # governed-term compliance + name drift
ctxbrew score --composed . # three-pillar completeness score

Exactly one mode flag required.

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.

Terminal window
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)

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.

Terminal window
ctxbrew gate # all five checks
ctxbrew gate -t schema_evolution_safe # a subset of gate types
ctxbrew gate --evidence --receipt md # bundle + markdown receipt
ctxbrew 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.

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.

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.

Terminal window
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.

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).

Terminal window
ctxbrew observe k8s --c4 models/c4.json --sim models/sim.json
ctxbrew observe k8s --from-json snapshot.json --json # offline path
ctxbrew 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
Terminal window
ctxbrew recipe create --aggregate Order # .contextbrew/recipes/recipe-001.{json,md}
ctxbrew recipe list
ctxbrew 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.

Terminal window
ctxbrew recipe claude-md [--sections <list>] [--stdout] # CLAUDE.md
ctxbrew recipe agents-md [--stdout] # AGENTS.md
ctxbrew recipe cursor-rules [--stdout] # .cursor/rules
ctxbrew recipe copilot-instructions [--stdout] # .github/copilot-instructions.md

Recipe Server commands operate on a remote recipe repo (--repo-id <id>, created by recipe init --project-id <id> --name <name>):

Terminal window
ctxbrew recipe init --project-id <uuid> --name main
ctxbrew 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]
Terminal window
ctxbrew generation create # start a hosted generation run
ctxbrew generation list # runs + costs
ctxbrew 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 comparison
ctxbrew provider list | show | models | update | health
ctxbrew orchestrate next # RDOS-aware next-work orchestration

Native 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”.

Terminal window
ctxbrew review inspect --origin <studio> --project <uuid> --artifact <uuid> \
--model ddd --kind aggregate --id <local-id> [--json] # emit the inspection file
ctxbrew review links --inspection <file> # typed representation links (no network)
ctxbrew review submit --origin <studio> --inspection <file> \
--decision approve|needs_work [--reason-stdin] # expectations travel unchanged
ctxbrew review revoke --origin <studio> --inspection <file> \
--decision-id <uuid> [--reason-stdin] # revoke the active recorded decision
ctxbrew review command-status --origin <studio> --command-id <uuid> # read a review receipt
ctxbrew 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 id
ctxbrew review workflow-context --origin <studio> --project <uuid> \
--target-type <type> --target-id <id> --actor <actor-id> \
--purpose repair|review # runtime context of one workflow target
ctxbrew 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:

Terminal window
ctxbrew transition targets # registered implementation targets
ctxbrew transition adoption # evidence-backed adoption assertions (append-only)
ctxbrew transition prepare # owned isolated candidate + frozen source-move plan
ctxbrew transition apply # execute a FROZEN plan (E10 readiness gate)
ctxbrew transition journal status --run <runId> # known-unknown steps + next action
ctxbrew transition journal reconcile --run <runId> # reconcile interrupted steps against ACTUAL state
Terminal window
ctxbrew mcp setup --agent claude-code # or: cursor | windsurf | codex | orca | generic
ctxbrew mcp serve # stdio server

See 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, …).

Terminal window
ctxbrew log "chose Redis over Kafka — p99 latency" # one-line decision capture
ctxbrew timeline # the memory, read back in order
ctxbrew decisions # .dec text projection
ctxbrew ingest-decisions # ingest decision records

Print the normative JSON Schema of any ContextBrew file format — the same schemas documented in File Schemas.

Terminal window
ctxbrew schema # list every format (id, version, summary)
ctxbrew schema ddd # print the ddd schema JSON
ctxbrew schema ddd -o ddd.schema.json
ctxbrew schema --all # every schema as one JSON document