Docs/Début
Guide source3 min read

Read your first operation

Trace a maintained contract from its input schema to its deliberately small handler.

Download Markdown ↓
Source and verification context ⌄

Source reading walkthrough

Examiner la source ↗

Repository links may require access. Source inspection is separate from a clean public-package installation.

AN INTERACTIVE READING MAP

Get the shape of this guide.

Move through the ideas, inspect their relationships, or make a focused reading path. The complete guide stays below.

SÉQUENCE DE LECTUREComprendre les liens entre les idées
Choose a point to look closer
01 / Section du guide

What this walkthrough demonstrates

The maintained minimal example declares an operation named user.create. It accepts an email and returns the same email. Despite the operation's name, the shown handler does not create a persistent account, send a message or call a provider.

Lire le contexte à l’appui

This is a reading walkthrough of real source. It helps you understand the shape of an operation before introducing databases, authentication or transport setup. The complete files are linked from the source snapshot; the excerpts below are intentionally partial.

Explore a section, then continue with the complete article below.

1 / 5

What this walkthrough demonstrates

The maintained minimal example declares an operation named user.create. It accepts an email and returns the same email. Despite the operation's name, the shown handler does not create a persistent account, send a message or call a provider.

This is a reading walkthrough of real source. It helps you understand the shape of an operation before introducing databases, authentication or transport setup. The complete files are linked from the source snapshot; the excerpts below are intentionally partial.

Read its identity first

The meta object gives the operation a stable key and version, then records its purpose, ownership and stability. These fields tell a caller which contract it is using and help a maintainer find the responsible team.

Use the key and version together when comparing an implementation with its documentation. A source path can move without changing the operation's public identity.

typescript
key: 'user.create',
version: '1.0.0',

Exact metadata excerpt from examples/minimal/src/contracts/user.ts at d58fa5b7; not a standalone declaration.

Changez le point d’entrée. Gardez le sens.Trace the mechanism · 3 ways to look closer

Follow a request to export a report through three interfaces. The useful common ground is the registered operation and its boundary.

Where does this request begin?
UNE SITUATION CONCRÈTE

A form helps someone make a valid request.

A person selects a report and gives a reason for the export.

01 / Form

Collect the report and reason, and explain errors in the person’s language.

Ce qui change

Labels, validation messages and the way the result is presented.

Ce qui reste explicite

The report, required reason, business implementation and configured execution checks.

SUIVRE LA CONSÉQUENCE

The form can make a requirement clear. The server still needs to reject a request that bypasses the form.

Where this explanation comes from

An authored situation, grounded in the linked source guides. Choosing a case explores its expected responsibilities; it does not execute an operation.

Follow the input and output

UserInput is a SchemaModel with one required email field. The maintained declaration uses ScalarTypeEnum.EmailAddress(). Both input and output point to that model, so the example describes the same shape on either side.

Its authentication setting is anonymous because the example is demonstrating data flow. Treat that as an intentional property of this sample, not a default to copy into an operation that reads or changes private data.

typescript
io: {
  input: UserInput,
  output: UserInput,
},
policy: {
  auth: 'anonymous',
},

Exact partial contract excerpt from examples/minimal/src/contracts/user.ts at d58fa5b7.

Find the business implementation

The companion userInputHandler has a type derived from CreateUser and returns the provided email. The contract describes the boundary; this function supplies the implementation. Editing the declaration does not magically add persistence to this function.

To turn the example into a real account workflow, you would need to decide how accounts are stored, what happens when an address is already used, how identity is established and which outcome the caller receives. Those choices belong to your application.

typescript
return {
  email: input.email,
};

Exact handler excerpt from examples/minimal/src/handlers/user-input.handler.ts at d58fa5b7.

Make the next experiment observable

First inspect the example's typecheck, validation and smoke scripts. Its smoke test checks stable example metadata and the feature-to-operation reference; it is not an end-to-end API test.

