Token导航 LogoToken导航

Agent Skill · 研究检索

figma-code-connect(Figma 代码 connect)

用于辅助界面设计、视觉规范、排版、配色、布局和交互体验优化。它适合让 Agent 根据产品场景整理页面结构、生成 UI 方案、检查视觉一致性或改进组件层级。使用时需要结合现有品牌、设计系统和用户任务,不应只堆装饰元素;涉及真实页面改动时,应通过截图或浏览器预览检查文本溢出、对齐和响应式表现。

figma-code-connect 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为调用外部服务;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 7,673。

总安装 18,350周安装 757GitHub Stars 1,328下载 5,995核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:figma-code-connect(Figma 代码 connect)
来源仓库:https://github.com/figma/mcp-server-guide
仓库路径:skills/figma-code-connect
安装命令:
npx skills add https://github.com/figma/mcp-server-guide --skill figma-code-connect
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/figma/mcp-server-guide --skill figma-code-connect

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于辅助界面设计、视觉规范、排版、配色和布局优化。适合整理页面结构、生成 UI 方案或检查视觉一致性。使用时需结合现有品牌、设计系统和用户任务。涉及真实页面改动时应通过截图或浏览器预览检查表现。figma-code-connect 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/figma-code-connect

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/figma/mcp-server-guide --skill figma-code-conn…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要调用外部服务,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

figma-code-connect 怎么安装?

在终端执行 npx skills add https://github.com/figma/mcp-server-guide --skill figma-code-connect。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

figma-code-connect 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

figma-code-connect 需要什么权限?

权限级别是调用外部服务。该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

figma-code-connect 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

figma-code-connect 用的人多吗?

公开数据是累计安装 18,350 次,近一周安装 757 次,下载 5,995 次,GitHub 1,328 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

figma-code-connect 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 来源仓库有 1,328 星,维护活跃度相对可查。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
figma-code-connect

Figma 代码 connect · 本页

18,3501,328调用外部服务未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Code Connect

Overview

Create Code Connect template files (.figma.ts) that map Figma components to code snippets. Given a Figma URL, follow the steps below to create a template.

Note: This project may also contain parser-based .figma.tsx files (using figma.connect(), published via CLI). This skill covers templates files only — .figma.ts files that use the MCP tools to fetch component context from Figma.

Prerequisites

  • Figma MCP server must be connected — verify that Figma MCP tools (e.g., get_code_connect_suggestions) are available before proceeding. If not, guide the user to enable the Figma MCP server and restart their MCP client.
  • Components must be published — Code Connect only works with components published to a Figma team library. If a component is not published, inform the user and stop.
  • Organization or Enterprise plan required — Code Connect is not available on Free or Professional plans.
  • URL must include node-id — the Figma URL must contain the node-id query parameter.
  • TypeScript types — for editor autocomplete and type checking in .figma.ts files @figma/code-connect/figma-types must be added to types in tsconfig.json: {"compilerOptions": {"types": ["@figma/code-connect/figma-types"]}}

Step 1: Parse the Figma URL

Extract fileKey and nodeId from the URL:

URL FormatfileKeynodeId
figma.com/design/:fileKey/:name?node-id=X-Y:fileKeyX-Y → X:Y
figma.com/file/:fileKey/:name?node-id=X-Y:fileKeyX-Y → X:Y
figma.com/design/:fileKey/branch/:branchKey/:nameuse :branchKeyfrom node-id param

Always convert nodeId hyphens to colons: 1234-5678 → 1234:5678.

Worked example:

Given: https://www.figma.com/design/QiEF6w564ggoW8ftcLvdcu/MyDesignSystem?node-id=4185-3778

  • fileKey = QiEF6w564ggoW8ftcLvdcu
  • nodeId = 4185-3778 → 4185:3778

Step 2: Discover Unmapped Components

The user may provide a URL pointing to a frame, instance, or variant — not necessarily a component set or standalone component. Call the MCP tool get_code_connect_suggestions with:

  • fileKey — from Step 1
  • nodeId — from Step 1 (colons format)
  • excludeMappingPrompt — true (returns a lightweight list of unmapped components)

