code-connect-components by figma/mcp-server-guide
npx skills add https://github.com/figma/mcp-server-guide --skill code-connect-components此技能帮助您使用 Figma 的 Code Connect 功能,将 Figma 设计组件与其对应的代码实现连接起来。它会分析 Figma 设计结构,在您的代码库中搜索匹配的组件,并建立映射以保持设计与代码的一致性。
get_code_connect_suggestions)是否可用,来验证 Figma MCP 服务器是否已连接。https://figma.com/design/:fileKey/:fileName?node-id=1-2
node-id 参数。没有它,Code Connect 映射将失败。请按顺序执行以下步骤。不要跳过任何步骤。
调用 get_code_connect_suggestions 以在一次操作中识别所有未映射的组件。此工具会自动:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
解析 URL 以提取 fileKey 和 nodeId,然后调用 get_code_connect_suggestions。
重要: 从 Figma URL 提取节点 ID 时,请转换格式:
node-id=1-2nodeId=1:2解析 Figma URL:
https://figma.com/design/:fileKey/:fileName?node-id=1-2:fileKey(/design/ 之后的片段)1-2,然后转换为 1:2 以供工具使用get_code_connect_suggestions(fileKey=":fileKey", nodeId="1:2")
处理响应:
对于 get_code_connect_suggestions 返回的每个未映射组件,在代码库中搜索匹配的代码组件。
查找内容:
src/components/、components/、ui/ 等)搜索策略:
示例搜索模式:
Button.tsx、PrimaryButton.tsx、Button.jsxsrc/components/、app/components/、lib/ui/variant、size、color展示您的发现,并让用户选择要创建哪些映射。用户可以接受所有、部分或不接受任何建议的映射。
按此格式展示匹配项:
以下组件与设计匹配:
- [ComponentName](path/to/component): DesignComponentName 位于节点 ID [nodeId](figmaUrl?node-id=X-Y)
- [AnotherComponent](path/to/another): AnotherDesign 位于节点 ID [nodeId2](figmaUrl?node-id=X-Y)
您想连接这些组件吗?您可以全部接受、选择特定组件或跳过。
如果未找到组件的精确匹配:
如果用户拒绝所有映射,请通知他们并停止。无需进行进一步的工具调用。
一旦用户确认了他们的选择,就调用 send_code_connect_mappings,仅包含已接受的映射。此工具处理单次调用中所有映射的批量创建。
示例:
send_code_connect_mappings(
fileKey=":fileKey",
nodeId="1:2",
mappings=[
{ nodeId: "1:2", componentName: "Button", source: "src/components/Button.tsx", label: "React" },
{ nodeId: "1:5", componentName: "Card", source: "src/components/Card.tsx", label: "React" }
]
)
每个映射的关键参数:
nodeId: Figma 节点 ID(使用冒号格式:1:2)componentName: 要连接的组件名称(例如 "Button"、"Card")source: 代码组件文件的路径(相对于项目根目录)label: 此 Code Connect 映射的框架或语言标签。有效值包括:
调用后:
处理后提供摘要:
Code Connect 摘要:
- 成功连接:3
- Button (1:2) → src/components/Button.tsx
- Card (1:5) → src/components/Card.tsx
- Input (1:8) → src/components/Input.tsx
- 无法连接:1
- CustomWidget (1:10) - 在代码库中未找到匹配的组件
用户说:"将此 Figma 按钮连接到我的代码:https://figma.com/design/kL9xQn2VwM8pYrTb4ZcHjF/DesignSystem?node-id=42-15"
操作:
kL9xQn2VwM8pYrTb4ZcHjF,nodeId=42-15 → 转换为 42:15get_code_connect_suggestions(fileKey="kL9xQn2VwM8pYrTb4ZcHjF", nodeId="42:15")variant(primary/secondary)和 size(sm/md/lg)属性,以及缩略图图像src/components/Button.tsxButton.tsx 并确认其具有 variant 和 size 属性send_code_connect_mappings(fileKey="kL9xQn2VwM8pYrTb4ZcHjF", nodeId="42:15", mappings=[{ nodeId: "42:15", componentName: "Button", source: "src/components/Button.tsx", label: "React" }])结果: Figma 按钮组件现已连接到代码中的 Button 组件。
操作:
pR8mNv5KqXzGwY2JtCfL4D,nodeId=10-50 → 转换为 10:50get_code_connect_suggestions(fileKey="pR8mNv5KqXzGwY2JtCfL4D", nodeId="10:50")src/components/ProductCard.tsx(属性匹配)src/components/Badge.tsx(属性匹配)send_code_connect_mappings(fileKey="pR8mNv5KqXzGwY2JtCfL4D", nodeId="10:50", mappings=[{ nodeId: "10:51", componentName: "ProductCard", source: "src/components/ProductCard.tsx", label: "React" }])结果: 仅 ProductCard 根据用户的选择被连接。
操作:
8yJDMeWDyBz71EnMOSuUiw,nodeId=5-20 → 转换为 5:20get_code_connect_suggestions(fileKey="8yJDMeWDyBz71EnMOSuUiw", nodeId="5:20")src/icons/ 目录send_code_connect_mappings(fileKey="8yJDMeWDyBz71EnMOSuUiw", nodeId="5:20", mappings=[{ nodeId: "5:20", componentName: "CheckIcon", source: "src/icons/CheckIcon.tsx", label: "React" }])结果: CheckIcon 组件成功连接到 Figma 设计。
不要只是向用户询问文件路径——主动搜索他们的代码库以找到匹配的组件。这提供了更好的体验,并抓住了潜在的映射机会。
在比较 Figma 组件和代码组件时,不要只看名称。检查:
在提议创建映射时,请清楚地解释:
如果多个组件可能匹配,请提供选项而不是猜测。让用户最终决定连接哪个组件。
如果找不到精确匹配,请提供有用的后续步骤:
原因: Figma 组件未发布到团队库。Code Connect 仅适用于已发布的组件。解决方案: 用户需要将组件发布到 Figma 中的团队库:
原因: 用户的 Figma 计划不包含 Code Connect 访问权限。解决方案: 用户需要升级到组织或企业计划,或联系其管理员。
原因: 代码库搜索未找到具有匹配名称或结构的组件。解决方案: 询问用户组件是否以不同的名称存在或在不同的位置。他们可能需要先创建组件,或者它可能位于意外的目录中。
原因: 源文件路径不正确,组件在该位置不存在,或者 componentName 与实际导出不匹配。解决方案: 验证源路径是否正确且相对于项目根目录。检查组件是否以指定的确切 componentName 从文件中正确导出。
原因: 此组件已存在 Code Connect 映射。解决方案: 组件已连接。如果用户想要更新映射,他们可能需要先在 Figma 中移除现有的映射。
原因: 用户对 Figma 文件或库没有编辑权限。解决方案: 用户需要对包含组件的文件具有编辑访问权限。联系文件所有者或团队管理员。
原因: Figma URL 格式不正确或缺少 node-id 参数。解决方案: 验证 URL 是否符合所需格式:https://figma.com/design/:fileKey/:fileName?node-id=1-2。node-id 参数是必需的。同时确保在调用工具时将 1-2 转换为 1:2。
原因: 代码库包含多个可能匹配 Figma 组件的组件。解决方案: 向用户展示所有候选组件及其文件路径,并让他们选择连接哪一个。不同的组件可能用于不同的上下文(例如,Button.tsx 与 LinkButton.tsx)。
Code Connect 在设计与代码之间建立双向链接:
对于设计师: 查看哪个代码组件实现了 Figma 组件 对于开发者: 直接从 Figma 设计导航到实现它们的代码 对于团队: 维护组件映射的单一事实来源
您创建的映射通过使这些连接明确且可发现,有助于保持设计与代码同步。
有关 Code Connect 的更多信息:
每周安装量
859
仓库
GitHub 星标数
457
首次出现
2026年1月20日
安全审计
安装于
opencode768
codex753
gemini-cli747
github-copilot722
cursor712
kimi-cli648
This skill helps you connect Figma design components to their corresponding code implementations using Figma's Code Connect feature. It analyzes the Figma design structure, searches your codebase for matching components, and establishes mappings that maintain design-code consistency.
get_code_connect_suggestions) are available.https://figma.com/design/:fileKey/:fileName?node-id=1-2
node-id parameter. Code Connect mapping will fail without it.Follow these steps in order. Do not skip steps.
Call get_code_connect_suggestions to identify all unmapped components in a single operation. This tool automatically:
Parse the URL to extract fileKey and nodeId, then call get_code_connect_suggestions.
IMPORTANT: When extracting the node ID from a Figma URL, convert the format:
node-id=1-2nodeId=1:2Parse the Figma URL:
URL format: https://figma.com/design/:fileKey/:fileName?node-id=1-2
Extract file key: :fileKey (segment after /design/)
Extract node ID: 1-2 from URL, then convert to 1:2 for the tool
get_code_connect_suggestions(fileKey=":fileKey", nodeId="1:2")
Handle the response:
For each unmapped component returned by get_code_connect_suggestions, search the codebase for a matching code component.
What to look for:
src/components/, components/, ui/, etc.)Search strategy:
Example search patterns:
Button.tsx, PrimaryButton.tsx, Button.jsxsrc/components/, app/components/, lib/ui/variant, size, color that match Figma variantsPresent your findings and let the user choose which mappings to create. The user can accept all, some, or none of the suggested mappings.
Present matches in this format:
The following components match the design:
- [ComponentName](path/to/component): DesignComponentName at nodeId [nodeId](figmaUrl?node-id=X-Y)
- [AnotherComponent](path/to/another): AnotherDesign at nodeId [nodeId2](figmaUrl?node-id=X-Y)
Would you like to connect these components? You can accept all, select specific ones, or skip.
If no exact match is found for a component:
If the user declines all mappings , inform them and stop. No further tool calls are needed.
Once the user confirms their selections, call send_code_connect_mappings with only the accepted mappings. This tool handles batch creation of all mappings in a single call.
Example:
send_code_connect_mappings(
fileKey=":fileKey",
nodeId="1:2",
mappings=[
{ nodeId: "1:2", componentName: "Button", source: "src/components/Button.tsx", label: "React" },
{ nodeId: "1:5", componentName: "Card", source: "src/components/Card.tsx", label: "React" }
]
)
Key parameters for each mapping:
nodeId: The Figma node ID (with colon format: 1:2)componentName: Name of the component to connect (e.g., "Button", "Card")source: Path to the code component file (relative to project root)label: The framework or language label for this Code Connect mapping. Valid values include:
After the call:
Provide a summary after processing:
Code Connect Summary:
- Successfully connected: 3
- Button (1:2) → src/components/Button.tsx
- Card (1:5) → src/components/Card.tsx
- Input (1:8) → src/components/Input.tsx
- Could not connect: 1
- CustomWidget (1:10) - No matching component found in codebase
User says: "Connect this Figma button to my code: https://figma.com/design/kL9xQn2VwM8pYrTb4ZcHjF/DesignSystem?node-id=42-15"
Actions:
Parse URL: fileKey=kL9xQn2VwM8pYrTb4ZcHjF, nodeId=42-15 → convert to 42:15
Run get_code_connect_suggestions(fileKey="kL9xQn2VwM8pYrTb4ZcHjF", nodeId="42:15")
Response shows: Button component (unmapped) with variant (primary/secondary) and size (sm/md/lg) properties, plus a thumbnail image
Search codebase for Button components: Find src/components/Button.tsx
Read Button.tsx and confirm it has variant and props
Would you like to connect this component?"
User confirms: "Yes"
Detect that it's a TypeScript React component
Run send_code_connect_mappings(fileKey="kL9xQn2VwM8pYrTb4ZcHjF", nodeId="42:15", mappings=[{ nodeId: "42:15", componentName: "Button", source: "src/components/Button.tsx", label: "React" }])
Result: Figma button component is now connected to the code Button component.
User says: "Connect components in this frame: https://figma.com/design/pR8mNv5KqXzGwY2JtCfL4D/Components?node-id=10-50"
Actions:
Parse URL: fileKey=pR8mNv5KqXzGwY2JtCfL4D, nodeId=10-50 → convert to 10:50
Run get_code_connect_suggestions(fileKey="pR8mNv5KqXzGwY2JtCfL4D", nodeId="10:50")
Response shows 3 unmapped components: ProductCard, Badge, and CustomWidget
Search codebase:
src/components/ProductCard.tsx (props match)src/components/Badge.tsx (props match)Present to user: "The following components match the design:
I couldn't find a match for CustomWidget (10:53).
Would you like to connect these components? You can accept all, select specific ones, or skip."
User: "Just connect ProductCard, skip Badge for now"
Run send_code_connect_mappings(fileKey="pR8mNv5KqXzGwY2JtCfL4D", nodeId="10:50", mappings=[{ nodeId: "10:51", componentName: "ProductCard", source: "src/components/ProductCard.tsx", label: "React" }])
Result: Only ProductCard is connected, per the user's selection.
User says: "Connect this icon: https://figma.com/design/8yJDMeWDyBz71EnMOSuUiw/Icons?node-id=5-20"
Actions:
8yJDMeWDyBz71EnMOSuUiw, nodeId=5-20 → convert to 5:20get_code_connect_suggestions(fileKey="8yJDMeWDyBz71EnMOSuUiw", nodeId="5:20")src/icons/ directory with other iconssend_code_connect_mappings(fileKey="8yJDMeWDyBz71EnMOSuUiw", nodeId="5:20", mappings=[{ nodeId: "5:20", componentName: "CheckIcon", source: "src/icons/CheckIcon.tsx", label: "React" }])Result: CheckIcon component is successfully connected to the Figma design.
Don't just ask the user for the file path — actively search their codebase to find matching components. This provides a better experience and catches potential mapping opportunities.
When comparing Figma components to code components, look beyond just names. Check that:
When offering to create a mapping, clearly explain:
If multiple components could match, present options rather than guessing. Let the user make the final decision about which component to connect.
If you can't find an exact match, provide helpful next steps:
Cause: The Figma component is not published to a team library. Code Connect only works with published components. Solution: The user needs to publish the component to a team library in Figma:
Cause: The user's Figma plan does not include Code Connect access. Solution: The user needs to upgrade to an Organization or Enterprise plan, or contact their administrator.
Cause: The codebase search did not find a component with a matching name or structure. Solution: Ask the user if the component exists under a different name or in a different location. They may need to create the component first, or it might be located in an unexpected directory.
Cause: The source file path is incorrect, the component doesn't exist at that location, or the componentName doesn't match the actual export. Solution: Verify the source path is correct and relative to the project root. Check that the component is properly exported from the file with the exact componentName specified.
Cause: A Code Connect mapping already exists for this component. Solution: The component is already connected. If the user wants to update the mapping, they may need to remove the existing one first in Figma.
Cause: The user does not have edit permissions on the Figma file or library. Solution: The user needs edit access to the file containing the component. Contact the file owner or team admin.
Cause: The Figma URL format is incorrect or missing the node-id parameter. Solution: Verify the URL follows the required format: https://figma.com/design/:fileKey/:fileName?node-id=1-2. The node-id parameter is required. Also ensure you convert 1-2 to 1:2 when calling tools.
Cause: The codebase contains multiple components that could match the Figma component. Solution: Present all candidates to the user with their file paths and let them choose which one to connect. Different components might be used in different contexts (e.g., Button.tsx vs LinkButton.tsx).
Code Connect establishes a bidirectional link between design and code:
For designers: See which code component implements a Figma component For developers: Navigate from Figma designs directly to the code that implements them For teams: Maintain a single source of truth for component mappings
The mapping you create helps keep design and code in sync by making these connections explicit and discoverable.
For more information about Code Connect:
Weekly Installs
859
Repository
GitHub Stars
457
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode768
codex753
gemini-cli747
github-copilot722
cursor712
kimi-cli648
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
136,300 周安装
YouTube视频分析师 - 逆向分析病毒内容公式,提取钩子、留存机制与情感触发点
647 周安装
SQLiteData 使用指南:SwiftData 轻量级替代方案,支持 CloudKit 同步
CTF密码学挑战速查指南 | 经典/现代密码攻击、RSA/ECC/流密码实战技巧
648 周安装
Bitrefill CLI:让AI智能体自主购买数字商品,支持加密货币支付
Bilibili 字幕提取工具 - 支持 AI 字幕检测与 ASR 转录,一键下载视频字幕
648 周安装
assistant-ui thread-list 线程列表:管理多聊天线程的 React AI SDK 组件
649 周安装
size