For your own next step, bind a disposable handler to the registry and test a valid email, invalid input and an invalid handler result. Then expose that registry through one adapter. This adds one responsibility at a time and makes failures easy to locate.

See it in an example.

Contracts / Beginner

Write your first contract

Define an operation

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

  1. Describe the input
  2. Name the operation
  3. Follow the handler

Ce que montre la sourceThe maintained source declares user.create with a required email input and a typed output.

Ne démontre pasA 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.

  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 example establishes
Ce que montre la source
  • 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.
Ne démontre pas
  • 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.

Répertoire de travail examples/minimal

bun run smoke
bun run validate

Commands and source inspected; not executed here.

Continue from here.

Concepts

Contracts, handlers and adapters

3 min read

Understand the separate responsibilities that let one operation serve several interfaces.

Look inside the guideOpening context · complete reading path

The contract describes the behavior

An operation contract names a command or query and describes its data and requirements. The model includes metadata, input and output schemas, result definitions, policy, declared effects, transport hints and links to related presentations or tests.

Work through the guide
Concepts

Model inputs, outcomes and failures

3 min read

Make the data boundary explicit while keeping business meaning in the operation and handler.

Look inside the guideOpening context · complete reading path

Describe what the caller must supply

An input schema should express the shape you actually accept, including required values and constraints that can be checked before execution. Keep the distinction between an absent value and a valid empty value clear.

Work through the guide
Guides

Expose one operation through API and MCP

3 min read

Share the registered behavior while keeping authentication, transport formats and evidence explicit.

Look inside the guideOpening context · complete reading path

Start from one registry

Register the operation and bind its handler once. The REST createFetchHandler and MCP registerMcpTools implementations both call OperationSpecRegistry.executeResult. That shared invocation path is the useful connection between an API request and an agent tool call.

Work through the guide
Next: Adopt ContractSpec in an existing codebase →
Votre vue

Make room for your context.

Shape the presentation around this moment. You can change it whenever you need.

Votre contexte

The different parts of you

Choose a starting point

Un mélange utile de contexte, de visuels et de guidage discret.

Tune each dimension
Each dimension can change independently. Product permissions and available actions stay unchanged.

Support the way you begin and return

Tune your support

Confort de lecture

Choisir votre langue

La langue de l’interface change uniquement le texte. Les marchés, les prix et les parcours conservent leurs propres paramètres.

Couverture des traductions

Une partie du contenu est affichée en anglais.

Navigation151
Graphe616
Catégories378
Portfolio833
Exemples2 035
Aperçu de la source1 542

D’autres traductions seront ajoutées à mesure que le contenu sera relu.

Cette préférence est enregistrée dans ce navigateur.

Rechercher sur le site

Des points de départ utiles

Aucun résultat. Essayez une expression plus courte, un nom d’opération ou un autre périmètre de recherche.

UN PEU DE PLACE POUR EXPLORER

Trouvez quelque chose à explorer.

Ouvrez un aperçu détaillé sur cette page, essayez une autre perspective ou suivez le détail vers sa propre page.

Fonctionnement des aperçus et des commandes
01

Regarder avant de partir

Survolez un lien ou sélectionnez-le avec Tab pour voir un aperçu. Cliquer sur le lien d’origine ou appuyer sur Entrée ouvre toujours sa destination.

02

Rester dans le contexte

Entrez dans l’aperçu pour explorer ses sections. Depuis un lien sélectionné, utilisez Alt + ↓ pour y entrer au clavier. Échap le ferme.

03

Ouvrir les possibilités

Les lignes dépliables, les choix de perspective et les commandes mises en évidence révèlent davantage. Votre vue adapte le confort de lecture et le contexte exploré.

Un bouton séparé pour voir de plus près

Affichez de petits boutons d’aperçu à côté des liens quand l’espace le permet. Touchez l’œil pour examiner ou le lien pour y aller directement. Ce choix reste dans cet onglet.

Aucun historique de navigation n’est collecté. La réduction des animations suit votre appareil et Votre vue.