This tool identifies published components in the selection that don't yet have Code Connect mappings.

Handle the response:

  • "No published components found in this selection" — the node contains no published components. Inform the user they need to publish the component to a team library in Figma first, then stop.
  • "All component instances in this selection are already connected to code via Code Connect" — everything is already mapped. Inform the user and stop.
  • Normal response with component list — extract the mainComponentNodeId for each returned component. Use these resolved node IDs (not the original from the URL) for all subsequent steps. If multiple components are returned (e.g. the user selected a frame containing several different component instances), repeat Steps 3–6 for each one.

Step 3: Fetch Component Properties

Call the MCP tool get_context_for_code_connect with:

  • fileKey — from Step 1
  • nodeId — the resolved mainComponentNodeId from Step 2
  • clientFrameworks — determine from figma.config.json parser field (e.g. "react" → ["react"])
  • clientLanguages — infer from project file extensions (e.g. TypeScript project → ["typescript"], JavaScript → ["javascript"])

For multiple components, call the tool once per node ID.

The response contains the Figma component's property definitions — note each property's name and type:

  • TEXT — text content (labels, titles, placeholders)
  • BOOLEAN — toggles (show/hide icon, disabled state)
  • VARIANT — enum options (size, variant, state)
  • INSTANCE_SWAP — swappable nested instances tied to a specific component (icon, avatar)
  • SLOT — flexible content regions (freeform layout, mixed children); use getSlot() in templates (not the same as INSTANCE_SWAP)

Save this property list — you will use it in Step 5 to write the template.

Step 4: Identify the Code Component

If the user did not specify which code component to connect:

  1. Check figma.config.json for paths and importPaths to find where components live
  2. Search the codebase for a component matching the Figma component name. Check common directories (src/components/, components/, lib/ui/, app/components/) if figma.config.json doesn't specify paths
  3. Read candidate files and compare their props interface against the Figma properties from Step 3 — look for matching variant types, size options, boolean flags, and slot props
  4. If multiple candidates match, pick the one with the closest prop-interface match and explain your reasoning to the user
  5. If no match is found, show the 2 closest candidates and ask the user to confirm or provide the correct path

Confirm with the user before proceeding to Step 5. Present the match: which code component you found, where it lives, and why it matches (prop correspondence, naming, purpose).

Read figma.config.json for import path aliases — the importPaths section maps glob patterns to import specifiers, and the paths section maps those specifiers to directories.

Read the code component's source to understand its props interface — this informs how to map Figma properties to code props in Step 5.

Step 5: Create the Template File (.figma.ts)

File location

Place the file alongside existing Code Connect templates (.figma.tsx or .figma.ts files). Check figma.config.json include patterns for the correct directory. Name it ComponentName.figma.ts.

Template structure

Every template file follows this structure:

// url=https://www.figma.com/file/{fileKey}/{fileName}?node-id={nodeId}
// source={path to code component from Step 4}
// component={code component name from Step 4}
import figma from 'figma'
const instance = figma.selectedInstance

// Extract properties from the Figma component (see property mapping below)
// ...

export default {
  example: figma.code`<Component ... />`,       // Required: code snippet
  imports: ['import { Component } from "..."'], // Optional: import statements
  id: 'component-name',                         // Required: unique identifier
  metadata: {                                    // Optional
    nestable: true,                              // true = inline in parent, false = show as pill
    props: {}                                    // data accessible to parent templates
  }
}

Property mapping

Use the property list from Step 3 to extract values. For each Figma property type, use the corresponding method:

