figma-design
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFigma Design
Figma 设计
Access Figma designs, design systems, and components for frontend implementation. Extract design tokens, component specifications, and visual assets to ensure pixel-perfect implementation.
访问Figma设计稿、设计系统与组件,用于前端开发实现。提取设计令牌、组件规格与视觉资源,确保像素级精准的UI实现。
Quick Start
快速开始
- Identify design source - Get Figma file URL, frame names, or component IDs from designer
- Extract design tokens - Use or
get_design_systemfor colors, typography, spacingexport_tokens - Get component details - Use ,
get_node_infofor structure, variants, statesget_component - Download assets - Use or
download_design_assetsfor images, iconsexport_node_as_image - Implement with fidelity - Apply to extracted tokens, maintain visual quality
frontend-philosophy
- 确定设计来源 - 从设计师处获取Figma文件URL、框架名称或组件ID
- 提取设计令牌 - 使用或
get_design_system获取颜色、排版、间距信息export_tokens - 获取组件详情 - 使用、
get_node_info获取结构、变体、状态信息get_component - 下载资源 - 使用或
download_design_assets获取图片、图标export_node_as_image - 高还原度实现 - 将提取的令牌应用于,维持视觉品质
frontend-philosophy
Workflow
工作流程
0) If any MCP call fails because Figma MCP is not connected, pause and set it up:
0) 若因未连接Figma MCP导致MCP调用失败,请暂停并完成以下设置:
- Add the Figma MCP:
codex mcp add figma --url https://mcp.figma.com/mcp
- Enable remote MCP client:
- Set in
[features].rmcp_client = trueor runconfig.tomlcodex --enable rmcp_client
- Set
- Log in with OAuth (or configure API token):
codex mcp login figma- OR set environment variable
FIGMA_ACCESS_TOKEN
After successful login, the user will have to restart codex. You should finish your answer and tell them so when they try again they can continue with Step 1.
- 添加Figma MCP:
codex mcp add figma --url https://mcp.figma.com/mcp
- 启用远程MCP客户端:
- 在中设置
config.toml或 运行[features].rmcp_client = truecodex --enable rmcp_client
- 在
- 通过OAuth登录(或配置API令牌):
codex mcp login figma- 或 设置环境变量
FIGMA_ACCESS_TOKEN
登录成功后,用户需重启codex。完成此步骤后,请告知用户下次尝试时可继续执行步骤1。
1) Understand the Design Context
1) 理解设计上下文
Before extracting any data, clarify:
- What Figma file or frame contains the design?
- Is there a design system or shared library?
- What component(s) need implementation?
- Are there specific variants or states (hover, active, disabled)?
- What framework is being used (React, Vue, HTML/CSS)?
Tools to use:
- - Get file structure overview
get_document_info - - List all nodes in file
get_file_nodes - - Export file structure as ASCII tree
get_tree
提取数据前,请明确:
- 设计包含在哪个Figma文件或框架中?
- 是否存在设计系统或共享库?
- 需要实现哪些组件?
- 是否有特定变体或状态(悬停、激活、禁用)?
- 使用的框架是什么(React、Vue、HTML/CSS)?
可使用工具:
- - 获取文件结构概览
get_document_info - - 列出文件中所有节点
get_file_nodes - - 将文件结构导出为ASCII树形图
get_tree
2) Extract Design System Tokens
2) 提取设计系统令牌
Design tokens are the foundation of consistent UI implementation.
Colors:
- - List all color styles
get_styles - - Export as CSS variables
export_tokens({ format: "css" }) - - Export as Tailwind config
export_tokens({ format: "tailwind" }) - - Export as JSON
export_tokens({ format: "json" })
Typography:
- - List all text styles
get_styles - Extract font families, sizes, weights, line heights
- Map to distinctive fonts (avoid Inter, Roboto)
frontend-philosophy
Spacing & Layout:
- with
get_node_infoprojection - Get padding, gaps, auto-layout@layout - Extract spacing scale (4px, 8px, 16px, 24px, etc.)
- Identify layout patterns (flexbox, grid)
Effects:
- - List effect styles (shadows, blurs)
get_styles - - Extract exact CSS for shadows, borders, opacity
get_css
设计令牌是一致UI实现的基础。
颜色:
- - 列出所有颜色样式
get_styles - - 导出为CSS变量
export_tokens({ format: "css" }) - - 导出为Tailwind配置
export_tokens({ format: "tailwind" }) - - 导出为JSON格式
export_tokens({ format: "json" })
排版:
- - 列出所有文本样式
get_styles - 提取字体族、字号、字重、行高
- 映射到推荐的特色字体(避免使用Inter、Roboto)
frontend-philosophy
间距与布局:
- 使用投影调用
@layout- 获取内边距、间距、自动布局信息get_node_info - 提取间距刻度(4px、8px、16px、24px等)
- 识别布局模式(flexbox、grid)
效果:
- - 列出效果样式(阴影、模糊)
get_styles - - 提取阴影、边框、透明度的精确CSS代码
get_css
3) Get Component Specifications
3) 获取组件规格
For each component to implement:
Structure:
- - Get hierarchy and dimensions
get_node_info({ node_id, select: ["@structure", "@bounds"] }) - - Get component details and variants
get_component - - Audit all project components
list_local_components - - Access team library components
list_remote_components
Styling:
- - Extract CSS properties (fills, strokes, effects, corner radius)
get_css({ node_id }) - - Get detailed styling data
get_node_info({ node_id, select: ["@css"] }) - Note: Apply - enhance generic styles with intentional color and atmosphere
frontend-philosophy
Variants & States:
- returns all variants (Primary/Secondary, Small/Medium/Large)
get_component - for each variant to understand differences
get_node_info - Map to component props (e.g., ,
variant="primary")size="large"
Accessibility:
- Check for accessibility labels in Figma annotations
- Extract semantic roles (button, link, heading)
- Verify color contrast meets WCAG standards
针对每个需要实现的组件:
结构:
- - 获取层级结构与尺寸
get_node_info({ node_id, select: ["@structure", "@bounds"] }) - - 获取组件详情与变体
get_component - - 审核项目中所有组件
list_local_components - - 访问团队库组件
list_remote_components
样式:
- - 提取CSS属性(填充、描边、效果、圆角)
get_css({ node_id }) - - 获取详细样式数据
get_node_info({ node_id, select: ["@css"] }) - 注意:应用- 用有目的性的色彩与氛围优化通用样式
frontend-philosophy
变体与状态:
- 返回所有变体(主/次按钮、小/中/大尺寸)
get_component - 为每个变体调用以理解差异
get_node_info - 映射到组件属性(如、
variant="primary")size="large"
无障碍性:
- 检查Figma注释中的无障碍标签
- 提取语义角色(按钮、链接、标题)
- 验证颜色对比度符合WCAG标准
4) Download Visual Assets
4) 下载视觉资源
Images & Icons:
- - Export icons as SVG
export_node_as_image({ node_id, format: "svg" }) - - Export images at 2x
export_node_as_image({ node_id, format: "png", scale: 2 }) - - Batch download all assets
download_design_assets({ figma_url, local_path })
Reference Images:
- includes
download_design_assetsfor visual contextreference.png - Use reference image with tool for visual comparison during implementation
zai-vision_*
图片与图标:
- - 将图标导出为SVG格式
export_node_as_image({ node_id, format: "svg" }) - - 以2倍分辨率导出图片
export_node_as_image({ node_id, format: "png", scale: 2 }) - - 批量下载所有资源
download_design_assets({ figma_url, local_path })
参考图片:
- 包含
download_design_assets用于视觉上下文参考reference.png - 实现过程中可将参考图片与工具配合使用,进行视觉对比
zai-vision_*
5) Implement with Design Fidelity
5) 高还原度实现
Apply extracted tokens while maintaining :
frontend-philosophyTypography:
- If Figma uses generic fonts (Inter, Roboto), suggest distinctive alternatives
- Maintain hierarchy and scale from design tokens
- Apply proper font weights and line heights
Color:
- Extract color palette from Figma
- If palette is generic gray/blue, propose bold intentional alternatives
- Maintain contrast ratios for accessibility
Spacing:
- Use exact padding, margins, gaps from auto-layout properties
- Apply brave spatial composition (generous negative space OR controlled density)
Effects:
- Extract shadows, blurs, gradients from Figma
- Layer visual richness (gradient meshes, noise textures) per
frontend-philosophy
Motion:
- Figma prototypes may specify transitions
- Add purposeful motion that enhances UX (not decorative)
应用提取的令牌同时遵循:
frontend-philosophy排版:
- 若Figma使用通用字体(Inter、Roboto),建议替换为特色替代字体
- 维持设计令牌中的层级与刻度
- 应用合适的字重与行高
颜色:
- 从Figma提取调色板
- 若调色板为通用灰/蓝色系,建议改用大胆且有目的性的替代方案
- 维持符合无障碍要求的对比度
间距:
- 使用自动布局属性中的精确内边距、外边距、间距值
- 应用大胆的空间构图(充足留白或可控密度)
效果:
- 从Figma提取阴影、模糊、渐变效果
- 根据添加视觉层次感(渐变网格、噪点纹理)
frontend-philosophy
动效:
- Figma原型可能指定了过渡效果
- 添加能增强UX的有目的性动效(而非装饰性动效)
6) Verify Implementation
6) 验证实现效果
Visual Comparison:
- Export Figma frame as PNG:
export_node_as_image - Screenshot implemented component
- Use to compare for pixel-perfect accuracy
zai-vision_*
Responsive Behavior:
- Check Figma constraints (fixed, stretch, scale)
- Implement responsive breakpoints
- Test on multiple viewport sizes
Accessibility:
- Verify color contrast with Figma accessibility plugin data
- Add ARIA labels and semantic HTML
- Test keyboard navigation
视觉对比:
- 使用将Figma框架导出为PNG
export_node_as_image - 对已实现的组件截图
- 使用工具对比,确保像素级精准
zai-vision_*
响应式表现:
- 检查Figma约束(固定、拉伸、缩放)
- 实现响应式断点
- 在多个视口尺寸上测试
无障碍性:
- 验证颜色对比度符合Figma无障碍插件数据
- 添加ARIA标签与语义化HTML
- 测试键盘导航
Available Tools
可用工具
Document Navigation
文档导航
- - Get file overview and structure
get_document_info - - List all nodes in file
get_file_nodes - - Export file structure as ASCII tree with node IDs
get_tree - - Get currently selected elements in Figma
get_selection - - Switch to specific page
set_current_page
- - 获取文件概览与结构
get_document_info - - 列出文件中所有节点
get_file_nodes - - 将文件结构导出带节点ID的ASCII树形图
get_tree - - 获取Figma中当前选中的元素
get_selection - - 切换到指定页面
set_current_page
Design System Extraction
设计系统提取
- - List all styles (color, text, effect, grid)
get_styles - - Export design tokens to CSS/JSON/Tailwind
export_tokens - - Extract CSS properties from nodes
get_css - - Audit project components
get_local_components - - Access team library components
get_remote_components
- - 列出所有样式(颜色、文本、效果、网格)
get_styles - - 将设计令牌导出为CSS/JSON/Tailwind格式
export_tokens - - 从节点提取CSS属性
get_css - - 审核项目组件
get_local_components - - 访问团队库组件
get_remote_components
Component Analysis
组件分析
- - Inspect specific node properties (use projections:
get_node_info,@structure,@css,@layout,@typography)@tokens - - Batch inspect multiple nodes
get_nodes_info - - Get component details and variants
get_component - - Use components in designs
create_component_instance
- - 检查特定节点属性(使用投影:
get_node_info、@structure、@css、@layout、@typography)@tokens - - 批量检查多个节点
get_nodes_info - - 获取组件详情与变体
get_component - - 在设计中使用组件
create_component_instance
Asset Export
资源导出
- - Export as PNG/SVG/JPG
export_node_as_image - - Batch download assets with reference image
download_design_assets - - Find all text layers for content audit
scan_text_nodes
- - 导出为PNG/SVG/JPG格式
export_node_as_image - - 批量下载资源及参考图片
download_design_assets - - 查找所有文本图层用于内容审核
scan_text_nodes
Query API (Advanced)
查询API(进阶)
- - Use Figma Query DSL for token-efficient searches
query- Projections: ,
@structure,@bounds,@css,@layout,@typography,@tokens,@images@all - Filters: ,
$match,$eq,$in,$gt$lt - Example:
{ "from": ["COMPONENT"], "where": { "name": { "$match": "Button*" } }, "select": ["@structure", "@css"] }
- Projections:
- - 使用Figma Query DSL进行高效搜索
query- 投影:、
@structure、@bounds、@css、@layout、@typography、@tokens、@images@all - 过滤器:、
$match、$eq、$in、$gt$lt - 示例:
{ "from": ["COMPONENT"], "where": { "name": { "$match": "Button*" } }, "select": ["@structure", "@css"] }
- 投影:
Practical Workflows
实用工作流程
Design Handoff
设计交付
Goal: Extract complete design specifications for implementation
- - Understand file structure
get_document_info - - Get node IDs for target frames
get_tree - - Export design system
export_tokens({ format: "tailwind" }) - - Get component details
get_node_info({ node_id, select: ["@all"] }) - - Download assets + reference.png
download_design_assets - Implement component using extracted data
目标: 提取完整设计规格用于开发实现
- - 理解文件结构
get_document_info - - 获取目标框架的节点ID
get_tree - - 导出设计系统
export_tokens({ format: "tailwind" }) - - 获取组件详情
get_node_info({ node_id, select: ["@all"] }) - - 下载资源及reference.png
download_design_assets - 使用提取的数据实现组件
Design System Audit
设计系统审核
Goal: Inventory design tokens and components for consistency
- - List all color, text, effect styles
get_styles - - Get all components with usage count
list_local_components - - Export tokens for analysis
export_tokens({ format: "json" }) - Identify inconsistencies (duplicate colors, similar components)
- Recommend consolidation or cleanup
目标: 盘点设计令牌与组件,确保一致性
- - 列出所有颜色、文本、效果样式
get_styles - - 获取所有组件及其使用次数
list_local_components - - 导出令牌用于分析
export_tokens({ format: "json" }) - 识别不一致性(重复颜色、相似组件)
- 建议合并或清理方案
Component Library Migration
组件库迁移
Goal: Convert Figma components to code components
- - Get component inventory
list_local_components - For each component:
- - Get variants and properties
get_component - - Extract styling
get_css - - Get layout properties
get_node_info({ select: ["@layout"] })
- Generate component code (React, Vue, etc.)
- Create Storybook stories or documentation
目标: 将Figma组件转换为代码组件
- - 获取组件清单
list_local_components - 针对每个组件:
- - 获取变体与属性
get_component - - 提取样式
get_css - - 获取布局属性
get_node_info({ select: ["@layout"] })
- 生成组件代码(React、Vue等)
- 创建Storybook示例或文档
Visual QA & Pixel Perfection
视觉QA与像素级精准
Goal: Ensure implementation matches design exactly
- - Export design
export_node_as_image({ node_id, format: "png", scale: 2 }) - Screenshot implemented component
- Use for visual comparison
zai-vision_* - Identify discrepancies (spacing, colors, shadows)
- Fix implementation and re-verify
目标: 确保实现效果与设计完全匹配
- - 导出设计稿
export_node_as_image({ node_id, format: "png", scale: 2 }) - 对已实现的组件截图
- 使用进行视觉对比
zai-vision_* - 识别差异(间距、颜色、阴影)
- 修复实现并重新验证
Design Token Synchronization
设计令牌同步
Goal: Keep code tokens in sync with Figma
- - Export current tokens
export_tokens({ format: "css" }) - Compare with existing CSS variables or Tailwind config
- Identify changes (new colors, updated spacing)
- Update code design system
- Document changes and notify team
目标: 保持代码令牌与Figma同步
- - 导出当前令牌
export_tokens({ format: "css" }) - 与现有CSS变量或Tailwind配置对比
- 识别变更(新颜色、更新的间距)
- 更新代码中的设计系统
- 记录变更并通知团队
Tips for Maximum Productivity
高效使用技巧
- Use projections for efficient queries - fetches only needed data
select: ["@structure", "@css"] - Batch node inspections - Use for multiple nodes instead of individual calls
get_nodes_info - Export tokens early - Get design system tokens before diving into components
- Download reference images - Visual context helps with implementation decisions
- Map Figma variants to props - Component variants become component props (e.g., ,
variant,size)state - Use Query DSL for large files - More token-efficient than fetching entire files
- Cache component IDs - Reuse node IDs across multiple queries
- Verify with visual comparison - Always compare exported design vs. implementation
- 使用投影实现高效查询 - 仅获取所需数据
select: ["@structure", "@css"] - 批量节点检查 - 使用处理多个节点,替代多次单独调用
get_nodes_info - 尽早导出令牌 - 在深入组件前先获取设计系统令牌
- 下载参考图片 - 视觉上下文有助于实现决策
- 将Figma变体映射到属性 - 组件变体对应组件属性(如、
variant、size)state - 对大文件使用Query DSL - 比获取整个文件更高效
- 缓存组件ID - 在多次查询中复用节点ID
- 通过视觉对比验证 - 始终对比导出的设计稿与实现效果
Troubleshooting
故障排查
- Authentication Errors: Re-run OAuth (); verify workspace access; check API token permissions
codex mcp login figma - File Not Found: Verify Figma URL is correct and accessible; check file hasn't been moved or deleted
- Node Not Found: Use to find correct node IDs; verify node hasn't been deleted
get_tree - Export Failures: Check node type supports export (frames, components); verify export settings; try different format (PNG vs SVG)
- Missing Fonts: Pre-load custom fonts with before setting font names
load_font_async - Component Import Timeout: Use for local components; increase timeout for remote library components
getNodeByIdAsync - Token Export Issues: Verify design uses variables/styles (not raw values); check file has defined color/text styles
- Rate Limits: Batch operations; use Query DSL for efficient data fetching; implement exponential backoff
- 认证错误:重新运行OAuth登录();验证工作区访问权限;检查API令牌权限
codex mcp login figma - 文件未找到:验证Figma URL正确且可访问;检查文件是否被移动或删除
- 节点未找到:使用查找正确的节点ID;验证节点未被删除
get_tree - 导出失败:检查节点类型支持导出(框架、组件);验证导出设置;尝试不同格式(PNG vs SVG)
- 字体缺失:在设置字体名称前使用预加载自定义字体
load_font_async - 组件导入超时:对本地组件使用;增加远程库组件的超时时间
getNodeByIdAsync - 令牌导出问题:验证设计使用了变量/样式(而非原始值);检查文件是否定义了颜色/文本样式
- 速率限制:批量操作;使用Query DSL实现高效数据获取;实现指数退避策略
Integration with Frontend Workflow
与前端工作流集成
When working with the agent:
frontend- Load this skill first: before implementation
skill("figma-design") - Extract design tokens as foundation for styling
- Get component specs for structure and variants
- Apply frontend-philosophy to elevate generic Figma designs:
- Replace generic fonts with distinctive alternatives
- Enhance color palettes with bold, intentional choices
- Add atmosphere and depth (gradients, shadows, textures)
- Implement purposeful motion
- Verify visual fidelity with exported reference images
See for detailed step-by-step process.
reference/design-handoff-workflow.md与 agent协作时:
frontend- 先加载此技能:在实现前调用
skill("figma-design") - 提取设计令牌作为样式基础
- 获取组件规格用于结构与变体实现
- 应用frontend-philosophy优化通用Figma设计:
- 用特色替代字体替换通用字体
- 用大胆、有目的性的选择增强调色板
- 添加氛围与层次感(渐变、阴影、纹理)
- 实现有目的性的动效
- 通过导出的参考图片验证视觉还原度
详细分步流程请查看。
reference/design-handoff-workflow.mdReferences and Examples
参考资料与示例
- - How to export and apply design tokens
reference/design-token-extraction.md - - Step-by-step component conversion
reference/component-implementation-guide.md - - Query DSL syntax and examples
reference/figma-query-dsl.md - - Complete button component workflow
examples/button-component-extraction.md - - Migrating Figma design system to code
examples/design-system-migration.md
- - 如何导出与应用设计令牌
reference/design-token-extraction.md - - 组件转换分步指南
reference/component-implementation-guide.md - - Query DSL语法与示例
reference/figma-query-dsl.md - - 完整按钮组件工作流
examples/button-component-extraction.md - - 将Figma设计系统迁移到代码 ",
examples/design-system-migration.md