Skip to content

CBRL Syntax

CBRL (ContextBrew Requirements Language) is a structured DSL for writing formal, traceable requirements. This page provides the complete syntax reference.

A CBRL file contains one or more REQUIREMENT blocks:

REQUIREMENT <id>
TITLE "<title>"
DESCRIPTION "<description>"
[ACCEPTANCE_CRITERIA]
GIVEN <precondition>
WHEN <action>
THEN <expected result>
[TEST_CASE]
NAME "<test name>"
INPUT <field> = <value>
EXPECTED <assertion>
[INVOLVES_AGGREGATE <aggregate-name>]
[LINKED_STORY "<story-title>"]
[@<aspect-name>]
END_REQUIREMENT

Defines a requirement block. The ID must be unique within the project and follow the pattern REQ-NNN:

REQUIREMENT REQ-001
...
END_REQUIREMENT

A human-readable title for the requirement:

TITLE "User registration"

A detailed description of what the system must do:

DESCRIPTION "The system shall allow new users to register with email and password. Passwords must be at least 12 characters and contain a mix of letters, numbers, and symbols."

One or more criteria in Given/When/Then format. Each requirement can have multiple criteria:

ACCEPTANCE_CRITERIA
GIVEN a new user with email "[email protected]"
WHEN the user submits the registration form with a valid password
THEN the user account is created and a verification email is sent
ACCEPTANCE_CRITERIA
GIVEN an existing user with email "[email protected]"
WHEN a new user tries to register with the same email
THEN the system rejects the registration with a "duplicate email" error

An explicit test definition with inputs and expected outcomes:

TEST_CASE
NAME "Valid registration creates account"
INPUT email = "[email protected]"
INPUT password = "Str0ng!Pass#2026"
EXPECTED user account exists with email "[email protected]"
EXPECTED verification_email_sent = true
TEST_CASE
NAME "Duplicate email rejected"
INPUT email = "[email protected]"
INPUT password = "Str0ng!Pass#2026"
EXPECTED error with code "DUPLICATE_EMAIL"

Links the requirement to a DDD aggregate. Creates a traceability link:

INVOLVES_AGGREGATE User
INVOLVES_AGGREGATE EmailVerification

A requirement can involve multiple aggregates.

Links the requirement to a USM story:

LINKED_STORY "User registration"

Aspects tag cross-cutting concerns. They generate additional test cases:

@security
@audit
@accessibility
@performance
@privacy

Multiple aspects can be applied to a single requirement:

REQUIREMENT REQ-005
TITLE "User profile update"
DESCRIPTION "Users can update their profile information"
INVOLVES_AGGREGATE User
@security
@audit
@privacy
END_REQUIREMENT

CBRL supports the following value types in INPUT and EXPECTED fields:

Type Syntax Example
String "value" "[email protected]"
Number 123 or 3.14 42
Boolean true or false true
Null null null
Reference <field> user.id

Single-line comments start with #:

# This requirement covers the core registration flow
REQUIREMENT REQ-001
TITLE "User registration"
...
END_REQUIREMENT
REQUIREMENT REQ-010
TITLE "Order placement"
DESCRIPTION "Customers can place orders containing multiple items. The system validates stock availability before confirming the order."
ACCEPTANCE_CRITERIA
GIVEN a customer with items in their cart
WHEN the customer submits the order
THEN the order is created with status PENDING
AND stock is reserved for each item
ACCEPTANCE_CRITERIA
GIVEN an item with 0 stock
WHEN the customer attempts to order that item
THEN the system rejects the order with "OUT_OF_STOCK"
TEST_CASE
NAME "Valid order creates pending order"
INPUT customer_id = "cust-123"
INPUT items = [{"book_id": "book-1", "quantity": 2}]
EXPECTED order.status = "PENDING"
EXPECTED order.total = calculated from item prices
TEST_CASE
NAME "Out of stock item rejected"
INPUT customer_id = "cust-123"
INPUT items = [{"book_id": "book-out-of-stock", "quantity": 1}]
EXPECTED error with code "OUT_OF_STOCK"
INVOLVES_AGGREGATE Order
INVOLVES_AGGREGATE Book
LINKED_STORY "Place order"
@security
@audit
END_REQUIREMENT