SCM — Tutorial
This is the tutorial part of the SCM — Screen Connectivity guide. See also Short info and samples.
Before you begin
Section titled “Before you begin”Name a user goal and the destinations needed to complete it. Rough labels are enough; polished wireframes are unnecessary.
Understand the model
Section titled “Understand the model”Model destinations and meaningful moves
Section titled “Model destinations and meaningful moves”A screen map explains where a user can be and how they can continue. Search, Results and Confirmation are destinations with different purposes. An edge such as “select flight” explains a supported move and the context carried to the next destination. A collection of route names without these relationships is only an inventory.
A screen can represent many instances. Booking detail for reservation A and reservation B usually shares one route contract with a parameter. Model that parameter and the screen’s purpose rather than creating one node per record. Conversely, two destinations with different responsibilities should not be combined merely because their URLs share a prefix.
Include the journey that fails
Section titled “Include the journey that fails”A useful first map contains a way to recover from an empty result or rejected operation. If no flights are available, the traveler should be able to change the search. If a reservation expires before confirmation, identify the destination that explains what happened and what can happen next. These paths reveal requirements that a happy-path diagram can hide.
Link a destination to a story to explain the user’s goal, and link access decisions to ACM when permissions matter. The navigation map can show an account link without proving that access is authorized. Similarly, discovering a route in source code establishes an implemented destination, not that it belongs in the intended journey. Review the map against a realistic user task and keep route validation separate from usability and authorization checks.
Visual walkthrough
Section titled “Visual walkthrough”A traveler reaches a dead end—and gets a way back. A route animates through Search and Results; an empty result stops it; a labelled return arrow completes recovery.
Pause and predict: Where can the traveler go next when the result list is empty?
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.
Creating Screens
Section titled “Creating Screens”Author the file
Section titled “Author the file”There is no model command — screen maps are authored as .scm.json files under .contextbrew/scm/ (or on the Studio canvas). Create .contextbrew/scm/books.scm.json:
{ "kind": "scm-file", "schemaVersion": "0.3.0", "screens": [ { "kind": "screen", "id": "book-catalog", "name": "Book Catalog", "route": "/books", "aggregate": "Book", "stories": ["US-001"], "requirements": ["REQ-001"] }, { "kind": "screen", "id": "book-details", "name": "Book Details", "route": "/books/:id", "aggregate": "Book", "stories": ["US-001"], "requirements": ["REQ-002"] }, { "kind": "screen", "id": "add-book", "name": "Add Book", "route": "/books/new", "aggregate": "Book", "stories": ["US-002"], "requirements": ["REQ-003"] } ], "navigations": [ { "kind": "navigation", "id": "nav-catalog-details", "source": "book-catalog", "target": "book-details", "trigger": "User clicks a book card", "navType": "push" }, { "kind": "navigation", "id": "nav-catalog-add", "source": "book-catalog", "target": "add-book", "trigger": "Admin clicks 'Add Book' button", "navType": "push" }, { "kind": "navigation", "id": "nav-details-catalog", "source": "book-details", "target": "book-catalog", "trigger": "User clicks 'Back'", "navType": "push" } ], "flows": []}ctxbrew scm validate .contextbrew/scm/books.scm.jsonDiscover screens from an existing app
Section titled “Discover screens from an existing app”Already have routes? ctxbrew scm discover parses route-file conventions — Next.js App Router, Expo Router, React Router — into an SCM model, and can diff the discovery against a committed model for CI:
ctxbrew scm discover src/app --framework auto --out discovered-scm.json
# CI drift slice: exit 1 when discovery diverges from the committed modelctxbrew scm discover src/app --drift-vs .contextbrew/scm/books.scm.json --fail-on-driftUsing Context Studio
Section titled “Using Context Studio”The SCM canvas provides a visual graph editor where:
- Screens appear as labeled nodes with their route path
- Navigation edges show the flow between screens
- Clicking a node reveals its linked aggregate, story, and requirements
- The graph validates for unreachable screens and dead-end navigation
Screen Properties
Section titled “Screen Properties”Each screen can carry additional metadata in the file:
- Guard condition –
guardon a screen or navigation: what must be true to access it (e.g.,session.active) - Zones – which area of the app the screen lives in (e.g.,
"zones": ["Public", "Search"]) - Sections – named data sections mapped to aggregate properties:
"sections": [{ "name": "Flight List", "source": "Flight.route/departureTime/price" }]
{ "kind": "screen", "id": "book-details", "name": "Book Details", "route": "/books/:id", "aggregate": "Book", "purpose": "View book details, reviews, and availability", "zones": ["Catalog"], "sections": [{ "name": "Book Info", "source": "Book.title/isbn/price" }]}CLI Reference
Section titled “CLI Reference”ctxbrew scm validate <file> # Parse the file; exit 1 on any errorctxbrew scm stats <file> # Collection sizes (screens, navigations…)ctxbrew scm export <file> # Canonical DSL (or --format json|yaml)ctxbrew scm import <file> # Canonicalization passctxbrew scm diff <before> <after> # Semantic diff (report only)ctxbrew scm discover <srcDir> # Route-file discovery (+ --drift-vs CI slice)ctxbrew schema scm # Print the normative JSON SchemaImport / export
Section titled “Import / export”SCM imports Mermaid flowchart diagrams (the documented flowchart subset; foreign constructs skip with a warning) and exports back to Mermaid. Route discovery from Next.js App Router, Expo Router, and React Router source trees produces SCM models directly, with --drift-vs + --fail-on-drift as the CI drift gate. Details: Import & Export.
