Write your first contract
Define an operation
Follow user.create from an email schema to a typed handler. Start with the smallest maintained example.
- Describe the input
- Name the operation
- Follow the handler
Source demonstratesThe maintained source declares user.create with a required email input and a typed output.
Does not demonstrateA database account is created or an email is sent.
Inspect the walkthroughBehavior · proof and limits · source checks
Follow the source behavior
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.
- 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.
- 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.
- 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.
- 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 example establishes
Source demonstrates
- 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.
Does not demonstrate
- 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.
Reproduce the source checks
The smoke fixture checks metadata and feature wiring; validation checks the contract. Neither is an account-creation integration test.
Working directory examples/minimal
bun run smoke
bun run validateCommands and source inspected; not executed here.
