Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Extract design tokens, colors, typography, and spacing from Figma files via REST API. Use when building a design-to-code pipeline, syncing design tokens, or extracting styles from a Figma design system file. Trigger with phrases like "figma design tokens", "extract figma styles", "figma to CSS", "sync figma colors", "figma typography".
.claude/skills/jeremylongshore-figma-core-workflow-a/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -5% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 25% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 64% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 81% | 0% |
| case-17 | ✗→✓ | ▲ Improved | 74% | 0% |
The primary workflow for Figma API integrations: extracting design tokens (colors, typography, spacing) from a Figma file and converting them to CSS custom properties, JSON tokens, or Tailwind config.
figma-install-auth setupFIGMA_PAT and FIGMA_FILE_KEY env vars settypescriptimport { FigmaClient } from './figma-client'; const client = new FigmaClient(process.env.FIGMA_PAT!); const fileKey = process.env.FIGMA_FILE_KEY!; // GET /v1/files/:key -- returns styles map in response const file = await client.getFile(fileKey); // file.styles is a map: nodeId -> { key, name, style_type, description } // style_type: "FILL" | "TEXT" | "EFFECT" | "GRID" const colorStyles = Object.entries(file.styles) .filter(([, s]) => s.style_type === 'FILL') .map(([nodeId, s]) => ({ nodeId, name: s.name })); const textStyles = Object.entries(file.styles) .filter(([, s]) => s.style_type === 'TEXT') .map(([nodeId, s]) => ({ nodeId, name: s.name })); console.log(`Found ${colorStyles.length} color styles, ${textStyles.length} text styles`);
typescript// Fetch the actual nodes to get fill colors and text properties const styleNodeIds = colorStyles.map(s => s.nodeId); const nodesResponse = await client.getFileNodes(fileKey, styleNodeIds); interface DesignToken { name: string; type: 'color' | 'typography' | 'spacing'; value: string; } const tokens: DesignToken[] = []; for (const [nodeId, nodeData] of Object.entries(nodesResponse.nodes)) { const node = nodeData.document; const styleName = colorStyles.find(s => s.nodeId === nodeId)?.name; if (node.fills?.[0]?.type === 'SOLID' && node.fills[0].color) { const { r, g, b, a } = node.fills[0].color; // Figma colors are 0-1 floats; convert to 0-255 const hex = '#' + [r, g, b].map(v => Math.round(v * 255).toString(16).padStart(2, '0') ).join(''); tokens.push({ name: styleName ?? node.name, type: 'color', value: a !== undefined && a < 1 ? `rgba(${Math.round(r*255)}, ${Math.round(g*255)}, ${Math.round(b*255)}, ${a.toFixed(2)})` : hex, }); } }
typescript// Fetch text style nodes const textNodeIds = textStyles.map(s => s.nodeId); const textNodes = await client.getFileNodes(fileKey, textNodeIds); for (const [nodeId, nodeData] of Object.entries(textNodes.nodes)) { const node = nodeData.document; const styleName = textStyles.find(s => s.nodeId === nodeId)?.name; if (node.style) { tokens.push({ name: styleName ?? node.name, type: 'typography', value: JSON.stringify({ fontFamily: node.style.fontFamily, fontSize: `${node.style.fontSize}px`, fontWeight: node.style.fontWeight, lineHeight: node.style.lineHeightPx ? `${node.style.lineHeightPx}px` : 'normal', letterSpacing: node.style.letterSpacing ? `${node.style.letterSpacing}px` : '0', }), }); } }
typescriptfunction tokensToCss(tokens: DesignToken[]): string { const lines = [':root {']; for (const token of tokens) { const varName = `--${token.name.toLowerCase().replace(/[\s/]+/g, '-')}`; if (token.type === 'color') { lines.push(` ${varName}: ${token.value};`); } else if (token.type === 'typography') { const t = JSON.parse(token.value); lines.push(` ${varName}-family: ${t.fontFamily};`); lines.push(` ${varName}-size: ${t.fontSize};`); lines.push(` ${varName}-weight: ${t.fontWeight};`); } } lines.push('}'); return lines.join('\n'); } import { writeFileSync } from 'fs'; writeFileSync('src/styles/tokens.css', tokensToCss(tokens)); console.log(`Generated ${tokens.length} tokens to src/styles/tokens.css`);
typescript// GET /v1/files/:key/variables/local (Tier 2, requires file_variables:read) const vars = await client.getLocalVariables(fileKey); // vars.meta.variables: Record<variableId, Variable> // vars.meta.variableCollections: Record<collectionId, Collection> for (const [id, variable] of Object.entries(vars.meta.variables)) { const collection = vars.meta.variableCollections[variable.variableCollectionId]; console.log(`${collection.name}/${variable.name}: ${variable.resolvedType}`); // resolvedType: "COLOR" | "FLOAT" | "STRING" | "BOOLEAN" // Each variable has values per mode for (const [modeId, value] of Object.entries(variable.valuesByMode)) { const modeName = collection.modes.find(m => m.modeId === modeId)?.name; console.log(` ${modeName}: ${JSON.stringify(value)}`); } }
| Error | Cause | Solution | |-------|-------|----------| | Empty styles map | File has no published styles | Publish styles in Figma first | | null node in response | Node was deleted | Filter nulls before processing | | 403 on variables endpoint | Not Enterprise plan | Use styles endpoint instead | | Color looks wrong | Forgot 0-1 to 0-255 conversion | Multiply by 255 before hex |
Extract every fill color used by published styles and emit CSS custom properties:
bash# 1. List published styles, 2. resolve their node values (see Steps 1-2) curl -s -H "X-Figma-Token: ${FIGMA_PAT}" \ "https://api.figma.com/v1/files/${FIGMA_FILE_KEY}/styles" \ | jq -r '.meta.styles[] | select(.style_type == "FILL") | "\(.node_id)\t\(.name)"'
text1:5 Color/Brand/Primary 1:6 Color/Brand/Secondary 1:9 Color/Neutral/100
Feed those node IDs to /v1/files/:key/nodes?ids=... and run the Step 4 generator to produce:
css:root { --color-brand-primary: #4f46e5; --color-brand-secondary: #22d3ee; --color-neutral-100: #f5f5f5; }
Full token-extraction walkthrough: references/extract-typography-tokens.md and references/generate-css-custom-properties.md.
For asset export, see figma-core-workflow-b.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 44,134 | 23,800 | -46% | 1 | 1 | 0% | 7,640 | 7,262 | -5% | 0 | 0 | — |
case-02 | fail→pass | 28,099 | 30,421 | +8% | 1 | 1 | 0% | 5,510 | 6,872 | +25% | 0 | 0 | — |
case-03 | fail→pass | 9,722 | 6,786 | -30% | 1 | 1 | 0% | 2,036 | 3,334 | +64% | 0 | 0 | — |
case-04 | fail→fail | 9,916 | 12,504 | +26% | 1 | 1 | 0% | 1,931 | 4,417 | +129% | 0 | 0 | — |
case-05 | fail→fail | 15,044 | 9,730 | -35% | 1 | 1 | 0% | 2,897 | 3,985 | +38% | 0 | 0 | — |
case-06 | pass→pass | 15,212 | 12,732 | -16% | 1 | 1 | 0% | 2,379 | 4,111 | +73% | 0 | 0 | — |
case-07 | pass→pass | 9,952 | 8,442 | -15% | 1 | 1 | 0% | 1,992 | 3,850 | +93% | 0 | 0 | — |
case-08 | pass→pass | 8,234 | 7,299 | -11% | 1 | 1 | 0% | 1,680 | 3,546 | +111% | 0 | 0 | — |
case-09 | pass→pass | 8,681 | 8,483 | -2% | 1 | 1 | 0% | 1,547 | 3,349 | +116% | 0 | 0 | — |
case-10 | pass→pass | 4,774 | 2,609 | -45% | 1 | 1 | 0% | 847 | 2,503 | +196% | 0 | 0 | — |
case-11 | pass→pass | 8,562 | 4,272 | -50% | 1 | 1 | 0% | 1,049 | 2,686 | +156% | 0 | 0 | — |
case-12 | pass→pass | 10,353 | 6,153 | -41% | 1 | 1 | 0% | 1,555 | 2,935 | +89% | 0 | 0 | — |
case-13 | pass→pass | 10,357 | 11,328 | +9% | 1 | 1 | 0% | 2,143 | 4,446 | +107% | 0 | 0 | — |
case-14 | pass→pass | 5,249 | 5,418 | +3% | 1 | 1 | 0% | 828 | 2,807 | +239% | 0 | 0 | — |
case-15 | pass→pass | 11,209 | 9,691 | -14% | 1 | 1 | 0% | 2,258 | 3,996 | +77% | 0 | 0 | — |
case-16 | fail→pass | 8,826 | 6,394 | -28% | 1 | 1 | 0% | 1,742 | 3,145 | +81% | 0 | 0 | — |
case-17 | fail→pass | 8,059 | 3,640 | -55% | 1 | 1 | 0% | 1,425 | 2,473 | +74% | 0 | 0 | — |
case-18 | pass→pass | 4,323 | 1,838 | -57% | 1 | 1 | 0% | 614 | 2,352 | +283% | 0 | 0 | — |
case-19 | pass→pass | 3,448 | 3,034 | -12% | 1 | 1 | 0% | 635 | 2,497 | +293% | 0 | 0 | — |
case-20 | pass→pass | 7,122 | 2,652 | -63% | 1 | 1 | 0% | 1,344 | 2,597 | +93% | 0 | 0 | — |
case-21 | pass→pass | 8,345 | 229,464 | +2650% | 1 | 1 | 0% | 1,212 | 2,896 | +139% | 0 | 0 | — |
case-22 | pass→pass | 922,487 | 10,905 | -99% | 1 | 1 | 0% | 2,188 | 3,807 | +74% | 0 | 0 | — |
case-23 | pass→pass | 8,945 | 6,105 | -32% | 1 | 1 | 0% | 1,616 | 3,217 | +99% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +22 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.