CBRL — Tutorial
This is the tutorial part of the CBRL — Requirements Language guide. See also Short info and samples.
Before you begin
Section titled “Before you begin”Bring one promise the system should keep and one concrete example of success. A linked story or aggregate helps but is not needed to understand the example.
Understand the model
Section titled “Understand the model”Turn intent into an observable promise
Section titled “Turn intent into an observable promise”“We must prevent overbooking” is a useful intention, but it leaves several questions open. Does it apply to tentative holds or confirmed reservations? Does the limit count seats or bookings? What should the traveler see when the request is refused? A requirement becomes more useful as those distinctions become explicit.
Give the requirement a stable identity so discussion, tests and model references can point to the same obligation. Describe the relevant condition, requested action and observable result. Keep implementation choices out unless they are themselves required constraints. A promise about booking capacity should survive a change of database or frontend framework.
Review the boundary cases
Section titled “Review the boundary cases”Choose examples just inside and just outside the boundary. If capacity is two and one seat is confirmed, one additional seat fits and two do not. These examples make the meaning easier to review than a paragraph containing several loosely related promises. If the requirement combines capacity, email delivery and payment timing, consider separating the obligations and linking them.
Traceability provides context for change. A story explains who benefits, an aggregate identifies relevant domain behavior, and an aspect can express a concern shared across requirements. A broken link is a structural problem; a linked but misunderstood business rule is a semantic problem. Validation and stakeholder review address different parts of that work. A test case must ultimately name how it observes the implementation rather than silently equating the presence of a requirement with satisfaction.
Visual walkthrough
Section titled “Visual walkthrough”From “no overbooking” to two precise examples. A vague promise becomes one requirement card; two nearly identical inputs produce confirmation and refusal.
Pause and predict: Which observation proves that a refused request left the seat count unchanged?
This is the text storyboard for a proposed short illustrated film. The written walkthrough and exercises are available now; a published movie will be added after its scenes, captions and model references have been reviewed.
CBRL Syntax Example
Section titled “CBRL Syntax Example”REQUIREMENT REQ-001 TITLE "Book catalog search" DESCRIPTION "The system shall allow searching books by title, author, or ISBN"
ACCEPTANCE_CRITERIA GIVEN a book exists with title "TypeScript Handbook" WHEN the user searches for "TypeScript" THEN the book appears in search results
TEST_CASE NAME "Search returns matching books" INPUT search_query = "TypeScript" EXPECTED contains book with title "TypeScript Handbook"
INVOLVES_AGGREGATE Book LINKED_STORY "Browse book catalog" @accessibilityEND_REQUIREMENTKey Constructs
Section titled “Key Constructs”REQUIREMENT Block
Section titled “REQUIREMENT Block”Every requirement starts with a unique ID and contains a title, description, and optional sections:
REQUIREMENT REQ-002 TITLE "Secure user authentication" DESCRIPTION "Users must authenticate with email and password" INVOLVES_AGGREGATE User @security @auditEND_REQUIREMENTAcceptance Criteria
Section titled “Acceptance Criteria”Written in Given/When/Then format, auto-converted to Gherkin:
ACCEPTANCE_CRITERIA GIVEN a registered user with email "[email protected]" WHEN the user submits valid credentials THEN the user is authenticated and receives a session tokenTest Cases
Section titled “Test Cases”Explicit test definitions with inputs and expected outcomes:
TEST_CASE NAME "Invalid email format rejected" INPUT email = "not-an-email" EXPECTED validation error with message "Invalid email format"Aspects
Section titled “Aspects”Aspects tag cross-cutting concerns on requirements. When a requirement is tagged with an aspect, ContextBrew generates additional test cases for that concern:
@security– generates security-focused tests (injection, XSS, auth bypass)@audit– generates audit logging test stubs@accessibility– generates accessibility compliance test stubs@performance– generates performance benchmark stubs@privacy– generates data handling and consent tests
REQUIREMENT REQ-003 TITLE "User profile update" DESCRIPTION "Users can update their profile information" INVOLVES_AGGREGATE User @security @audit @privacyEND_REQUIREMENTTraceability Links
Section titled “Traceability Links”Link requirements to other model elements:
INVOLVES_AGGREGATE Book # Links to DDD aggregateLINKED_STORY "Browse catalog" # Links to USM storyThese links enable bidirectional navigation: from any aggregate, you can find all requirements that involve it; from any requirement, you can find the aggregates and stories it relates to.
Editing CBRL
Section titled “Editing CBRL”Using the CodeMirror Editor
Section titled “Using the CodeMirror Editor”Context Studio includes a purpose-built CBRL editor with:
- Syntax highlighting for all CBRL keywords
- Real-time validation and error reporting
- Autocomplete for aggregate names, story titles, and aspect tags
- Inline traceability indicators showing linked model elements
Using the CLI
Section titled “Using the CLI”CBRL requirements are authored as .requirements files under .contextbrew/cbrl/ (or in the Studio editor shown above). The CLI validates and gates them:
ctxbrew cbrl validate .contextbrew/cbrl/requirements.requirements # exit 1 on any error
# CI gate: exit 1 on NEW error findings vs the baseline (warnings never gate);# --ddd makes DDD aggregates the source of truth for INVOLVES_AGGREGATE checksctxbrew cbrl check .contextbrew/cbrl/requirements.requirements \ --ddd .contextbrew/ddd/*.domainImport / export
Section titled “Import / export”CBRL round-trips with the tools requirements teams already run: ReqIF envelopes import and export deterministically, and Doorstop YAML document trees import and export with per-item YAML fidelity (uid/text/links; active: false items are excluded with a warning). Outbound, acceptance criteria become Gherkin .feature files and ctxbrew cbrl publish renders a self-contained HTML spec pack (--out, --title; its print CSS is the PDF path). The Spec Kit, Kiro, OpenSpec, BMAD, and spec-workflow-mcp workspace imports also produce CBRL requirements. Details: Import & Export.