Figma Property TypeTemplate MethodWhen to Use
TEXTinstance.getString('Name')Labels, titles, placeholder text
BOOLEANinstance.getBoolean('Name', {true:..., false:...})Toggle visibility, conditional props
VARIANTinstance.getEnum('Name', {'FigmaVal': 'codeVal'})Size, variant, state enums
INSTANCE_SWAPinstance.getInstanceSwap('Name')Swapped instance for a fixed component slot (then hasCodeConnect() / executeTemplate()) - do not confuse with the SLOT property below
SLOTinstance.getSlot('Name')Freeform slot content only when the Figma property type is SLOT
(child layer)instance.findInstance('LayerName')Named child instances without a property
(text layer)instance.findText('LayerName') → .textContentText content from named layers

TEXT — get the string value directly:

const label = instance.getString('Label')

VARIANT — map Figma enum values to code values:

const variant = instance.getEnum('Variant', {
  'Primary': 'primary',
  'Secondary': 'secondary',
})

const size = instance.getEnum('Size', {
  'Small': 'sm',
  'Medium': 'md',
  'Large': 'lg',
})

BOOLEAN — simple boolean or mapped to values:

// Simple boolean
const disabled = instance.getBoolean('Disabled')

// Mapped to code values (e.g. when the code prop is an enum, not a boolean)
const size = instance.getBoolean('Show Label', { true: 'large', false: 'small' })

Map Figma properties to code props where there's a valid correspondence. Figma properties and code props don't always line up 1:1 — some Figma properties map directly (by name, or via the API methods above), others have no code equivalent. Where a mapping exists, use it; where none fits, omit the Figma property rather than invent a code prop. Never emit an attribute whose name doesn't appear in the code component's Props interface.

Exhaustive variant handling

When a VARIANT property has multiple possible values, the getEnum mapping must list every value returned by get_context_for_code_connect. Don't omit values — an unmapped value silently returns undefined, producing broken output.

// WRONG — omits 'Warning', which will render as undefined
const status = instance.getEnum('Status', {
  'Success': 'success',
  'Error': 'error',
})

// CORRECT — every value is mapped
const status = instance.getEnum('Status', {
  'Success': 'success',
  'Error': 'error',
  'Warning': 'warning',
  'Info': 'info',
})

When two or more VARIANT properties combine to produce different code output, generate exhaustive conditional branches. For example, 2 variants × 2 values = 4 branches:

const type = instance.getEnum('Type', { 'Filled': 'filled', 'Outlined': 'outlined' })
const status = instance.getEnum('Status', { 'Success': 'success', 'Error': 'error' })

let colorClass
if (type === 'filled' && status === 'success') {
  colorClass = 'bg-green-500 text-white'
} else if (type === 'filled' && status === 'error') {
  colorClass = 'bg-red-500 text-white'
} else if (type === 'outlined' && status === 'success') {
  colorClass = 'bg-transparent border-green-500'
} else if (type === 'outlined' && status === 'error') {
  colorClass = 'bg-transparent border-red-500'
}

If the combinations produce repetitive output (e.g., Size doesn't change the snippet structure — it's just passed through as a prop), a single getEnum mapping per variant is sufficient — no need for cross-product branches.

INSTANCE_SWAP — access swappable component instances:

const icon = instance.getInstanceSwap('Icon')
let iconCode
if (icon && icon.type === 'INSTANCE') {
  iconCode = icon.executeTemplate().example
}

SLOT — getSlot(propName) is only valid when the Figma component property reported in Step 3 has type SLOT. Do not use getSlot() for INSTANCE_SWAP properties (those use getInstanceSwap()). Slots are explicit “content regions” in the component definition, not generic nested instances.

  • Signature: getSlot(propName: string): ResultSection[] | undefined
// Figma property "Content" must be type SLOT in component properties
const content = instance.getSlot('Content')

export default {
  example: figma.code`<Card>${content}</Card>`,
  // ...
}

Interpolation in tagged templates

When interpolating values in tagged templates, use the correct wrapping:

  • String values (getString, getEnum, textContent): wrap in quotes → variant="${variant}"
  • Instance/section values (executeTemplate().example): wrap in braces → icon={${iconCode}}
  • Slot sections (getSlot() result — ResultSection[] | undefined): interpolate directly inside ` figma.code... (same shape as nested snippet sections), e.g. figma.code<Select>${content}</Select> ` — do not treat as a plain string
  • Boolean bare props: use conditional → ${disabled? 'disabled': ''}

