メインコンテンツまでスキップ

Figma → Code Implementation Workflow

Overview

Translating Figma designs into code faithfully requires more than just a prompt. High-quality implementation depends on four elements working together:

ElementDescription
Figma design rulesToken, component, and variant naming and structural conventions
Code design rulesHow to reference design tokens, component decomposition granularity
Skills / RulesReview patterns and guidelines passed to the LLM
Staged flowStrict ordering: read spec → plan → implement → review → fix

Without these, the most common problems are hardcoded token values, reimplementing existing components, and drift from the design specification.

Integration with river-review

river-review ships two midstream skills that handle Figma → code quality checks.

design-token-enforcement

Detects hardcoded design token values. Issues a warning when colors, font sizes, spacing, or other values are embedded directly rather than referenced through design system variables.

design-system-component-reuse

Detects reimplemented components. Reports cases where an equivalent implementation already exists in the component library but has been redefined inline.

Both skills run automatically in the midstream phase (post-PR review). No explicit activation is needed.

Step 1: Read the design specification via Figma MCP
- Use get_design_context to retrieve component and token information
- Use get_screenshot to verify visuals

Step 2: Build a component mapping table
- List Figma component names ↔ code component names
- Distinguish between existing components to reuse and new ones to create

Step 3: Output an implementation plan (do not write code yet)
- Document file structure, dependencies, and token reference approach
- Request a team review of the plan

Step 4: Implement one component at a time
- Follow the mapping table for imports, props, and styles
- Always reference design tokens through variables/constants

Step 5: Review with river-review (detect token violations and reimplementations)
- Opening a PR triggers the midstream phase automatically
- Check results from design-token-enforcement and design-system-component-reuse

Step 6: Fix the diff
- Resolve all Critical / Major findings before requesting re-review
- Track Minor findings in a follow-up issue for the next sprint

Example Agent Prompts

Discovery (Steps 1–2)

Read the design specification from Figma at <URL> and extract:
1. A list of components used (Figma name / code name / whether new creation is needed)
2. The color tokens and spacing tokens present
3. A classification of which existing library components can be reused vs. newly created

Do not implement anything yet. Output as a mapping table.

Implementation (Step 4)

Using the mapping table below, implement <ComponentName>:
- Figma spec: <URL>
- Design token import path: <path>
- Existing component import path: <path>

Constraints:
- Always use token variables for colors, fonts, and spacing
- Reuse existing components whenever they are available
- Implement only one component at a time

Fix (Step 6)

river-review returned the following findings:
<paste findings here>

Fix each finding according to this policy:
- Hardcoded token → replace with the corresponding design token variable
- Reimplementation → import and use the existing component instead

After fixing, report the list of changed locations.

Common Failure Patterns

CauseWhat happensMitigation
Skipping Step 3 and jumping straight to codeOverall structure drifts without a planNever skip the planning phase
Manually reading tokens instead of using Figma MCPTypos and misread token namesUse get_design_context for accurate values
Requesting multiple components in one promptCross-component dependencies tangle and debugging becomes hardEnforce one request = one component
Ignoring review findings before mergingToken violations ship to productionTreat Critical / Major as merge blockers
Not checking for existing componentsLibrary bloats and consistency is lostAlways complete the mapping table in Step 2