$npx -y skills add bluzir/claude-code-design --skill ingest-figmaPull design tokens + frame structure from a Figma URL via the Figma REST API. Requires FIGMA_TOKEN env var.
| 1 | # Ingest Figma |
| 2 | |
| 3 | Extract design system from a Figma file using the REST API. Falls back to SVG-import if no token available. |
| 4 | |
| 5 | ## Preflight |
| 6 | |
| 7 | 1. `Bash(test -n "$FIGMA_TOKEN" && echo has-token || echo no-token)` — check env var |
| 8 | 2. If `no-token`: |
| 9 | - Tell user: "No `FIGMA_TOKEN` found. Two options: (a) Get a token at https://www.figma.com/developers/api#access-tokens and `export FIGMA_TOKEN=...` in your shell, or (b) export the frame as SVG in Figma (Right-click frame → Copy as → Copy as SVG) and paste the file to `artifacts/ingested/` — I'll parse the SVG." |
| 10 | - Stop; wait for user response. |
| 11 | |
| 12 | ## Parse URL |
| 13 | |
| 14 | Figma URL format: `https://www.figma.com/(file|design|proto)/<fileKey>/<name>?node-id=<nodeId>` |
| 15 | |
| 16 | Extract: |
| 17 | - `fileKey` — alphanumeric after `/file/` or `/design/` |
| 18 | - `nodeId` — query param `node-id` (URL-decoded, often contains `:`) |
| 19 | |
| 20 | ## Steps (token path) |
| 21 | |
| 22 | 1. **Fetch file nodes:** |
| 23 | ``` |
| 24 | Bash(curl -H "X-FIGMA-TOKEN: $FIGMA_TOKEN" \ |
| 25 | "https://api.figma.com/v1/files/<fileKey>/nodes?ids=<nodeId>&depth=2" \ |
| 26 | -o /tmp/figma-<ts>.json) |
| 27 | ``` |
| 28 | |
| 29 | 2. **Fetch style definitions:** |
| 30 | ``` |
| 31 | Bash(curl -H "X-FIGMA-TOKEN: $FIGMA_TOKEN" \ |
| 32 | "https://api.figma.com/v1/files/<fileKey>/styles" \ |
| 33 | -o /tmp/figma-styles-<ts>.json) |
| 34 | ``` |
| 35 | |
| 36 | 3. **Parse JSON:** |
| 37 | - Colors: walk `document.children` → find `fills` with `type === 'SOLID'` → extract `color {r,g,b}` → convert to hex |
| 38 | - Effects (shadows): find `effects` with `type === 'DROP_SHADOW'` |
| 39 | - Text styles: find `style` with `fontFamily`, `fontSize`, `fontWeight`, `lineHeightPx` |
| 40 | - Components: traverse for `type === 'COMPONENT'` and `type === 'COMPONENT_SET'` |
| 41 | - Local styles from `/styles`: styles endpoint returns named variables |
| 42 | |
| 43 | 4. **Write:** |
| 44 | ``` |
| 45 | artifacts/ingested/figma-<fileKey>-tokens.json |
| 46 | ``` |
| 47 | Same schema as `ingest-github`, plus `"source": { "figma_url": "...", "file_key": "...", "node_id": "..." }`. |
| 48 | |
| 49 | 5. **Offer next step:** |
| 50 | - "Extracted X colors, Y text styles, Z components from Figma. Saved to `artifacts/ingested/figma-<fileKey>-tokens.json`." |
| 51 | - Continue with `/create-design-system` or start artifact skill. |
| 52 | |
| 53 | ## Steps (SVG fallback path) |
| 54 | |
| 55 | 1. User drops SVG file in `artifacts/ingested/` |
| 56 | 2. `Read` the SVG content |
| 57 | 3. Extract `fill="#..."` / `stroke="#..."` / `style="...color..."` attributes |
| 58 | 4. Recognize `<text>` elements for font info (`font-family`, `font-size`, `font-weight`) |
| 59 | 5. Build partial tokens.json with `"source": { "svg": "<path>" }` + confidence flags |
| 60 | 6. Note: SVG export loses component structure, only visual primitives |
| 61 | |
| 62 | ## Rate limits |
| 63 | |
| 64 | Figma API: 50 req/min for free tier. Fetching one frame + styles = 2 requests, well under limit. |
| 65 | |
| 66 | ## Security |
| 67 | |
| 68 | `FIGMA_TOKEN` in env only — never written to disk or logged. |