一键导入
figma-bridge
How to use Figma MCP and Variables2CSS to read designs from Figma and generate code consistent with tokens. Use when the designer shares a Figma link.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
How to use Figma MCP and Variables2CSS to read designs from Figma and generate code consistent with tokens. Use when the designer shares a Figma link.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | figma-bridge |
| description | How to use Figma MCP and Variables2CSS to read designs from Figma and generate code consistent with tokens. Use when the designer shares a Figma link. |
| user-invocable | false |
| disable-model-invocation | true |
Structured workflow to translate Figma designs into production-ready code with 1:1 visual fidelity. Ensures integration with the Figma MCP server, correct use of design tokens, and visual parity with mockups.
.mcp.json (automatically created by init-project.sh). On first session, authenticate: /mcp → figma → Authenticate → Allow Access.https://figma.com/design/:fileKey/:fileName?node-id=1-2figma-desktop MCP: direct node selection in the desktop app (no URL required)If an MCP call fails because the Figma server is not connected, stop and configure:
.mcp.json in the project root contains the figma server (see references/figma-mcp-setup.md)init-project.sh/mcp → figma → Authenticate → Allow Accessget_screenshot on a known node)Once configured, this step does not need to be repeated in subsequent sessions (the OAuth token is persisted).
URL format: https://figma.com/design/:fileKey/:fileName?node-id=1-2
Extract:
/design/node-id parameterExample:
https://figma.com/design/kL9xQn2VwM8pYrTb4ZcHjF/DesignSystem?node-id=42-15kL9xQn2VwM8pYrTb4ZcHjF42-15With the desktop MCP, tools automatically use the selected node in the open file. No need to pass fileKey.
Use get_design_context with the extracted file key and node ID:
get_design_context(fileKey=":fileKey", nodeId="1-2")
Provides:
If the response is truncated or too large:
get_metadata(fileKey=":fileKey", nodeId="1-2") to get the high-level node mapget_design_context(fileKey=":fileKey", nodeId=":childNodeId")Use get_screenshot as the visual source of truth:
get_screenshot(fileKey=":fileKey", nodeId="1-2")
Don't rely solely on the data structure — the screenshot confirms the expected appearance. Keep it accessible throughout the implementation.
Download images, icons, and SVGs returned by the Figma MCP server.
Asset rules:
localhost source for an image or SVG, use it directlylocalhost source is availableUse get_variable_defs to verify that design tokens match those in the theme CSS files. Flag discrepancies to the designer.
Read these CSS files for actual values — don't rely on markdown tables:
| File | Content |
|---|---|
{{TOKEN_FILE_THEME}} | @theme {} block — colors, spacing, radius, font, breakpoints, gradients |
{{TOKEN_FILE_CUSTOM_PROPS}} | :root semantic CSS vars |
{{TOKEN_FILE_SEMANTIC}} | @utility for semantic colors, bg, border, link |
{{TOKEN_FILE_TYPOGRAPHY}} | Heading and body classes |
Generate code based on the structure read from MCP, not invented layout.
Principles:
{{COMPONENTS_CATALOG}} — use existing components where possibleaccessibility)Report completion to the user. Visual verification is the user's responsibility — if they provide a screenshot for comparison, adjust the implementation accordingly.
component-workflow step 5.5)rtds-heading-N or rtds-body-N class)Figma Variables
↓
Variables2CSS plugin (in browser)
↓
{{TOKEN_FILE_THEME}} (@theme block)
↓
{{TOKEN_FILE_CUSTOM_PROPS}} (:root vars)
{{TOKEN_FILE_SEMANTIC}} (semantic @utility)
↓
TW4 classes with project prefix (e.g.: {{PREFIX}}:bg-primary-500, {{PREFIX}}:p-4)
+ semantic utilities (e.g.: {{PREFIX}}-content-01, {{PREFIX}}-background-primary)
When the designer updates tokens in Figma:
{{TOKEN_FILE_THEME}} / {{TOKEN_FILE_CUSTOM_PROPS}}No need to modify app.css — the @theme mapping uses var() which updates automatically.
| Figma Property | How to find the value | Example class/variable |
|---|---|---|
| Fill > color | 1) Find hex. 2) Search in {{TOKEN_FILE_THEME}}. 3) Search semantic var in {{TOKEN_FILE_CUSTOM_PROPS}}. 4) Use var or utility from {{TOKEN_FILE_SEMANTIC}} | var(--color-content-primary) or {{PREFIX}}-content-primary or {{PREFIX}}:bg-primary-500 |
| Auto Layout > Gap | px / 4 = Tailwind number. E.g.: 16px / 4 = 4 | {{PREFIX}}:gap-4 |
| Padding | px / 4 = Tailwind number. E.g.: 24px / 4 = 6 | {{PREFIX}}:p-6, {{PREFIX}}:px-8 |
| Corner Radius | Search in {{TOKEN_FILE_THEME}} → --radius-* | {{PREFIX}}:rounded-md, {{PREFIX}}:rounded-lg |
| Drop Shadow | Search in {{TOKEN_FILE_THEME}} → --shadow-* | {{PREFIX}}:shadow-sm, {{PREFIX}}:shadow-md |
| Font Outfit | Use heading class matching the size | .{{PREFIX}}-heading-1 ... .{{PREFIX}}-heading-6 |
| Font DM Sans | Use body class matching the size | .{{PREFIX}}-body-xs ... .{{PREFIX}}-body-xl |
| Semantic color | Search in {{TOKEN_FILE_SEMANTIC}} for the utility class | {{PREFIX}}-content-01, {{PREFIX}}-background-primary |
Quick spacing rule:
Figma px / 4 = Tailwind class number. E.g.: 32px ={{PREFIX}}:p-8, 48px ={{PREFIX}}:p-12Quick typography rule: Outfit →
{{PREFIX}}-heading-N, DM Sans →{{PREFIX}}-body-NFull tables for spacing, typography, and colors: see
component-workflowskill, section 5.5.
{{TOKEN_FILE_THEME}} — might be a color with a different name| Issue | Cause | Solution |
|---|---|---|
| Truncated Figma output | Design too complex or too many nested levels | Use get_metadata for the node map, then fetch individual children with get_design_context |
| Design doesn't match after implementation | Visual discrepancies between code and mockup | Compare side-by-side with the Step 3 screenshot. Check spacing, colors, and typography in context data |
| Assets not loading | MCP assets endpoint not accessible or URLs changed | Verify the Figma MCP assets endpoint is accessible. Use localhost URLs directly without modifications |
| Token values differ from Figma | Project tokens have different values than those in the design | Prefer project tokens for consistency, but adjust spacing/sizing to maintain visual fidelity |
The user shares: https://figma.com/design/kL9xQn2VwM8pYrTb4ZcHjF/DesignSystem?node-id=42-15
Actions:
kL9xQn2VwM8pYrTb4ZcHjF, nodeId=42-15get_design_context(fileKey="kL9xQn2VwM8pYrTb4ZcHjF", nodeId="42-15")get_screenshot(fileKey="kL9xQn2VwM8pYrTb4ZcHjF", nodeId="42-15") for visual reference{{COMPONENTS_CATALOG}}primary-500, primary-hover)Result: Component that respects the Figma design, integrated into the project's design system.
The user shares: https://figma.com/design/pR8mNv5KqXzGwY2JtCfL4D/Pages?node-id=10-5
Actions:
pR8mNv5KqXzGwY2JtCfL4D, nodeId=10-5get_metadata(fileKey="pR8mNv5KqXzGwY2JtCfL4D", nodeId="10-5") to understand the structure (complex page)get_design_context for each main sectionget_screenshot(fileKey="pR8mNv5KqXzGwY2JtCfL4D", nodeId="10-5") for the full page{{COMPONENTS_CATALOG}}Result: Complete page layout, faithful to the design, with reused design system components.
Don't implement based on assumptions. Always run get_design_context and get_screenshot before writing code.
Compare your code with the Figma screenshot and design context data during implementation. Verify spacing, typography, and colors using the token mapping tables. If you have doubts about fidelity, flag it to the user.
If you must deviate from the Figma design (e.g., for accessibility, technical constraints, or framework limitations), document the reason with a code comment.
When in doubt, prefer the project's design system patterns over a literal Figma translation. Codebase consistency matters more than exact replication.
Always check {{COMPONENTS_CATALOG}} for existing components before creating new ones. Extend rather than duplicate.
references/figma-tools-and-prompts.md — Complete MCP tool catalog and prompt patternsreferences/figma-mcp-setup.md — Setup, verification, and troubleshooting for the Figma MCP serverAudit and improve web accessibility following WCAG 2.1 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible".
Optimize web performance for faster loading and better user experience. Use when asked to "speed up my site", "optimize performance", "reduce load time", "fix slow loading", "improve page speed", or "performance audit".
Optimize for search engine visibility and ranking. Use when asked to "improve SEO", "optimize for search", "fix meta tags", "add structured data", "sitemap optimization", or "search engine optimization".
WordPress operations with WP-CLI — search-replace, plugin/theme management, cron, cache, DB export/import, automation. Always-active rules when using wp commands.
WCAG 2.2 checklist for accessible markup. Always-active rules for every generated interface.
WordPress backend performance optimization — profiling, queries, object cache, autoload, cron, and remote HTTP. Always-active rules when investigating slowness issues.