Generates Figma component sets from React/CSS source code using figma-cli. Reads TSX, CSS Modules, and metadata to create component sets with variants, properties, and variable bindings.
Ships in figma-component-generator. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Generate Figma component sets from source code (TSX, CSS Modules, metadata files) using the figma-cli eval command. Reads component logic, styles, and optional metadata to produce a properly structured Figma component set with variants, sizes, colors, and boolean properties -- all bound to Figma variables.
figma-cli repo must be cloned locallynode src/index.js daemon start)To verify the connection:
curl -s http://localhost:9222/json
/figma-component-generator <figma-page-url> [component-path]
figma-page-url: URL of the Figma page where the component should be created (required)component-path: Path to the component folder (if not provided, ask the user)Parse the Figma page URL to extract the file and page context. If component-path is not provided, ask the user for it.
Locate the figma-cli repo. Check common locations:
figma-cli directory in the current working directory or its parent~/figma-cli or ~/Projects/figma-cliStore the CLI path for use in all subsequent eval commands:
CLI_PATH=<path-to-figma-cli>
Read the component files. At minimum, look for:
.tsx, .jsx, .vue, .svelte): Extract props, variants, types, default values.module.css, .css, .scss): Extract sizing, colors, spacing, border radius, token usage.metadata.ts, .metadata.json): If available, extract structured variant definitions, sizes, colors, descriptionsFrom these files, build a component spec:
variant: solid|soft|outline, color: primary|danger|..., size: sm|md|lg)var(--background-interactive-primary))Before querying variables or generating, determine whether this component should be generated as a component set, and if so, resolve its atom dependencies.
Read references/rules/atomic-dependencies.md and follow the classification and resolution workflow:
composition.nestedComponents, composition.commonPartners) and source importscreateInstance() instead of raw frames for found dependencies.An external JSON lookup table may exist that maps component names to Figma node IDs. Read references/figma-map-lookup.md for the full schema and generation instructions.
Resolution order:
figma-map.json file provided by the user (typically in ~/.claude/data/). If found, extract the figmaFileKey and compare it to the file key parsed from the Figma URL. If they match, use the map.components.<name>.componentSetId in the map. If non-null, use figma.getNodeByIdAsync(id) to fetch the node directly. This avoids cross-page traversal entirely.figma.root.findAll(n => n.type === 'COMPONENT_SET' && n.name === name).The lookup table is optional — the skill must work without it. Never hardcode a specific file path; treat it as an external data source that may or may not be present.
Before generating, fetch all available Figma variables to build a mapping:
cd $CLI_PATH && node src/index.js eval "
(async () => {
const allVars = await figma.variables.getLocalVariablesAsync();
return JSON.stringify(allVars.map(v => v.name));
})()"
Token-to-variable mapping: Convert CSS token names to Figma variable paths:
var(--background-interactive-primary) maps to background/interactive/primaryvar(-- and ), replace - with / for path segmentsFor each token used by the component, check if a matching Figma variable exists. Track any unmapped tokens for the final report.
For detailed mapping rules and patterns, read references/figma-plugin-api-patterns.md.
Parse the node-id from the Figma URL (URL-encoded, e.g., 2001-2 means 2001:2).
cd $CLI_PATH && node src/index.js eval "
(async () => {
const targetId = '<decoded-node-id>';
const page = figma.root.children.find(p => p.id === targetId);
if (!page) {
// Fallback: find by name
const page2 = figma.root.children.find(p => p.name.trim() === '> <ComponentName>');
if (page2) { figma.currentPage = page2; return 'Navigated by name'; }
return 'Page not found';
}
figma.currentPage = page;
return 'Navigated to: ' + page.name;
})()"
Build a single eval script that creates all variant combinations. The script must:
references/figma-typography.md)solid + primary + md), create a figma.createComponent()Variant=solid, Color=primary, Size=mdcomponentNode.createInstance() instead of creating raw frames. See references/rules/atomic-dependencies.md for instance creation and variant selection patterns.figma.combineAsVariants(components, figma.currentPage)For detailed Figma Plugin API patterns and code examples, read references/figma-plugin-api-patterns.md.
Before generating, scan the component source for these patterns and load the relevant rule:
| Pattern | Detection Signal | Rule File |
|---|---|---|
| Sizing & layout | Any component | references/rules/sizing-modes.md (always read) |
| Icons | lucide-react imports, icon props, SVG elements, spinners | references/figma-icon-library.md + references/rules/icon-recoloring.md |
| Typography | Text nodes, font tokens, text-style CSS properties | references/figma-typography.md |
| Nested components | .map() loops, repeated elements with per-item state (isActive, isSelected) | references/rules/nested-components.md |
| Dynamic item count | Positive: prop is an array mapped with .map(); runtime-determined count; no fixed upper bound. Negative: named structural children (header/footer); fixed count (OTP=6, rating=5); single-child wrapper (Tooltip trigger); render-props | references/rules/slots.md |
| Floating overlays | Imports from @floating-ui/*, @radix-ui/react-popover, @radix-ui/react-dropdown-menu, @radix-ui/react-tooltip, cmdk, @headlessui/react; uses createPortal; position: absolute|fixed with high z-index on the expanded part; conditional render of menu/dropdown/popover content | references/rules/floating-overlays.md |
| Atomic dependencies | Molecule/organism; metadata nestedComponents non-empty; imports design-system components | references/rules/atomic-dependencies.md |
Cross-dependency: Nested components and Dynamic item count often fire together. When a parent maps over items AND each item has per-item state (isActive, isSelected), you need BOTH: create a sub-component set per nested-components.md, then use slot Pattern A (instance-filled) in the parent per slots.md. If items are heterogeneous or have no per-item state, only slots.md applies (Pattern B, frame-filled).
(async () => { ... })()layoutSizingHorizontaltextStyleId) BEFORE setting .characters (avoids Inter font loading issues)JSON.stringify() for structured resultsfigma.variables.setBoundVariableForPaint() for variable binding.js file and use eval --file <path>, then clean up afterreferences/figma-icon-library.mdreferences/figma-typography.mdArrange variants in a grid where:
After generation, present a summary:
## Component Generated: Badge
- **Variants created**: 63 (3 variants x 7 colors x 3 sizes)
- **Properties**: Variant, Color, Size, Show Dot (boolean)
- **Variables bound**: 42 fill bindings, 21 stroke bindings
- **Unmapped tokens**: (none)
OR
- **Unmapped tokens**:
- `var(--background-utility-coral)` -- no matching Figma variable found
- `var(--foreground-utility-coral)` -- no matching Figma variable found
- **Dependencies resolved**: 3/5 (Button, SearchInput, Select found; Input, Checkbox not in file)
OR
- **Dependencies**: none (atom component)
If there are unmapped tokens, suggest the user create the missing variables in Figma or check for naming mismatches.
node src/index.js daemon restart and retry.LICENSE.txt (opens in a new tab)README.md (opens in a new tab)references/figma-icon-library.md (opens in a new tab)references/figma-map-lookup.md (opens in a new tab)references/figma-plugin-api-patterns.md (opens in a new tab)references/figma-typography.md (opens in a new tab)references/rules/atomic-dependencies.md (opens in a new tab)references/rules/floating-overlays.md (opens in a new tab)references/rules/icon-recoloring.md (opens in a new tab)references/rules/nested-components.md (opens in a new tab)references/rules/sizing-modes.md (opens in a new tab)references/rules/slots.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/figma-component-generator:figma-component-generatorfrom figma-component-generator
npx claudepluginhub cris-achiardi/claude-skills --plugin figma-component-generatorOther plugins' skills for the same job