Skip to content

SCM — Tutorial

This is the tutorial part of the SCM — Screen Connectivity guide. See also Short info and samples.

Name a user goal and the destinations needed to complete it. Rough labels are enough; polished wireframes are unnecessary.

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.

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.

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.

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": []
}
Terminal window
ctxbrew scm validate .contextbrew/scm/books.scm.json

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:

Terminal window
ctxbrew scm discover src/app --framework auto --out discovered-scm.json
# CI drift slice: exit 1 when discovery diverges from the committed model
ctxbrew scm discover src/app --drift-vs .contextbrew/scm/books.scm.json --fail-on-drift

The SCM canvas provides a visual graph editor where:

  1. Screens appear as labeled nodes with their route path
  2. Navigation edges show the flow between screens
  3. Clicking a node reveals its linked aggregate, story, and requirements
  4. The graph validates for unreachable screens and dead-end navigation

Each screen can carry additional metadata in the file:

  • Guard condition – guard on 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" }]
}
Terminal window
ctxbrew scm validate <file> # Parse the file; exit 1 on any error
ctxbrew scm stats <file> # Collection sizes (screens, navigations…)
ctxbrew scm export <file> # Canonical DSL (or --format json|yaml)
ctxbrew scm import <file> # Canonicalization pass
ctxbrew 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 Schema

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.