Finding descendant layers

When you need to access children that aren't exposed as component properties:

MethodUse when
instance.getInstanceSwap('PropName')Figma property type is INSTANCE_SWAP (fixed swapped instance)
instance.getSlot('PropName')Figma property type is SLOT (freeform content region)
instance.findInstance('LayerName')You know the child layer name (no component property)
instance.findText('LayerName') → .textContentYou need text content from a named text layer
instance.findConnectedInstance('id')You know the child's Code Connect id
instance.findConnectedInstances(fn)You need multiple connected children matching a filter
instance.findLayers(fn)You need any layers (text + instances) matching a filter

Nested configurable instances

A component may contain child instances that are not exposed as component properties (no INSTANCE_SWAP) but are still independently configurable — they have their own variants, properties, or swap slots. These must be resolved dynamically, not hardcoded.

  1. Check whether the child already has a Code Connect template — use get_code_connect_suggestions or check existing .figma.ts files in the project.
  2. If no template exists, create one for the child so it renders correctly both standalone and when nested.
  3. Reference the child from the parent using findInstance() or findConnectedInstance(), then call executeTemplate().
// Parent template — the Badge child isn't a prop, but it's configurable
const badge = instance.findInstance('Status Badge')
let badgeCode
if (badge && badge.type === 'INSTANCE') {
  badgeCode = badge.executeTemplate().example
}

export default {
  example: figma.code`<Card>${badgeCode}</Card>`,
  // ...
}

This applies to icons, badges, labels, and any other nested instance that is configurable by itself — always connect them and render dynamically, never hardcode their content.

Nested component example

For multi-level nested components or metadata prop passing between templates, see advanced-patterns.md.

const icon = instance.getInstanceSwap('Icon')
let iconSnippet
if (icon && icon.type === 'INSTANCE') {
  iconSnippet = icon.executeTemplate().example
}

export default {
  example: figma.code`<Button ${iconSnippet ? figma.code`icon={${iconSnippet}}` : ''}>${label}</Button>`,
  // ...
}

Conditional props

const variant = instance.getEnum('Variant', { 'Primary': 'primary', 'Secondary': 'secondary' })
const disabled = instance.getBoolean('Disabled')

export default {
  example: figma.code`
    <Button
      variant="${variant}"
      ${disabled ? 'disabled' : ''}
    >
      ${label}
    </Button>
  `,
  // ...
}

Step 6: Validate

Read back the .figma.ts file and review it against the following:

  • Property coverage — every Figma property from Step 3 should be accounted for in the template. Flag any that are missing and ask the user if they were intentionally omitted.
  • Valid, correctly typed code — all emitted code must be valid and correctly typed against the code component's Props interface. Never make up component properties — if a Figma property has no corresponding code prop, omit it rather than invent one.
  • No hardcoded children — verify that every INSTANCE_SWAP property and child component slot uses the dynamic APIs (getInstanceSwap(), findInstance(), findConnectedInstance(), etc.) with executeTemplate(). No slot should contain hardcoded component content.
  • Rules and Pitfalls — check for the common mistakes listed below (string concatenation of template results, unnecessary hasCodeConnect() guards, missing type === 'INSTANCE' checks, etc.)
  • Interpolation wrapping — strings (getString, getEnum, textContent) wrapped in quotes, instance/section values (executeTemplate().example) wrapped in braces, slot sections (getSlot) interpolated as snippet sections inside ` figma.code... `, booleans using conditionals

If anything looks uncertain, consult api.md for API details and advanced-patterns.md for complex nesting.

Inline Quick Reference

instance.* Methods

