Import & Export
Import & Export
Section titled “Import & Export”ContextBrew models interoperate with the tools you already use: requirements live in ReqIF or Doorstop, schemas live in Prisma or a live database, architecture lives in Structurizr. This page is the per-format matrix of what comes in, what goes out, and which command to reach for.
The per-format toolkit
Section titled “The per-format toolkit”Every model format gets the same five commands against its canonical file (the DSL or JSON file in .contextbrew/):
ctxbrew <format> validate <file> # parse + validate (exit 1 on any error)ctxbrew <format> export <file> # canonical DSL (default), --format json|yaml, or --to <exporterId>ctxbrew <format> import <file> # canonicalization pass: parse, re-emit canonicalctxbrew <format> stats <file> # collection sizesctxbrew <format> diff <a> <b> # semantic diff of two snapshots (report only)<format> is one of ddd, usm, cbrl, scm, dsm, sim, absl, c4, context-map, esdm. Every format also has a normative JSON Schema (ctxbrew schema <format> prints it; see File Schemas).
Format matrix
Section titled “Format matrix”| Format | Import from | Export to | CLI entry points |
|---|---|---|---|
| DDD | TypeORM/NestJS entities and Spring/JPA entities → aggregate proposals (marked, reviewable — never merged silently); hypothesis specs from TS source (init --from-code) |
Gherkin, architecture doc, Mermaid class diagram | ctxbrew ddd validate|export|import|stats|diff, ctxbrew init --from-code |
| USM | Featmap JSON; TextUSM-style indented .usm.md (round-trip); Spec Kit / Kiro / OpenSpec / BMAD / spec-workflow-mcp workspaces |
Indented text (round-trip), user guide | ctxbrew usm validate|export|import|stats|diff, ctxbrew import spec-kit|kiro|openspec|bmad|spec-workflow-mcp |
| CBRL | ReqIF (round-trip); Doorstop YAML directories (round-trip); the workspace import family above | ReqIF, Doorstop, Gherkin, self-contained HTML spec pack | ctxbrew cbrl validate|export|import|stats|diff, ctxbrew cbrl check --baseline, ctxbrew cbrl publish --out <dir> |
| SCM | Mermaid flowchart subset; route discovery from Next.js App Router / Expo Router / React Router source trees (+ CI drift report) | Mermaid flowchart | ctxbrew scm validate|export|import|stats|diff, ctxbrew scm discover <srcDir> --drift-vs <model> --fail-on-drift |
| DSM | SQL DDL (Postgres + SQLite subset), DBML, Prisma schema, drizzle-kit TS, MySQL DDL, dbt schema.yml/properties.yml, live Postgres catalog |
SQL DDL, DBML, Drizzle ORM schema, data dictionary | ctxbrew dsm validate|export|import|stats|diff, ctxbrew db pull --dialect postgres |
| SIM | Structurizr DSL (via the C4 parser); boundary scanning of an existing codebase | Canonical JSON/DSL round-trip | ctxbrew sim validate|export|import|stats|diff, ctxbrew ingest-sim <path> |
| C4 | Structurizr DSL + JSON; Mermaid C4 | C4-PlantUML, Structurizr workspace, Mermaid C4 diagram | ctxbrew c4 validate|export|import|stats|diff, ctxbrew import structurizr <file> |
| ABSL | CrewAI YAML (strict superset) | Agent suite: card, system prompt, MCP tools, guardrail code, red-team spec, observability | ctxbrew absl validate|export|import|stats|diff |
| ESDM | Canonical .esdm.yaml (lossless round-trip) |
.esdm.yaml (lossless round-trip) |
ctxbrew esdm validate|export|import|stats|diff, ctxbrew lint-esdm |
| Context Map | Context Mapper DSL (CML subset) | CML | ctxbrew context-map validate|export|import|stats|diff |
| ACM | Derived projection over SCM/DDD/CBRL/DSM/USM; ACCESS_RULE grammar with linter |
Cerbos YAML, OPA Rego, and AWS Cedar policies | ctxbrew acm matrix|audit-log|check-coverage, ctxbrew acm generate, ctxbrew acm export-policy --target cerbos|opa|cedar |
Notes on the matrix:
- The ReqIF, Doorstop, DBML, Prisma, drizzle, MySQL DDL, dbt, Mermaid, CrewAI, CML, ESDM, and entity-import converters live in the importer/exporter framework in
@contextbrew/core(the same parsers the Studio and MCP server use) — the per-format CLI commands handle the canonical round-trip, and the “CLI entry points” column names the command that drives each conversion where one exists. ctxbrew db pullreads the connection string from theDATABASE_URLenvironment variable only — never a flag, never printed, never logged. No live database?--from-jsonruns the same pipeline on a captured catalog document.ctxbrew scm discover --drift-vs <model> --fail-on-driftis the CI slice: it diffs discovered routes against your committed SCM model and exits 1 on drift.
House rules
Section titled “House rules”Two conventions hold across every importer and exporter:
- Importers never throw. A foreign document with unknown constructs imports as far as it can; unknown constructs are skipped with a warning, never a crash and never a silent invention.
- Round-trip is the bar. Import → export → import must be stable for a converter to ship. If a round-trip loses data, the converter documents its subset rather than pretending.
Where to go next
Section titled “Where to go next”- CLI Reference for every command and flag
- File Schemas for the normative JSON Schema per format
- MCP for reading these models from an AI agent
- Travel Booking Tutorial for
db pullandscm discoverin context
