Skip to content

First Project

This walkthrough takes you from zero to a complete recipe ready for an AI coding agent. You will create a project, author a DDD aggregate, connect it to a USM story, validate a CBRL requirement, generate tests, and export a recipe.

Terminal window
mkdir bookstore && cd bookstore
ctxbrew init --name bookstore

ContextBrew creates the .contextbrew/ project structure in the current directory, with directories for model files, recipes, and generated artifacts. All five first-class specification models are enabled by default.

Models are plain text files on disk — author them in whatever editor you like. Create .contextbrew/ddd/book.domain:

AGGREGATE Book {
PROPERTY id: UUID [pk]
PROPERTY title: string [required]
PROPERTY isbn: string [required, unique]
PROPERTY price: number [required]
PROPERTY status: string [default="draft"]
INVARIANT "isbn-format"
EXPRESSION "isbn =~ /^[0-9]{10}([0-9]{3})?$/"
}

Validate the file:

Terminal window
ctx ddd validate .contextbrew/ddd/book.domain

ContextBrew parses the model and exits non-zero on any syntax or validation error — the same file also drives test generation later. Prefer drawing to typing? The same aggregate can be edited visually in Context Studio (the web UI) on the Svelte Flow canvas, where aggregates appear as nodes and associations as edges. AI agents can author models too, through the MCP server’s author tool.

The USM model is JSON. Create .contextbrew/usm/bookstore.usm.json with a persona and a story that connects to the domain:

{
"kind": "usm-file",
"schemaVersion": "0.2.0",
"title": "Bookstore Story Map",
"columns": ["Backlog", "Doing", "Done"],
"releases": [
{ "kind": "release", "id": "v1.0", "name": "MVP" }
],
"personas": [
{
"kind": "persona",
"id": "P1",
"name": "Bookstore Manager",
"stories": [
{
"kind": "user-story",
"id": "US-001",
"title": "Add new book to catalog",
"description": "As a Bookstore Manager, I want to add books with a valid ISBN so the catalog stays clean",
"column": "Backlog",
"release": "v1.0",
"acceptanceCriteria": [
"Given a valid ISBN, when I add a book, then it appears in the catalog",
"Given an invalid ISBN, when I add a book, then I see a validation error"
]
}
]
}
]
}
Terminal window
ctx usm validate .contextbrew/usm/bookstore.usm.json

Not sure who your users are? ctxbrew personas list shows the ten persona archetypes that ship with the starter library.

Formalize the requirement in the ContextBrew Requirements Language. Create .contextbrew/cbrl/bookstore.requirements:

REQUIREMENT REQ-001 "Book catalog management"
ACCEPTANCE_CRITERIA AC-001 "Only books with a valid ISBN are added to the catalog"
ACCEPTANCE_CRITERIA AC-002 "Adding a book with an invalid ISBN shows a validation error"
TEST_CASE TC-001 "Add book with valid ISBN succeeds"
TEST_CASE TC-002 "Add book with invalid ISBN fails"
INVOLVES_AGGREGATE Book
LINKED_STORY US-001
Terminal window
ctx cbrl validate .contextbrew/cbrl/bookstore.requirements

The INVOLVES_AGGREGATE and LINKED_STORY lines create traceability links between the CBRL requirement, the DDD aggregate, and the USM story. ContextBrew computes these links bidirectionally. In CI, ctx cbrl check .contextbrew/cbrl/bookstore.requirements fails the build when a new error finding appears relative to a committed baseline.

Terminal window
ctxbrew generate

From the CBRL and DDD files, ContextBrew generates (into .contextbrew/generated/<target>/):

  • Vitest unit tests pinning the ISBN invariant on the Book aggregate — failing-first scaffolds that pass once the implementation is real
  • Gherkin scenarios from the acceptance criteria
  • OpenAPI fragments from the SCM/DSM models
  • Prompt packs, Semgrep and ESLint rules, and CI pipeline artifacts (the other generation targets)

Generate one target at a time with --target vitest, or scope to a single aggregate with --aggregate Book.

Bundle everything into a recipe for an AI coding agent:

Terminal window
ctxbrew recipe create --aggregate Book

Export the recipe as a pasteable prompt:

Terminal window
ctxbrew recipe export --recipe 1

The exported recipe contains:

  • Domain context (the Book aggregate, its properties, and invariant)
  • The user story and its acceptance criteria
  • The generated failing tests
  • A work item checklist

Paste this into Claude Code, Cursor, or any AI agent — or hand it to the Execution Engine with ctxbrew generation create. The agent implements the code to make all tests pass.

You have:

  1. Created a ContextBrew project
  2. Authored a DDD aggregate with a business invariant — and validated it
  3. Connected it to a USM story with acceptance criteria
  4. Written a CBRL requirement with traceability links
  5. Generated failing-first tests, scenarios, and API fragments from your models
  6. Exported a recipe for an AI coding agent