MethodSignatureReturns
getString(propName: string)string
getBoolean(propName: string, mapping?: {true: any, false: any})`boolean \any`
getEnum(propName: string, mapping: {[figmaVal]: codeVal})any
getInstanceSwap(propName: string)`InstanceHandle \null`
getSlot(propName: string)`ResultSection[] \undefined`
getPropertyValue(propName: string)`string \boolean`
findInstance(layerName: string, opts?: SelectorOptions)`InstanceHandle \ErrorHandle`
findText(layerName: string, opts?: SelectorOptions)`TextHandle \ErrorHandle`
findConnectedInstance(codeConnectId: string, opts?: SelectorOptions)`InstanceHandle \ErrorHandle`
findConnectedInstances(selector: (node) => boolean, opts?: SelectorOptions)InstanceHandle[]
findLayers(selector: (node) => boolean, opts?: SelectorOptions)`(InstanceHandle \TextHandle)[]`

InstanceHandle Methods

MethodReturns
hasCodeConnect()boolean
executeTemplate(){example: ResultSection[], metadata: Metadata}
codeConnectId()`string \null`

TextHandle Properties

PropertyType
.textContentstring
.namestring

SelectorOptions

{ path?: string[], traverseInstances?: boolean }
  • traverseInstances: true — required when the target lives inside another nested instance. Without it, findInstance/findText only search the current instance's own layers and stop at nested instance boundaries.
  • path: string[] — disambiguates when multiple descendants share the same layer name. Lists parent layer names that must appear on the path to the target.

Examples:

// Layer hierarchy:
//   A > C (instance) > "mychild"
// "mychild" sits inside nested instance C, so plain findInstance returns ErrorHandle.
instance.findInstance('mychild', { traverseInstances: true })

// Layer hierarchy:
//   A > C (instance) > "mychild"
//   A > D (instance) > "mychild"
// Two "mychild" layers exist — use path to pick the one under C.
instance.findInstance('mychild', { traverseInstances: true, path: ['C'] })

When to reach into a nested instance from a parent template: only when the parent code component (from Step 4) takes the nested layer as a prop value itself (e.g. <C show={<B />} /> — A forwards B into C). If the parent just composes C and C renders B internally, resolve C with executeTemplate() and let C's own template handle B — don't duplicate B's rendering at the parent level.

Export Structure

export default {
  example: figma.code`...`,                      // Required: ResultSection[]
  id: 'component-name',                         // Required: string
  imports: ['import { X } from "..."'],          // Optional: string[]
  metadata: { nestable: true, props: {} }        // Optional
}

Rules and Pitfalls

  1. Never string-concatenate template results. executeTemplate().example is a ResultSection[] object, not a string. Using + or .join() produces [object Object]. Always interpolate inside tagged templates: ` figma.code${snippet1}${snippet2} `
  2. Do not use hasCodeConnect() guards. Call executeTemplate() directly on any instance after a type === 'INSTANCE' check. The runtime handles instances without Code Connect automatically. // WRONG — hasCodeConnect() gate drops non-CC instances if (icon && icon.type === 'INSTANCE' && icon.hasCodeConnect()) {iconCode = icon.executeTemplate().example} // CORRECT — let the runtime handle all instances if (icon && icon.type === 'INSTANCE') {iconCode = icon.executeTemplate().example}
  3. Check type === 'INSTANCE' before calling executeTemplate(). findInstance(), findConnectedInstance(), and findText() return an ErrorHandle (truthy, but not a real node) on failure — not null. Always add a type check to avoid crashes: if (child && child.type === 'INSTANCE') {...}
  4. Prefer getInstanceSwap() over findInstance() when a component property exists for the slot. findInstance('Star Icon') breaks when the icon is swapped to a different name; getInstanceSwap('Icon') always works regardless of which instance is in the slot.
  5. Use getSlot() only when the Figma property type is SLOT. For INSTANCE_SWAP props, use getInstanceSwap() (returns an InstanceHandle). getSlot() returns structured slot sections, not instances — never call executeTemplate() on its return value.
  6. Property names are case-sensitive and must exactly match what get_context_for_code_connect returns.
  7. Handle multiple template arrays correctly. When iterating over children, set each result in a separate variable and interpolate them individually — do not use .map().join(): ` // Wrong: items.map(n => n.executeTemplate().example).join('\n') // Correct — use separate variables: const child1 = items[0]?.executeTemplate().example const child2 = items[1]?.executeTemplate().example export default {example: figma.code${child1}${child2}} `
  8. Never hardcode slot or children content. Always resolve child instances dynamically — use getInstanceSwap() for INSTANCE_SWAP properties, findInstance()/findConnectedInstance() for direct children — and render them via executeTemplate(). Never construct JSX from a layer name (e.g., <StarIcon />) or guess import paths. If an instance has no Code Connect, omit it — do not add a hardcoded fallback. ` // WRONG — hardcodes the icon from its layer name example: figma.code<Button icon={<StarIcon />}>Submit</Button> // CORRECT — resolves dynamically, works for any swapped icon const icon = instance.findInstance('Icon') let iconCode if (icon && icon.type === 'INSTANCE') {iconCode = icon.executeTemplate().example} example: figma.code<Button${iconCode? figma.code icon={${iconCode}}: ''}>...</Button> `
  9. Attempt to represent every Figma property via a code prop. The code component's Props interface (from Step 4) is the authoritative list of attribute names. For each Figma property, figure out the right way to represent it using the API methods from Step 5 — direct name match, value transformation, or whatever fits. If no code prop fits at all, omit it — don't invent a prop name.

