通过 OAuth 认证网关管理 Stripe 客户、订阅、发票、产品、价格和支付。
设计与多媒体
figma-code-connect-components
通过 Figma Code Connect 把已发布的组件关联到代码实现。
它能做什么
读取 Figma 选区中已发布但尚未映射的组件,再按名称、props 和结构在本地代码库中搜索匹配项。匹配结果需用户确认后,一次性批量创建映射。支持 React、Vue、Svelte、Storybook、SwiftUI、Compose、Flutter 等多种框架。仅用于建立映射,不会改动 Figma 画布,也不会生成或修改代码文件。
什么时候用它
- 把 Button 设计组件关联到 src/components/Button.tsx
- 一次性批量映射一个画框里的多个组件
- 关联 src/icons/ 下的图标组件
- 复查某个画框里还剩哪些组件没接上
技能文档
Code Connect Components
Overview
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.
Skill Boundaries
- Use this skill for
get_code_connect_suggestions+send_code_connect_mappingsworkflows. - If the task requires writing to the Figma canvas with Plugin API scripts, switch to figma-use.
- If the task is building or updating a full-page screen in Figma from code or a description, switch to figma-generate-design.
- If the task is implementing product code from Figma, switch to figma-implement-design.
Prerequisites
- Figma MCP server must be connected and accessible
- User must provide a Figma URL with node ID:
https://figma.com/design/:fileKey/:fileName?node-id=1-2- IMPORTANT: The Figma URL must include the
node-idparameter. Code Connect mapping will fail without it.
- IMPORTANT: The Figma URL must include the
- OR when using
figma-desktopMCP: User can select a node directly in the Figma desktop app (no URL required) - IMPORTANT: The Figma component must be published to a team library. Code Connect only works with published components or component sets.
- IMPORTANT: Code Connect is only available on Organization and Enterprise plans.
- Access to the project codebase for component scanning
Required Workflow
Follow these steps in order. Do not skip steps.
Step 1: Get Code Connect Suggestions
Call get_code_connect_suggestions to identify all unmapped components in a single operation. This tool automatically:
- Fetches component info from the Figma scenegraph
- Identifies published components in the selection
- Checks existing Code Connect mappings and filters out already-connected components
- Returns component names, properties, and thumbnail images for each unmapped component
Option A: Using figma-desktop MCP (no URL provided)
If the figma-desktop MCP server is connected and the user has NOT provided a Figma URL, immediately call get_code_connect_suggestions. No URL parsing is needed — the desktop MCP server automatically uses the currently selected node from the open Figma file.
Note: The user must have the Figma desktop app open with a node selected. fileKey is not passed as a parameter — the server uses the currently open file.
Option B: When a Figma URL is provided
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:
- URL format uses hyphens:
node-id=1-2 - Tool expects colons:
nodeId=1:2
Parse 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-2from URL, then convert to1:2for the tool
get_code_connect_suggestions(fileKey=":fileKey", nodeId="1:2")
Handle the response:
- If the tool returns "No published components found in this selection" → inform the user and stop. The components may need to be published to a team library first.
- If the tool returns "All component instances in this selection are already connected to code via Code Connect" → inform the user that everything is already mapped.
- Otherwise, the response contains a list of unmapped components, each with:
- Component name
- Node ID
- Component properties (JSON with prop names and values)
- A thumbnail image of the component (for visual inspection)
Step 2: Scan Codebase for Matching Components
For each unmapped component returned by get_code_connect_suggestions, search the codebase for a matching code component.
What to look for:
- Component names that match or are similar to the Figma component name
- Component structure that aligns with the Figma hierarchy
- Props that correspond to Figma properties (variants, text, styles)
- Files in typical component directories (
src/components/,components/,ui/, etc.)
Search strategy:
- Search for component files with matching names
- Read candidate files to check structure and props
- Compare the code component's props with the Figma component properties returned in Step 1
- Detect the programming language (TypeScript, JavaScript) and framework (React, Vue, etc.)
- Identify the best match based on structural similarity, weighing:
- Prop names and their correspondence to Figma properties
- Default values that match Figma defaults
- CSS classes or style objects
- Descriptive comments that clarify intent
- If multiple candidates are equally good, pick the one with the closest prop-interface match and document your reasoning in a 1-2 sentence comment before your tool call
Example search patterns:
- If Figma component is "PrimaryButton", search for
Button.tsx,PrimaryButton.tsx,Button.jsx - Check common component paths:
src/components/,app/components/,lib/ui/ - Look for variant props like
variant,size,colorthat match Figma variants
Step 3: Present Matches to User
Present 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:
- Show the 2 closest candidates
- Explain the differences
- Ask the user to confirm which component to use or provide the correct path
If the user declines all mappings, inform them and stop. No further tool calls are needed.
Step 4: Create Code Connect Mappings
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:- Web: 'React', 'Web Components', 'Vue', 'Svelte', 'Storybook', 'Javascript'
- iOS: 'Swift UIKit', 'Objective-C UIKit', 'SwiftUI'
- Android: 'Compose', 'Java', 'Kotlin', 'Android XML Layout'
- Cross-platform: 'Flutter'
- Docs: 'Markdown'
After the call:
- On success: the tool confirms the mappings were created
- On error: the tool reports which specific mappings failed and why (e.g., "Component is already mapped to code", "Published component not found", "Insufficient permissions")
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
Examples
Example 1: Connecting a Button Component
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 to42:15 -
Run
get_code_connect_suggestions(fileKey="kL9xQn2VwM8pYrTb4ZcHjF", nodeId="42:15") -
Response shows: Button component (unmapped) with
variant(primary/secondary) andsize(sm/md/lg) properties, plus a thumbnail image -
Search codebase for Button components: Find
src/components/Button.tsx -
Read
Button.tsxand confirm it hasvariantandsizeprops -
Present to user:
I found a match: - [Button](src/components/Button.tsx): Button at nodeId [42:15](https://figma.com/design/kL9xQn2VwM8pYrTb4ZcHjF/DesignSystem?node-id=42-15) 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.
Example 2: Multiple Components with Partial Selection
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 to10:50 -
Run
get_code_connect_suggestions(fileKey="pR8mNv5KqXzGwY2JtCfL4D", nodeId="10:50") -
Response shows 3 unmapped components: ProductCard, Badge, and CustomWidget
-
Search codebase:
- ProductCard: Found
src/components/ProductCard.tsx(props match) - Badge: Found
src/components/Badge.tsx(props match) - CustomWidget: No matching component found
- ProductCard: Found
-
Present to user:
The following components match the design: - [ProductCard](src/components/ProductCard.tsx): ProductCard at nodeId [10:51](https://figma.com/design/pR8mNv5KqXzGwY2JtCfL4D/Components?node-id=10-51) - [Badge](src/components/Badge.tsx): Badge at nodeId [10:52](https://figma.com/design/pR8mNv5KqXzGwY2JtCfL4D/Components?node-id=10-52) 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.
Example 3: Component Needs Creation
User says: "Connect this icon: https://figma.com/design/8yJDMeWDyBz71EnMOSuUiw/Icons?node-id=5-20"
Actions:
- Parse URL: fileKey=
8yJDMeWDyBz71EnMOSuUiw, nodeId=5-20→ convert to5:20 - Run
get_code_connect_suggestions(fileKey="8yJDMeWDyBz71EnMOSuUiw", nodeId="5:20") - Response shows: CheckIcon component (unmapped) with color and size properties
- Search codebase for CheckIcon: No matches found
- Search for generic Icon components: Find
src/icons/directory with other icons - Report to user: "I couldn't find a CheckIcon component, but I found an icons directory at src/icons/. Would you like to:
- Create a new CheckIcon.tsx component first, then connect it
- Connect to a different existing icon
- Provide the path to the CheckIcon if it exists elsewhere"
- User provides path: "src/icons/CheckIcon.tsx"
- Detect language and framework from the file
- Run
send_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.
Best Practices
Proactive Component Discovery
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.
Accurate Structure Matching
When comparing Figma components to code components, look beyond just names. Check that:
- Props align (variant types, size options, etc.)
- Component hierarchy matches (nested elements)
- The component serves the same purpose
Clear Communication
When offering to create a mapping, clearly explain:
- What you found
- Why it's a good match
- What the mapping will do
- How props will be connected
Handle Ambiguity
If multiple components could match, present options rather than guessing. Let the user make the final decision about which component to connect.
Graceful Degradation
If you can't find an exact match, provide helpful next steps:
- Show close candidates
- Suggest component creation
- Ask for user guidance
Common Issues and Solutions
Issue: "No published components found in this selection"
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:
- In Figma, select the component or component set
- Right-click and choose "Publish to library" or use the Team Library publish modal
- Publish the component
- Once published, retry the Code Connect mapping with the same node ID
Issue: "Code Connect is only available on Organization and Enterprise plans"
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.
Issue: No matching component found in codebase
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.
Issue: "Published component not found" (CODE_CONNECT_ASSET_NOT_FOUND)
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.
Issue: "Component is already mapped to code" (CODE_CONNECT_MAPPING_ALREADY_EXISTS)
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.
Issue: "Insufficient permissions to create mapping" (CODE_CONNECT_INSUFFICIENT_PERMISSIONS)
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.
Issue: Code Connect mapping fails with URL errors
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.
Issue: Multiple similar components found
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).
Understanding Code Connect
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.
Additional Resources
For more information about Code Connect:
常见问题
- 没有 Figma 链接也能用吗?
- 可以。如果接了 figma-desktop MCP,会直接使用桌面端当前选中的节点;否则必须提供带 node-id 的链接(例如 ?node-id=1-2)。
- 找不到匹配组件时会自动新建吗?
- 不会。本技能只负责建立映射;代码库里没有匹配项时,会让用户提供正确路径,或先去创建该组件再回来映射。
- 为什么有些组件映射不上?
- Code Connect 仅对已发布到团队库的组件生效,且功能只向 Figma Organization 和 Enterprise 套餐开放。
相关技能
为自然搜索排名提供站点审计、内容撰写与竞品分析。
用可量化的层级、间距、字号、配色与版式规则,绘制并诊断视觉作品。
通过托管 OAuth 代理访问 YouTube Data API v3,搜索与管理视频、播放列表、频道、订阅和评论。
通过 API 生成 AI 人像肖像,支持 140+ 国籍、8 种风格与 24 种情绪。
一条提示词生成最长 4 分钟的视频 —— 自动完成脚本、配音、配乐与剪辑。
OpenAI 的更多技能
浏览全部技能用文档优先的工作流为 ChatGPT Apps SDK 项目搭建 MCP 服务与 widget UI。
通过 Plugin API 在 Figma 文件里执行 JavaScript,以编程方式增删改查设计节点。
从品牌名、角色立绘或文字描述生成 Codex 兼容的动画宠物,含图谱组装、校验与 QA。
imagegen
官方通过内置图像工具生成或编辑项目所需的位图素材,仅在用户明确要求时切换到 CLI 回退路径。
从 OpenAI 开发者文档获取权威且最新的答案并附引用,覆盖模型选型与升级建议。
从 git 历史构建代码归属与 bus factor 图,定位敏感代码风险。