Skip to content

Creating Recipes

Recipes are created by selecting spec elements from your models and bundling them into a self-contained work unit. This page covers how to create, configure, and refine recipes.

The simplest recipe pulls context from a single DDD aggregate:

Terminal window
ctxbrew recipe create --aggregate Book

This writes .contextbrew/recipes/recipe-001.{json,md} containing:

  • The Book aggregate definition with all properties and invariants
  • Generated unit tests for each invariant
  • A work item list derived from the aggregate’s properties and associations

A recipe is created per aggregate, but it is rarely aggregate-only. Everything you linked in your spec files travels with it through traceability:

  1. DDD – the aggregate, its properties, invariants, and associations
  2. CBRL – requirements that declare INVOLVES_AGGREGATE Book
  3. USM – stories linked from those requirements
  4. SCM – screens that reference the aggregate or those requirements
  5. DSM – tables whose aggregate field names the aggregate

In other words: the multi-model recipe is authored in the model files (the links), not in the recipe command. If a requirement should be part of the Book recipe, link it in CBRL with INVOLVES_AGGREGATE Book.

Work items are auto-derived when the recipe is created – there is no separate work-item command. They live inside the recipe file itself:

Terminal window
ctxbrew recipe list # what recipes exist
cat .contextbrew/recipes/recipe-001.json # manifest + state + work items

Need a custom work item? Edit the recipe file – it is plain JSON/markdown you own, and it is the artifact your agent reads.

Control what gets generated from the spec with generator targets:

Terminal window
ctxbrew generate --target vitest # failing-first unit tests only
ctxbrew generate --target all # everything (default)
ctxbrew generate --aggregate Book # scope to one aggregate

Available targets:

Target Output
vitest Failing-first unit tests from invariants and test cases (scaffold stubs fail by design)
gherkin Gherkin scenarios from acceptance criteria
openapi OpenAPI spec fragments from SCM/DSM
prompts Agent-ready prompt packs
semgrep Security rules
eslint Quality rules
ci CI pipeline artifacts
all Everything (default)

Output lands under .contextbrew/generated/<target>/.

For large recipes, the export step manages the token budget so the prompt fits within model limits:

Terminal window
ctxbrew recipe export --recipe recipe-001 --token-budget 80000

The default budget is 200000 tokens.

When your specs change, you do not need to regenerate everything blind. Diff first, then regenerate what the diff touched:

Terminal window
# Edit .contextbrew/ddd/book.domain (e.g. add a subtitle property), then:
ctxbrew ddd diff .contextbrew/ddd/book.domain.bak .contextbrew/ddd/book.domain
# Regenerate the tests that cover the changed aggregate
ctxbrew generate --target vitest --aggregate Book

Recipe exports are always assembled fresh from the current spec, so exporting again after a spec change produces an up-to-date prompt without a flag.

Terminal window
# Export as a pasteable markdown prompt (default)
ctxbrew recipe export --recipe recipe-001
# Export as a JSON file
ctxbrew recipe export --recipe recipe-001 --format json --output recipe-001.json
# Agent-specific formats
ctxbrew recipe export --recipe recipe-001 --format claude-mdc
ctxbrew recipe export --recipe recipe-001 --format cursorrule
ctxbrew recipe export --recipe recipe-001 --format copilot
# Copy to a file and hand to any agent
ctxbrew recipe export --recipe recipe-001 --format skill-md --output SKILL.md

All formats: markdown, json, claude-mdc, cursorrule, copilot, plain-text, signed-json, ctxbrew, skill-md, skill-md-bundle. Signed exports (signed-json) are verified with ctxbrew verify.

Terminal window
# Assign a recipe to an agent type
ctxbrew recipe assign recipe-001 --agent claude-code
# Prepare and dispatch (optionally spawning the agent and streaming output)
ctxbrew recipe execute recipe-001 --agent claude-code --run
# Check on it
ctxbrew recipe status recipe-001
ctxbrew recipe report recipe-001 --output report.md