token_map
Map Figma variables and paint styles to project design tokens from CSS or Tailwind config, enabling code generation that uses existing tokens instead of hard-coded values.
Instructions
Map the document's Figma variables — and its shared paint styles (single solid color styles, the design-token mechanism of pre-variables files; such rows carry source: 'style') — to the project's design tokens, so generated code references existing tokens instead of hard-coded values. Joins the grounded Figma names + values against tokens parsed from the project CSS (Tailwind v4 @theme or :root custom properties); the match is name-based with an exact color value-match as confirmation. When several project tokens share the exact same color value and the name cannot pick one, the mapping is capped below 'high' and candidate.ambiguousWith lists the other same-value tokens — verify that pick semantically instead of trusting it blindly. On a Tailwind project a variable that hits a framework built-in scale (spacing/N, line-height/N, weight/*) is reported as status 'framework-builtin' with { builtin: { scale, step } } rather than unmapped — it has no @theme token but the utility (p-4 / gap-4, leading-7, font-bold) is still usable. A variable in a multi-mode collection whose value differs per mode (a Light/Dark theme) carries figmaModes (mode name → value per theme; figmaValue is only the default mode), and the result lists themedCollections — keep such tokens theme-aware (a token that itself switches per theme, or the non-default values wired through the project's dark-mode mechanism), never just the default-mode literal. tokenSource overrides the detected styling config; rootDir defaults to the server cwd. Tailwind v3 JS configs are not yet parsed (pass tokenSource to a CSS file). An explicit docs/figma-token-map.md row (FigmaName | ref) overrides the fuzzy join with matchedBy ["map-file"] — this file is the durable record a verified token mapping is written back to, so the next run reuses it instead of re-guessing an ambiguous or value-only match. A row whose ref no longer resolves to a project token is reported in staleOverrides and degrades to the normal join. Returns { mappings (candidate + confidence + status + matchedBy + builtin), unmapped, staleOverrides, tokenSource, profile }.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rootDir | No | Project root; defaults to the server cwd | |
| threshold | No | Confidence at/above which a match counts as reliable (default 0.7) | |
| tokenSource | No | Path (relative to rootDir) to a CSS file holding the tokens; overrides detection |