### Widgets

To generate transactional widgets (React + Dynamic UI), the operator initializes the base project with the `widgets-init-project` Prompt (it instructs invoking the `widgets-scaffold` Tool, which clones the canonical template at the tag pinned by the compatibility matrix). Two-step flow: first the scaffold, then the operator provides the functional description — do not write widget code before receiving it. Once initialized, read [`modyo://docs/widgets/INDEX`](modyo://docs/widgets/INDEX) for critical rules, patterns and workflow. The tools `widgets-list-components`, `widgets-get-component-props`, `widgets-list-patterns` federate the catalog of Dynamic UI's deployed Storybook; `widgets-validate` runs the validator (package `@modyo/widget-validator`) on a local or virtual widget and returns a `ValidationReport`. The optional Claude Code integration (`PostToolUse` hook for the validator) lives in [`modyo://docs/widgets/_meta-integration-claude-code`](modyo://docs/widgets/_meta-integration-claude-code).

**Catalog Resources** (read on demand, backed by versioned Storybook manifests):
- `modyo://widgets/catalog/components` — lightweight list (id, name, key, description, storyCount)
- `modyo://widgets/catalog/components/{componentId}` — full detail (stories with snippet code, props with TypeScript types, JSDoc tags)
- `modyo://widgets/catalog/patterns` — lightweight pattern list (id, name, title)
- `modyo://widgets/catalog/patterns/{patternId}` — full MDX content of a pattern story

These Resources serve official Storybook manifests from the versioned CDN. They also return story snippet code and MDX docs, which `widgets-list-components` and `widgets-list-patterns` do not. See the Pattern Discovery section below for when consultation is required.

### Pattern Discovery (REQUIRED before generating widget UI)

Before writing TSX for the widget's UI, you MUST query the catalog for an official pattern matching the domain of the request:

1. **List patterns**: read `modyo://widgets/catalog/patterns`.
2. **Identify candidates** by matching the request domain against pattern titles and ids (e.g. "transaction history" → `patterns-list-group--transaction-history`).
3. **If a candidate exists**: read `modyo://widgets/catalog/patterns/{patternId}` and use the MDX content as the structural and visual basis for the widget. Adapt to the request's specifics (data shape, locale, domain language) but PRESERVE the layout decisions, component composition, and styling conventions from the pattern.
4. **If no candidate exists**: state explicitly in the response that no official pattern matches, then proceed using only components from `modyo://widgets/catalog/components`.

This step is NOT optional even when the request seems simple. Patterns exist for common use cases (list views, detail panels, forms, dashboards) and apply more often than not.

### Deploy (outside the MCP)

When validation passes (widgets-validate returns passing: true), the widget is done from the MCP's perspective. Deployment runs through CI from the widget's own git repository (the scaffold initializes the repository, and creates the initial commit only when git `user.name` and `user.email` are configured). A manual push is the developer's explicit `modyo-cli push` in their own shell — the agent NEVER runs it.

NEVER include the user's `MODYO_TOKEN` or any credential value in the conversation. Do not read `MODYO_TOKEN` or the widget's `.env`/`.modyo` files into your own context, do not call the Modyo CLI or admin API with the token, and do not echo token material in the chat.