Complete Worked Example

Given URL: https://figma.com/design/abc123/MyFile?node-id=42-100

Step 1: Parse the URL.

  • fileKey = abc123
  • nodeId = 42-100 → 42:100

Step 2: Call get_code_connect_suggestions with fileKey: "abc123", nodeId: "42:100", excludeMappingPrompt: true. Response returns one component with mainComponentNodeId: "42:100". If the response were empty, stop and inform the user. If multiple components were returned, repeat Steps 3–6 for each.

Step 3: Call get_context_for_code_connect with fileKey: "abc123", nodeId: "42:100" (from Step 2), clientFrameworks: ["react"], clientLanguages: ["typescript"].

Response includes properties:

  • Label (TEXT)
  • Variant (VARIANT): Primary, Secondary
  • Size (VARIANT): Small, Medium, Large
  • Disabled (BOOLEAN)
  • Has Icon (BOOLEAN)
  • Icon (INSTANCE_SWAP)

Step 4: Search codebase → find Button component. Read its source to confirm props: variant, size, disabled, icon, children. Import path: "primitives".

Step 5: Create src/figma/primitives/Button.figma.ts:

// url=https://figma.com/design/abc123/MyFile?node-id=42-100
// source=src/components/Button.tsx
// component=Button
import figma from 'figma'
const instance = figma.selectedInstance

const label = instance.getString('Label')
const variant = instance.getEnum('Variant', {
  'Primary': 'primary',
  'Secondary': 'secondary',
})
const size = instance.getEnum('Size', {
  'Small': 'sm',
  'Medium': 'md',
  'Large': 'lg',
})
const disabled = instance.getBoolean('Disabled')
const hasIcon = instance.getBoolean('Has Icon')
const icon = hasIcon ? instance.getInstanceSwap('Icon') : null
let iconCode
if (icon && icon.type === 'INSTANCE') {
  iconCode = icon.executeTemplate().example
}

export default {
  example: figma.code`
    <Button
      variant="${variant}"
      size="${size}"
      ${disabled ? 'disabled' : ''}
      ${iconCode ? figma.code`icon={${iconCode}}` : ''}
    >
      ${label}
    </Button>
  `,
  imports: ['import { Button } from "primitives"'],
  id: 'button',
  metadata: { nestable: true }
}

Step 6: Read back file to verify syntax.

Additional Reference

For advanced patterns (multi-level nested components, findConnectedInstances filtering, metadata prop passing between parent/child templates):

平台分布

Codex

38.54%
按下载量换算2,310

Claude

29.84%
按下载量换算1,789

Cursor

17.29%
按下载量换算1,037

Gemini CLI

8.95%
按下载量换算537

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

调用外部服务

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills