Type to search pages and rules.

Use with Agents

Start a Consumer Repository

A LiteSpec consumer is a project built against the LiteSpec standard, and this tutorial turns an empty folder into one: its configuration, its first Intent records, the Behavior specified from them, one working use case, and a passing model check. A use case names what the product does for an actor, a person or system using it, and the model check confirms the records, code, and tests agree. This tutorial follows one backend stack and one frontend stack, the dotnet backend with a React frontend, so every step runs the same way for every reader. A developer follows these steps once, when creating the consumer. Each step names the standard it satisfies, and the tutorial adds no rule of its own.

Markdown
On this page

Prerequisites#

  • Install the .NET SDK and Node.js releases the adopted release pins under stack in its litespec.manifest.yaml.
  • Read nothing in advance: each step links the standard it satisfies, so open each linked page at its step.
  • Ship the dotnet backend with a React frontend: this tutorial follows that pair from the dotnet-react preset. When the product ships another frontend, follow this tutorial first, then declare that frontend with its own how-to, Add a Svelte Frontend or Add a Blazor Frontend.
  • To start with records only and no stack, follow Start with Records Only instead of this tutorial.

Lesson#

This lesson creates a new project. The litespec new commands below write each record from its template with example values, so replace every example value with the project's own before committing. After the project runs, adding new intent to it follows the one sequence under New Intent in a Running Project on the agent page, and the check steps below walk that same order for the first slice.

  1. Install the LiteSpec CLI for the adopted release as the CLI overview shows. Check that dotnet litespec --help prints the command list from the consumer root. This satisfies litespec/workspace/structure#use-the-canonical-root-tree.
  2. Run dotnet litespec init --preset dotnet-react --size small and confirm .litespec/project.yaml exists. The initialize command lists what the command writes. This satisfies litespec/core/scope#select-a-size-a-shape-and-stacks.
  3. Select extensions only when their criteria already hold. Write each selection in the object form with its criterion. This satisfies litespec/core/scope#select-conditional-extensions-explicitly and litespec/core/scope#record-selected-extensions.
  4. Set paths.behaviorDocs in .litespec/project.yaml to the Behavior root and confirm the path names that folder. This satisfies litespec/core/scope#point-behavior-docs-at-the-behavior-root.
  5. Create the toolchain configuration from the manifest pins named on the project file and manifest pages. Check that the SDK, build, package, tool manifest, and JavaScript toolchain pins match the manifest. This satisfies litespec/backend/dotnet/config#set-the-sdk-floor-at-the-workspace-root, litespec/backend/dotnet/config#centralize-net-build-settings, litespec/backend/dotnet/config#centralize-nuget-versions, litespec/backend/dotnet/config#commit-the-tool-manifest, and litespec/workspace/config#pin-the-javascript-toolchain.
  6. Add only the packages the manifest already pins. Record each new package approval explicitly. This satisfies litespec/workspace/dependencies#pin-every-dependency-version-centrally and litespec/workspace/dependencies#approve-new-packages-explicitly.
  7. Create the API solution and its projects as Write Code for a Use Case and the .NET architecture and backend testing pages describe. Check that the solution holds the projects those pages require for a small server project. This satisfies litespec/backend/dotnet/architecture#separate-the-shared-kernel-from-the-modules, litespec/backend/testing#keep-the-test-suites-the-size-requires, and litespec/backend/dotnet/packages#run-litespec-analyzers-in-the-business-projects-and-hosts.
  8. Apply the naming rules: match each C# file to its primary type and each namespace to its folder. This satisfies litespec/backend/dotnet/naming#match-c-files-and-primary-types and litespec/workspace/naming#keep-namespaces-aligned-with-folders.
  9. Write the product record. Run dotnet litespec new product <name> and fill its boundary, its addresses, and its summary. This satisfies litespec/core/intent#state-one-product and litespec/core/intent#keep-intent-in-its-homes.
  10. Write one module with its first feature. Run dotnet litespec new module <module>, write the problem the feature answers, then follow Write a Feature Under a Problem to add the feature and its requirements. This satisfies litespec/core/intent#keep-intent-in-its-homes and litespec/core/intent#identify-every-requirement.
  11. State which constraints apply. Run dotnet litespec new constraint <name> once per outside rule and complete the record, or record that none applies. This satisfies litespec/core/intent#answer-every-constraint and litespec/core/scope#answer-the-constraints-question.
  12. Record the first decision. Run dotnet litespec new decision <name> and complete the record and its explanation file. This satisfies litespec/core/intent#shape-each-decision-page.
  13. Write the people records. Run dotnet litespec new actor <name> once per party and dotnet litespec new role <name> once per grantable set. Create the module permission list from its template and add each permission with dotnet litespec new entry .litespec/behavior/modules/<module>/permissions.yaml permission <name>. When the slice exchanges anything with an outside system, run dotnet litespec new external-system <name> and complete the record.
  14. Write one journey. Run dotnet litespec new journey <name> and complete the record with its serves, startedWhen, finishedWhen, steps, and branches. This satisfies litespec/core/intent#order-each-journey-toward-one-goal, litespec/core/intent#write-journey-steps-as-sentences-with-ids, litespec/core/intent#state-when-each-journey-starts, and litespec/core/intent#state-when-each-journey-finishes.
  15. Check the Intent records. Run dotnet litespec model check from the consumer root and fix every finding that names a record written so far before continuing. The run sees records only at this point, so it still reports missing Behavior record types and unreached Intent until step 16. The model command page lists the findings and their levels.
  16. Specify the module from Intent. Leave this tutorial now and complete Model a Behavior Module from its first step to its last, then return here, run dotnet litespec model check, and fix every finding before code moves. This satisfies litespec/core/system#group-module-use-case-files-by-aggregate and litespec/core/model#author-one-slice-at-a-time.
  17. Implement one use case. Move the transition into a business method, keep the handler narrow, commit once, expose one endpoint, and authorize the target. Code points up to its record through its mark. This satisfies litespec/backend/domain#express-transitions-through-business-methods, litespec/backend/application#keep-command-handlers-to-load-call-and-stage, litespec/backend/dotnet/persistence#commit-once-in-the-command-pipeline, litespec/backend/dotnet/api#use-one-endpoint-per-operation, and litespec/backend/application#enforce-target-authorization-in-the-pipeline.
  18. Declare the React frontend. Declare the application tree and mirror the backend use case path. This satisfies litespec/frontend/web/structure#use-the-frontend-application-tree. Build each pattern Default and record it with source: recommended, waiting for an owner only when a route departs from the Default or no Default exists, and compose each route from one floorplan. This satisfies litespec/frontend/ui#compose-each-route-from-one-floorplan.
  19. Deliver one complete slice. Ship source, tests, contracts, and operating evidence for one use case. This satisfies litespec/core/system#deliver-one-complete-use-case.
  20. Add the operating records. Write the settings and runbooks, add deployment, backup, restore, and rollback, and configure the pipeline gates. This satisfies litespec/quality/operations#start-the-stack-with-one-local-command and litespec/quality/ci#run-applicable-gates-on-every-pull-request.
  21. Run the boundary gates and the test suites the changed areas select, so the latest test run stands before the model reads it.
  22. Run dotnet litespec model check and confirm the run exits with no open blocking finding. The model command page lists its exit codes and what it reports.
  23. Run dotnet litespec model render and commit what it wrote. This satisfies litespec/core/release#run-consistency-checks.
  24. Run dotnet litespec book and open the journey detail, the way product reviewers read the change.

What You Built#

  • A consumer repository at small size that the model check accepts.
  • One coded use case with Intent, Behavior, code, tests, and generated contracts.
  • When the next use case is specified, follow Write Code for a Use Case to place each of its code elements with its mark and check.
  • When the product ships another frontend, Add a Svelte Frontend and Add a Blazor Frontend declare it. The checks are documented on Model Builder; all commands are listed on the command index.