--- name: spirit:figma-to-code description: >- Implement production React UI from a Figma design using @alma-oss/spirit-web-react. Use when the requested output is React code and a Figma node, URL, selection, screenshot, or specification is provided. Do not use for design review, Code Connect authoring, code-to-Figma workflows, or non-React Spirit packages. --- # Figma to Code Convert a Figma design into React with `@alma-oss/spirit-web-react`. Target this repository’s current main / latest APIs. Do not invent APIs, tokens, breakpoints, routes, data, or assets. Do **not** use this skill for: - Design-system review or handoff reports — use `/spirit:review-figma-design` - Writing or updating Figma Code Connect mappings - Building or syncing designs **in** Figma from code - Vanilla `packages/web` markup or other non-React packages ## References - [Component selection](references/component-selection.md) - [Layout](references/layout.md) - [Typography](references/typography.md) - [Cards](references/cards.md) - [Forms](references/forms.md) - Accessibility: `/spirit:accessibility` ## Source Authority Resolve conflicts in this order. A later source does not override an earlier one. 1. **Valid APIs, defaults, deprecations, composition** — current Spirit source in this order: implementation, public types, `packages/web-react/DEPRECATIONS.md`, then the component README. If those disagree, implementation and types win. Do not copy stale README examples. 2. **Component identity and variants** — Figma Code Connect mappings (when present). 3. **Visual measurements, tokens, assets** — Figma design context, variables, and exported assets. 4. **Behavior, copy, routing, and accessibility** — product requirements and the surrounding app. Normalize Code Connect and generated snippets to the current API: replace removed or deprecated props, omit values equal to current defaults, and keep design intent. Code Connect is not always complete or up to date. Nested `CardLink` is a common omission: a “Card Basic” snippet with a bare `CardTitle` is not proof the card is static if the title node uses a `themed/link/…` token. See [Cards](references/cards.md). Never guess from screenshots. If Figma data, Code Connect, or product context is missing, stop, list the assumptions, and ask. Do not silently invent breakpoints, icon names, colors, spacing, accessible names, hrefs, or image sources. ## Workflow ### 1. Acquire the Design If a Figma design-to-code skill is available, follow it before calling `get_design_context`. 1. Parse a Figma URL when provided (`fileKey`, `nodeId` from `node-id` with `-` → `:`). If the MCP needs `fileKey` even for the current selection, ask for a node URL instead of guessing. 2. Call `get_design_context` first. Treat the returned code as a **reference**, not paste-ready output. Adapt it to Spirit React. 3. Use supporting tools only when needed: metadata to pick a node, variable definitions for tokens, screenshots for visual comparison, asset download for images/icons, motion context for animation. 4. When the MCP lets you set client context, request React and TypeScript. ### 2. Map Structure, Not Figma’s Layer Count Preserve reading order, visual grouping, max-width boundaries, and Spirit composition contracts. Figma frames often exist for editing, clipping, or naming — they are not 1:1 DOM nodes. - Use a Spirit component when it owns the needed semantics, behavior, or styling contract. Match Figma names and layout patterns first, then search for an existing composite (`PricingPlan` + `Matrix`, `ScrollView`, `Stack`). See [Component selection](references/component-selection.md). - Use native semantic elements (`p`, `ul`/`ol`/`li`, `article`, `form`) when no Spirit component is responsible, including inside Card body content. - Do not wrap extra layout components around Card, Dialog, Drawer, or other families that require a flat, ordered composition. - Add `Container` only where a distinct width constraint exists. See [Layout](references/layout.md). - When the design is a form, wrap **both** the field area and the action buttons in a named native `