figma_ds_extract_tokens
Extract design tokens from analyzed codebases into canonical DTCG JSON plus CSS, Tailwind, SCSS or TypeScript outputs by mining declared styles and recurring raw values.
Instructions
Extract design tokens from analyzed codebases into canonical DTCG JSON (plus optional CSS variables / Tailwind / SCSS / TypeScript projections). Mines declared styling intent first — :root and @theme custom properties (light+dark → multi-mode tokens), SCSS variables, tailwind.config theme values, shadcn HSL triples — then promotes recurring raw values (hex colors, spacing/radius/font sizes) above a frequency threshold. Every token carries provenance (source file:line, confidence, frequency) in $extensions. Names are structural as-mined; do a semantic-naming review pass with the user afterwards. The DTCG output is directly importable into Figma variables with figma_import_tokens (top-level groups become collections). Requires figma_ds_analyze to have run for the same outDir. Local Mode only.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| write | No | Write token files to <outDir>/tokens/ (default true). False returns the DTCG document inline instead (dry run). | |
| outDir | No | The outDir used in figma_ds_analyze (reads .extraction/analysis.json from it). Default: '<first target of the analysis run>/design-system' — pass explicitly when in doubt. | |
| formats | No | Token file formats to write under <outDir>/tokens/. 'dtcg' (canonical) is always written. Match the app's styling method — e.g. add 'tailwind-v4' for a Tailwind app, 'scss' for SCSS. | |
| targets | No | Override: scan these app roots instead of the analysis manifest's targets (rarely needed). | |
| dtcgDialect | No | DTCG dialect: 'legacy' hex-string colors (max compatibility) or '2025' DTCG 2025.10 object colors/dimensions. | legacy |
| minFrequency | No | How often a raw (undeclared) value must recur to be promoted to a token (default 4). Values below the threshold are listed in the report for review. |