Audit the repo's styling for raw colours, sizes, spacing and fonts, then define design tokens with the user (primitives, semantic tokens, light and dark) in one W3C Design Tokens 2025.10 source that builds into the repo's own styling (CSS variables, Tailwind 4 or 3, SCSS, TS), into Swift, an asset catalog, Jetpack Compose and Android resources for an iOS or Android app (preview), and into Figma variables. Use for the tokens phase of a massimo project, or when the user asks about design tokens...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Tokens?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/darioabc-tokens)
---
name: tokens
description: Audit the repo's styling for raw colours, sizes, spacing and fonts, then define design tokens with the user (primitives, semantic tokens, light and dark) in one W3C Design Tokens 2025.10 source that builds into the repo's own styling (CSS variables, Tailwind 4 or 3, SCSS, TS), into Swift, an asset catalog, Jetpack Compose and Android resources for an iOS or Android app (preview), and into Figma variables. Use for the tokens phase of a massimo project, or when the user asks about design tokens, the colour palette, the type scale or the spacing scale.
---
# massimo: tokens
One source of truth for every design value, written in the W3C Design Tokens format 2025.10 in `<project>/tokens/`, built into whatever the repo's styling consumes. The audit shows how far the code has drifted; the proposal shows how far the tokens will bring it back. The user approves each group before anything is wired in.
Plugin root: two directories above this skill's base directory. Follow `<plugin>/reference/project.md` → Session protocol, and judge proposals with `<plugin>/reference/canon.md`. `<project>` is the project folder: `projectDir` in `massimo.config.json`, `design-system` by default.
## Run
1. **Begin.** `state.mjs set tokens in_progress`.
2. **Audit.** `node <project>/scripts/audit.mjs`, then read `<project>/audits/latest.md`. In an iOS or Android project (`platforms` in `massimo.config.json`), `latest.md` opens with how many colours the Swift and Kotlin files hard-code, and where: tell the user that count and the files that hold the most. It is read only: no baseline, and `--check` does not see it. Tell the user the canon numbers in one short block (distinct colours and clusters, font sizes, families, off-grid spacing, arbitrary values), plus the three files that leak the most. That is the "before". When `latest.md` has a Tailwind palette classes section, say how many palette classes the code uses and the most used ones: once colour tokens exist, a palette class whose colour a token holds becomes a finding with that token as its fix, and the others stay counted, out of the baseline, until a token holds their colour.
3. **Start from what exists.** If the repo's CSS has to stay the source (the file also holds component classes, or scripts and pages read it as it is), offer the mirror instead of a token set of its own: set `tokens.mirror` to `true`, with `tokens.styleFiles`, `darkSelector`, `darkMedia` and `selectors` saying exactly how the app switches theme, and set `"minScripts": "0.3.0"` at the top of `massimo.config.json`, since older vendored scripts ignore the mirror and would pass CI while it is behind. Then run `node <project>/scripts/tokens.mjs mirror`. It writes the token set from the CSS, keeping every CSS name, a value under any selector that is not a theme in `$extensions.massimo.scopes`, and the comment on each root declaration as its description (a section heading is not one). Show the user its notes: a selector that looks like a theme but is not in the config, two selectors in one theme with different values, a value written with `!important`, a Sass declaration with interpolation (`#{toRem(2)}`), which only Sass can turn into CSS, so the mirror leaves it out, and anything that did not convert exactly. Edits go to the CSS from then on, followed by `tokens.mjs mirror`, then `tokens.mjs build`, then `tokens.mjs resolved`; `tokens.mjs check` fails while any of them is behind. Steps 4 and 5 do not apply, since the CSS already holds the values; in step 6, no output may point at a mirrored file. Otherwise, if the project still has a `tokens.json` from before 0.2.0 (`tokens.mjs check` reads it fine), offer `node <project>/scripts/tokens.mjs migrate` first: it writes the 2025.10 files beside it, lists in `tokens/migration-report.md` anything that did not carry over exactly, checks every output still builds the same, and points the config at the new files. Show the user the report. In an iOS or Android project, `tokens.mobileSources` names where the app keeps its colours (detect proposes it: the app's asset catalogs, its res/values files), and `node <project>/scripts/tokens.mjs extract` reads them: each colour set with its dark appearance and its catalog name, each `<color>` and `<dimen>` with its `values-night` value. Show the user its notes: a colour with high-contrast entries (kept beside the token, never dropped), a system colour, an empty colour set, a theme attribute, a qualifier massimo does not read yet. `<plugin>/reference/mobile.md` says what is read and how. Otherwise, if the style files already define custom properties (`tokens.styleFiles` in config), run `node <project>/scripts/tokens.mjs extract`. It writes a 2025.10 draft in `tokens/draft/` with dark and other themes, and `tokens/draft/report.md` for any value it had to type or could not convert exactly. Existing names are a starting point, not a constraint.
4. **Propose, group by group.** Work through the groups in this order, one decision each, so a designer can approve in a sitting:
1. **Colour primitives**: neutral ramp, brand ramp, status hues. Use the audit's clusters to pick values the product already uses (the cluster representative), not new ones.
2. **Colour semantics**: surface, text, border, accent, focus, status, for light and dark. Every semantic token aliases a primitive (`"{color.neutral.900}"`). Mark each pair that must be legible with `$extensions.massimo.contrast: { "on": "<the token it sits on>", "use": "text" }` so contrast is checked in every theme. `use` sets the WCAG 2.2 minimum: `text` 4.5:1, `large-text` 3:1, `ui` and `focus` 3:1.
3. **Type**: families (at most two, per the canon), a size scale of six to eight steps, weights, line heights.
4. **Spacing**: the base unit (usually 4px) and the steps the product actually uses.
5. **Radius, shadow, motion**: three or four steps each.
For each group show a compact table (name → value → what it replaces from the audit) and how it moves the canon numbers ("38 greys → 9 neutrals"). Build the preview so the user sees it, not just reads it: `node <project>/scripts/tokens.mjs preview`, serve the project folder (`serve.mjs`), open `/tokens/preview.html`. Record each approved group with `state.mjs decide`.
5. **Write the token set** in 2025.10, starting from the approved draft: `tokens/base.tokens.json` holds every token's default value, `tokens/theme/<context>.tokens.json` what changes in dark (or another theme), and `tokens/tokens.resolver.json` ties them together; set `tokens.source` to the resolver. The spec is strict: every token has a `$type` (its own or its group's; never guessed), colours are objects (`{ "colorSpace": "oklch", "components": [0.7, 0.1, 200] }`), sizes are `{ "value": 4, "unit": "px" }` in px or rem, durations in ms or s, typography is one object with fontFamily, fontSize, fontWeight, letterSpacing and lineHeight. Aliases are in braces, `$description` goes on every semantic token. A value the spec cannot hold (`clamp()`, a length in em) keeps its exact CSS in `$extensions.massimo.css` beside the nearest valid `$value`. `tokens.mjs check` names every problem with its token path. Keep names semantic for anything components consume (canon → Meaning before value); once the set has semantic tokens that alias its primitives, the audit counts components that read a primitive directly (`primitive-read`), and tidy moves them onto semantic tokens. A set with no aliases at all has no semantic token to read instead, so the audit skips the kind and says why. By default, a colour counts as a primitive only when a token aliases it, so colours that are roles of their own are not flagged.
6. **Choose outputs with the user's stack** in `massimo.config.json` → `tokens.outputs`. Match how the app switches theme today: `darkSelector` (`.dark`, `[data-theme="dark"]`), `darkMedia` (whether dark also follows the system setting), `defaultMode` (the default theme's name, `light` unless the app calls it something else), and `selectors` for any mode whose selector is not the dark one with the name swapped in (`{ "brand": "[data-brand=\"acme\"]" }`):
- plain CSS / CSS modules / any framework → `{ "format": "css", "path": "src/styles/tokens.css" }`
- Tailwind 4 → `css` plus `{ "format": "tailwind4", "path": "src/styles/tokens.theme.css" }`, imported after `@import "tailwindcss"`
- Tailwind 3 → `css` plus `{ "format": "tailwind3", "path": "tokens.tailwind.cjs" }`, spread at the top of the config's `theme.extend` (step 7 says how)
- DaisyUI → `css` plus the theme block mapping DaisyUI's `--color-*` names to the semantic tokens (write it by hand in the theme file; aliases keep it in sync)
- Sass → `scss`; CSS-in-JS → `ts`
- iOS (preview) → `{ "format": "swift", "path": "<a .swift file>", "platform": "ios" }`. detect's `platforms[].suggestedOutputs` has the path: beside the app's catalog, in its Swift package target when it has one. First settle `tokens.mobile.colors` with the user: `catalog` (the default when the app has an asset catalog) keeps the app's catalog as the colour source and the Swift file reads it by name; `tokens` (a monorepo, or a new app) makes the token set the source and adds `{ "format": "xcassets", "path": "<a .xcassets folder>", "platform": "ios" }`, a catalog massimo owns beside it. Ask before setting `tokens.mobile.uikit` (UIColor twins), and map each typography token to an iOS text style in `tokens.mobile.textStyles` (or name it body, caption…): one with none is not written, since its size would not follow Dynamic Type.
- Android (preview) → `{ "format": "compose", "path": "<module>/src/main/kotlin/<package>/DesignTokens.kt", "platform": "android" }` for Compose, and `{ "format": "android-xml", "path": "<module>/src/main/res", "platform": "android" }` for views and resources; the module is the design-system module detect names. `tokens.mobile.package` is the Kotlin package (detect proposes the module's namespace).
- Any mobile output, `tokens.mobile` or `tokens.mobileSources` needs `"minScripts": "0.6.0"` at the top of `massimo.config.json`; init and detect set it, and set it by hand when adding one later.
- For coding agents, add `{ "format": "designmd", "path": "DESIGN.md" }`: Google Labs' DESIGN.md (format version alpha, pinned to release 0.4.0), with the default theme's colours, typography, radii and spacing in its front matter and the components' rules from the graph in its prose. The format has no themes, so the file names the others and says they live in code. Set `name` in `massimo.config.json` for its title (the package name otherwise).
7. **Build and wire.** `node <project>/scripts/tokens.mjs build`. On iOS and Android, the build prints a line per output: `wired` when the project picks the file up by itself (a Swift package target, a Tuist or XcodeGen project, a folder Xcode keeps in sync, a Gradle module), or `wire` with the one step to do by hand once, such as adding the Swift file to the app's target in Xcode for a plain `.xcodeproj` (massimo never edits project files). Do that step with the user, then build the app. It also lists what an output did not carry over and why, and notes such as a family to bundle: go through them with the user. In tokens mode, a colour with high-contrast entries, or entries a token cannot hold (a Display P3 gamut, another idiom, a localized entry), is left in the app's catalog and listed, with any alias of it, and the Swift output reads it from there; that is expected until massimo models them. When the build lists duplicates (colour sets the owned catalog now holds that the app's catalog in the same bundle also has), Xcode warns that each name is used twice: ask the user, then run `node <project>/scripts/tokens.mjs build --dedupe`, which removes them from the app's catalog, and commit that as its own change. When the build refuses a file as changed by hand, or as one with massimo's header that is not on the list, ask the user: put any change worth keeping in the tokens, then delete the file and build again. An android-xml output stops before writing when the module already declares one of its names: rename the token, or, with the user's OK, remove the module's own resource once massimo's declares it. massimo writes only the files `<project>/tokens/mobile-outputs.json` lists and never one it did not write. On the web, import the outputs where the app loads its global CSS or theme config. Add `"ds:tokens": "node <project>/scripts/tokens.mjs build"` to package.json, when the repo has one. Do not yet rewrite components to use the tokens: that is the tidy phase. A set extracted from a style file keeps that file's names, so a `css` output declares the same custom properties as the file's own hand-written `:root` block (and its theme blocks). Whichever is imported last wins, and an edit to the other is silently overridden. Ask the user, then remove those declarations from the style file, so each name is declared once and the token set is its one source. The names stay available, since the output now declares them, so no component loses a variable. Keep the file's other rules. With a `tailwind4` output, the file's own `@theme` block is wired the same way, name by name: `tokens.theme.css` replaces each theme variable it declares, the colour wiring included (`--color-primary: var(--primary)`, which it writes again from the colour token), and a token whose own variable is a Tailwind theme name it has no section for (`--animate-wiggle`, `--tracking-snug`) keeps that name when its value suits the namespace: never a colour outside `--color-*`, and never a number or a length under `--font-*` (a `font.lineHeight.*` token is no font family). Remove from the hand-written `@theme` only the names `tokens.theme.css` declares, and keep every other one: a `--breakpoint-*` or `--container-*` width, which Tailwind reads at build time, and any name the output does not write, or the utility it makes is gone. For a step of Tailwind's own type scale (`text-sm`, `text-2xl`), the output writes the size and its line height only when that is Tailwind's own, never a weight or letter spacing. For any other step a size token already writes (the file's own `--text-display`), it writes only that size and the parts the file sets for it (`--text-display--line-height`), never a typography composite's weight or line height. So each `text-*` class renders as before; a composite writes every part only on a step no size token writes, whose class is new. With a `tailwind3` output, keep the config's `theme.extend` and spread the output at its top: `extend: { ...require('./tokens.tailwind.cjs'), screens: {…} }`, or `import tokens from './tokens.tailwind.cjs'` and `...tokens` in a config written as a module or in TypeScript. The spread is shallow, so a section the config still writes by hand (its own `colors`) replaces the output's whole section: name by name, remove from each hand-written section the keys the output writes, merge what is left into the output's section (`colors: { ...tokens.colors, ...ownColors }`), and drop a section once it is empty. Inside a palette both write, merge shade by shade (`brand: { ...tokens.colors.brand, ...ownBrand }`), since the output may write only some of its shades. Keep every section the output does not write, such as `screens`, `animation`, `keyframes` and `backgroundImage`. A key the config sets in `theme` itself, outside `extend` (a `theme.fontSize` that replaces Tailwind's scale), gives way to the output's key of the same name, so compare those keys too. In a Nuxt app on `@nuxtjs/tailwindcss`, the module loads the app's own `tailwind.config` (from the app's root and from each layer) and any file `tailwindcss.configPath` names, and merges them with the `tailwindcss.config` option in `nuxt.config`, whose keys win over the files': wire the output in the file that holds the theme (the one `configPath` names, when it is set), not in the option, move any theme keys the option sets into that file, and add the `css` output to the `css` list in `nuxt.config`. Unless `styling` names `tailwind4` (an app on `@nuxtjs/tailwindcss` alone often has no `tailwindcss` dependency or `@tailwind` line, so its `styling` may name no Tailwind at all), the output writes each opaque colour written in sRGB (hex, `rgb()`, `hsl()`, `hwb()`) as `rgb(var(--x-rgb) / <alpha-value>)` over channels the `css` output writes, so opacity modifiers (`bg-brand-500/50`, and `@apply` with one) keep working; Tailwind 3.1 or newer reads that placeholder. A translucent colour, one outside sRGB (`oklch()`, `lab()`, `color(display-p3 …)`), one with CSS of its own and one whose `-rgb` name another token already has stay `var()`, which takes no modifier, so check the code's modifiers on those first. Code that reads the config's colours in JavaScript (`resolveConfig`, the module's `exposeConfig`) gets these strings, not hex, and a config function or plugin that reads one with `theme('colors.brand.500')` gets the `<alpha-value>` placeholder as written, which is no colour: in a config function ask for an opacity (`theme('colors.brand.500 / 1')`), and check each such read in a plugin, whose `theme()` takes none, before wiring. CSS's own `theme()` fills the placeholder in. Tailwind 3 follows the rule above for `text-*` too: a step of its own type scale gets its size and Tailwind 3's own line height (or the one a source sets), never a weight or letter spacing, and a step a size token writes gets that size and the parts a source sets for it, which extract keeps from a config's `[size, line-height]` pair as `text.<step>--line-height`. A config that writes one of Tailwind's own steps as a size alone (`xs: '0.7rem'`) replaces Tailwind's pair, so that class sets no line height: extract keeps this as `text.xs--line-height` set to `initial`, and the output writes the step bare. Remove that token to give the step Tailwind 3's own line height. With no colour left in the style files, the audit takes its nearest tokens from the token set instead. If the user wants that file to stay the source, do not add a `css` output: use the mirror (step 3) instead.
8. **Prove nothing broke.** Run the app's build. If the story lane exists, screenshot five of the most-used components' stories before step 7 and after (`shoot.mjs`, then `shoot.mjs --diff`). Wiring tokens should change nothing visible yet; any diff is a wiring mistake (an overridden variable, a changed default) to fix now.
9. **Contrast.** `node <project>/scripts/tokens.mjs check`. List failing pairs against the accessibility bar in `product.md`, and resolve each with the user (adjust the token or accept it with a recorded reason).
10. **Kit.** The build also refreshed `<project>/kit/kit.css`, so ux mockups now use the real tokens. Where pages list the tokens themselves (a Foundations story, a docs page), point them at the inventory instead of a hand-kept list: `node <project>/scripts/tokens.mjs resolved` writes `<project>/tokens/resolved.json` with every custom property per selector, the type classes, the faces and the breakpoints. Set `tokens.inventory` in `massimo.config.json` when it should list more sheets than `tokens.styleFiles`, or name the repo's own layers and families (`<plugin>/reference/project.md` has the shape), and set `"minScripts": "0.3.0"` with it, since older vendored scripts ignore the inventory and would let `resolved.json` fall behind in CI.
11. **End.** `state.mjs set tokens done --note "<n> tokens, <outputs>"`. Next step: tidy.
## Rules
- Values come from the product (audit clusters, extracted variables) before they come from taste.
- Never delete or rename an existing CSS variable in this phase. Keep old names working (alias them to the new tokens) until tidy migrates their consumers.
- The token files are edited by hand or by you; generated files never are. Every generated file says so in its header.
- A designer can veto any value. A developer can veto any wiring. Record both.