token-forge

One design-token source (W3C DTCG JSON) built with Style Dictionary into CSS variables, a Tailwind v4 theme and typed JS; four Lit web components that use only semantic tokens; a GitHub Action that turns every token PR into a semver release plan; and an LLM migration agent that moves legacy CSS onto the tokens, measured against two codemods and a whole-file LLM rewrite. This page is styled with the generated tokens: the button above switches the theme by changing one attribute.

Open the component Storybook   Code on GitHub

Token-migration benchmark

30 legacy stylesheets (20 CSS, 10 Lit), 438 graded declarations. Several tokens share a light-theme value (white is page, card and secondary-button background), so a value-only codemod can look right in light mode and still paint the wrong colour in dark mode. "Dark-theme paint errors" counts exactly that. Model: Qwen3-Coder 30B (Q4_K_M) on one NVIDIA L4 via Ollama, temperature 0.3, 3 seeds. The corpus and its labels are synthetic and were written by me; see the README for limits.

Held-out test split: 292 graded declarations

MethodCorrectDark-theme paint errorsCollateral editsLLM calls / file
Codemod, exact value, first match76.4 %63.00.00.0
Codemod + near-miss + selector heuristics94.2 %12.00.00.0
LLM rewrites whole file90.6 % ± 1.115.00.00.0
Agent, LLM sees only property + value87.0 % ± 0.031.00.03.5
Agent, LLM sees file + rule context96.0 % ± 0.27.70.03.5
By site typeexactambiguousnearformatdeprecateddimkeep
Codemod, exact value, first match89.0/8923.0/491.0/4020.0/2017.0/1750.0/5023.0/27
Codemod + near-miss + selector heuristics89.0/8938.0/4938.0/4020.0/2017.0/1750.0/5023.0/27
LLM rewrites whole file86.3/8934.7/4935.0/4020.0/2015.0/1748.0/5025.7/27
Agent, LLM sees only property + value89.0/8923.0/4932.0/4020.0/2017.0/1750.0/5023.0/27
Agent, LLM sees file + rule context89.0/8939.3/4938.0/4020.0/2017.0/1750.0/5027.0/27

Dev split (used for tuning): 146 graded declarations

MethodCorrectDark-theme paint errorsCollateral editsLLM calls / file
Codemod, exact value, first match69.2 %44.00.00.0
Codemod + near-miss + selector heuristics90.4 %12.00.00.0
LLM rewrites whole file85.6 %20.00.00.0
Agent, LLM sees file + rule context94.5 %6.00.04.2
By site typeexactambiguousnearformatdeprecateddimkeep
Codemod, exact value, first match47.0/4712.0/280.0/264.0/43.0/324.0/2411.0/14
Codemod + near-miss + selector heuristics47.0/4721.0/2822.0/264.0/43.0/324.0/2411.0/14
LLM rewrites whole file47.0/4719.0/2817.0/264.0/43.0/321.0/2414.0/14
Agent, LLM sees file + rule context47.0/4723.0/2823.0/264.0/43.0/324.0/2414.0/14

Token checks

32 WCAG 2.2 contrast pairs checked in both themes on every build; the lowest margin is 6 % above its minimum. Components are tested with axe (WCAG 2.2 AA) in both themes, with keyboard and form-association tests, and with visual snapshots in a pinned Playwright container.