一键导入
figma-code-connect
Generate a Figma Code Connect file (*.figma.tsx) for a design system component
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate a Figma Code Connect file (*.figma.tsx) for a design system component
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Migrate a design-system component off Ant Design to a DS-native styled-components implementation. Encodes the playbook + refinements from the Badge/Typography migrations so each subsequent component is faster. Use when removing antd from a `@synerise/ds-*` package (the antd-removal initiative).
End-to-end DS release — publish bumped packages with lerna, generate a changelog from GitLab MRs, create a Jira release task plus a GitLab release, post a two-audience release changelog to the Teams releases channel, and optionally open DS-upgrade branches/MRs in the portal-ui-bridge and portal-next consumer repos
Add or update an MDX overview documentation page for a component in Storybook, detailing usage patterns, API surface, and implementation guidance.
Audit a design system package for code quality, test coverage, Storybook completeness, and code hygiene issues. Produces a severity-ranked report and a fix plan for critical/important issues.
Verify a component package is ready for publishing by checking documentation, stories, argTypes, code tabs, overview page, unit tests, and interaction tests.
Generate a CLAUDE.md file for a design system component package that documents its structure, API, sub-components, and implementation details for AI-assisted development.
基于 SOC 职业分类
| name | figma-code-connect |
| description | Generate a Figma Code Connect file (*.figma.tsx) for a design system component |
Generate a <ComponentName>.figma.tsx file that connects a React component to its Figma design using the @figma/code-connect library.
The user must provide:
Switch, Button, AvatarThe user may optionally provide:
fsSZONXpVvtrDsCgtu01Jbhttps://www.figma.com/design/fsSZONXpVvtrDsCgtu01Jb/Synerise-Design-System?node-id=<nodeId>&m=devFind the component source files:
packages/components/<component-name>/src/<ComponentName>.tsx
packages/components/<component-name>/src/<ComponentName>.types.ts
packages/components/<component-name>/src/index.ts
Read these files to understand:
.types.ts)index.ts and the main component file)If the Figma MCP server is available (tools like mcp__figma__get_design_context exist), use it to get the component details:
fileKey and nodeId from it.curl -s -H "X-Figma-Token: <token>" "https://api.figma.com/v1/files/fsSZONXpVvtrDsCgtu01Jb/component_sets" \
| python3 -c "import sys,json; [print(json.dumps({...})) for cs in json.load(sys.stdin)['meta']['component_sets'] if '<name>' in cs['name'].lower()]"
mcp__figma__get_design_context with the nodeId and fileKey to get design context, screenshots, and code suggestions.get_code_connect_suggestions), follow the flow to map sub-components (like Button) and then use the returned design context.If the MCP server is NOT available, fall back to:
From the component set's componentPropertyDefinitions:
variant: {} keys in figma.connect()figma.boolean('PropName', { true: ..., false: ... })figma.string('PropName') (note: Figma text props often have ✏️ emoji prefix)figma.instance('LayerName')From the layer tree (depth exploration):
componentPropertyReferences pointing to text propertiesrefs.visibleCreate packages/components/<component-name>/src/<ComponentName>.figma.tsx following these conventions:
import figma from '@figma/code-connect';
import ComponentName from './ComponentName';
// Import any additional named exports needed (e.g., RawSwitch, ButtonGroup)
const FIGMA_URL = 'https://www.figma.com/design/fsSZONXpVvtrDsCgtu01Jb/Synerise-Design-System?node-id=<nodeId>&m=dev';
// If there are reusable prop mappings shared across variants, define them as shared objects:
const baseProps = {
label: figma.boolean('Show Header', {
true: figma.string('✏️Header Text'),
false: undefined,
}),
};
// One figma.connect() call per variant combination that produces meaningfully different code
figma.connect(ComponentName, FIGMA_URL, {
variant: { State: 'Default' },
props: baseProps,
example: (props) => <ComponentName {...mapped props} />,
});
Use these figma.* helpers to map Figma properties to React props:
| Figma property type | Helper | Example |
|---|---|---|
| String | figma.string('PropName') | figma.string('Text') |
| Boolean | figma.boolean('PropName') | figma.boolean('Has Icon') |
| Boolean → conditional | figma.boolean('PropName', { true: value, false: undefined }) | Show/hide a prop based on Figma toggle |
| Enum → string | figma.enum('PropName', { 'FigmaValue': 'react-value' }) | figma.enum('Size', { 'Small': 'S', 'Medium': 'M' }) |
| Enum → boolean | figma.enum('PropName', { 'Value': true }) | Used when a Figma enum maps to a boolean prop |
| Instance (slot) | figma.instance('LayerName') | figma.instance('Icon') |
| Children (auto slot) | figma.children('LayerName') | figma.children('*') for all children |
| Nested props | figma.nestedProps('LayerName', { ... }) | Access sub-component properties |
| Class name | figma.className([...]) | Combine into className prop |
figma.connect() per distinct code output. If two variant combos produce the same JSX, merge them. If they produce different JSX (different props, different components), keep them separate.figma.nestedProps when a Figma sub-layer (like Label or Description) has its own properties you need to access.example must produce valid, copy-pasteable JSX that a developer would actually write.State: Selected maps to a boolean React prop like checked, set it directly in the example: <Switch checked />.State: Disabled maps to a disabled prop, set it directly. For components that pass disabled via sub-props (like buttonProps), use the correct nesting.baseProps) to avoid duplication across variant figma.connect() calls.✏️ — include these exactly as they appear in Figma.If the MCP server is available and mcp__figma__send_code_connect_mappings is accessible:
get_code_connect_suggestions to check if sub-components (like Button) need mappingsend_code_connect_mappings with the approved mappingsAfter generating the file:
index.tsOutput:
figma.connect() calls were created and what variant combinations they cover