Skip to content
ContractSpec
Start here

Contracts · Beginner · source walkthrough

Write your first contract

Follow user.create from an email schema to a typed handler. Start with the smallest maintained example.

@lssm-tech/example.minimal · Source inspected · evidence as of 2026-10-27

Source context

Source inspected · b67c376f

Pinned source links require repository access; publication and anonymous package availability were not checked for this example.

A small user.create command accepts one required email address. Its current handler returns the same email. This gives you a compact place to understand the contract and handler boundary before adding storage or authentication.

What you will learn

  • Give an operation a stable key and version.
  • Describe the accepted input and returned output in the same contract.
  • Connect a typed handler without assuming the metadata implements the business operation.

AN INTERACTIVE READING MAP

Walk through this example.

Step through the maintained source review, inspect its evidence boundaries, or assemble an adaptation packet.

SOURCE WALKTHROUGH

Read the operation in its authored order

01 / IN FOCUS

Describe the input

Read UserInput in src/contracts/user.ts. The schema has one required EmailAddress field. The command uses the schema for both input and output.

1 / 4

0 points in your packet

Walk through the source

  1. Describe the input. Read UserInput in src/contracts/user.ts. The schema has one required EmailAddress field. The command uses the schema for both input and output.
  2. Name the operation. Inspect the user.create key, version 1.0.0, owner, goal, and anonymous authentication policy. These describe the operation and its boundary.
  3. Follow the handler. Open src/handlers/user-input.handler.ts. HandlerForOperationSpec derives the handler shape from CreateUser. The implementation returns input.email; it does not create a persisted account.
  4. Inspect and adapt the starter. Read the package smoke fixture and validation script. Replace the echo handler with your own behavior, then test that behavior and the contract boundary together.

What this review establishes

  • The maintained source declares user.create with a required email input and a typed output.
  • The handler is typed from the operation specification.
  • A source smoke fixture checks starter metadata and feature registration.

Not established

  • A database account is created or an email is sent.
  • This example exposes an MCP tool: its manifest disables MCP.
  • This starter implements an approval gate, persistence, or production authentication.

Before adapting

  • Access to the inspected source repository and a checkout at the cited revision.
  • The repository's Bun workspace dependencies and required generated package exports. These instructions were inspected; the examples were not executed in this review.

Adapt the pattern

  • Keep the operation key and version intentional as behavior changes.
  • Add persistence in a handler or port with explicit tests.
  • Use the approval fixture or draft-and-send story when learning governed writes.
declaredStability
stable
registry
Registered
inlinePreview
No generated inline UI preview registered
execution
Not rerun
production
Not assessed