design-system-governance/SKILL.md
Enforces token-first, composition-first governance for any design system project. Auto-detects the project's token naming conventions, grid system, animation keyframes, and shared component library before applying rules. Use when building UI components, composite layouts, pages, design tokens, or Storybook stories — or when the user mentions design tokens, hardcoded styles, component reuse, animations, i18n text, or design system governance.
npx skillsauth add harrychuang/cursor-skills design-system-governanceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Before any implementation, scan the project to establish:
| Convention | Where to look | What to find |
|---|---|---|
| Token naming | src/styles/, *.css, *.scss, tokens/ | prefix for ref / sys / comp layers (e.g. md-ref-, sd-sys-); verify names follow Token Layer Rules (ref = primitives only; sys = shared semantics; comp = component/region slots) |
| Token layer structure | Token files | Are there 3 layers (ref → sys → comp) or 2 (primitive → semantic)? |
| Grid / layout system | CSS, HTML templates | Class prefix for page grid, cell spans, color variants |
| Animation keyframes | CSS files | Keyframe name prefix, motion token names |
| Shared components | src/components/, Storybook | List of available shared components |
| i18n source | src/, locales/, i18n.json | Path to display text source file |
Record findings before proceeding. If the project has no token system, stop and ask the user whether to establish one first.
ref → sys → comp (or project equivalent).Stop immediately when:
Required response:
Stop immediately when:
Required response:
Use these exact prompts (adapt layer names to the discovered project convention):
找不到對應的 design token(sys/comp 層)。是否要先建立這組 token,再繼續元件開發?目前既有元件無法完整組裝此組件。是否要先建立新的共用子元件,再繼續?Apply all ten when writing or reviewing UI:
on-* foreground token. Never assume white or black text.#hex, rgb, hsl) in component code — always use tokens.ms values or cubic-bezier literals — always use discovered motion tokens.Apply using discovered project prefixes. Each layer has distinct naming responsibility: ref names describe raw values or scale steps; sys names describe shared, reusable semantics; comp names describe component- or region-specific slots.
| Layer | Role | Naming pattern (required) |
|---|---|---|
| ref | Raw values only (palette, spacing scale, radius, type scale, elevation) | Primitive / intuitive only. Names must read as the value or palette step (e.g. *-ref-size-12 → 12px, *-ref-color-red-50 → a red step). Must not encode component names, layout regions, or one-off UI chrome. |
| sys | Semantic roles mapped from ref (color roles, spacing roles, motion roles) | Shared, product-wide semantics. Role-based names any component might use. Must not name a specific component structure (no button, input, card, bottom-bar, etc.). |
| comp | Component-facing slots referencing sys only | Component vocabulary allowed (button, input, card, bottom-bar, …). This is the only layer for names tied to a particular component or composite. |
*-ref-size-12, *-ref-color-red-50, *-ref-space-4, *-ref-radius-sm (adapt prefix to the project).*-ref-spacing-bottom-bar-padding, *-ref-color-header-icon. Those concerns belong in sys (shared semantic) and/or comp (component slot), not ref.*-sys-color-surface, *-sys-space-inline-md, *-sys-color-action-primary (if “action primary” is a global semantic role).*-sys-button-padding-y, *-sys-card-header-gap). Push those to comp; keep sys vocabulary generic.*-comp-button-padding-y, *-comp-bottom-bar-padding, *-comp-card-gap — names may reference the component or layout region.animation-delay phase offset across multiple elements — never identical timings.translateY), scale, or focus-fade.on-* foreground tokens.For every changed component, include stories covering:
Default — base appearance.Hover — if the component has interactive hover state.FocusVisible — keyboard focus ring.Disabled — if the component supports disabled state.For composite components, include a composition story showing assembly from existing shared components.
When proceeding after user approval, always report:
development
Build or update token-backed Storybook foundations, shared UI components, and stories from an extracted design-system package. Use after design-system-extractor, or when Codex must read design-system Markdown and token files, automatically trace original design sources such as Figma URLs/nodes, UI images, rendered routes, and frontend folders, infer component dependency order so core primitives are built before composed components, map component specs into a product repo, create or update Storybook docs, plan component batches, and verify implementation with the bundled Figma export addon without bypassing tokens.
development
Extract a reusable design-system specification from UI screenshots/images, Figma URLs or exports, Figma Variables, existing app/project folders, or prototype code. Use when Codex must produce evidence-backed design principles, design elements, token architecture, component inventory, component token specs, anti-AI style constraints, static HTML documentation for developers, cross-agent handoff guidance for Claude Code/Cursor/Codex, and a checkpoint before any product implementation.
development
Create, apply, audit, and understand Variables in Figma using Google Material Design's three-tier token inheritance (Ref → Sys → Comp). Use when: creating Variables for components or screens, applying existing Variables to nodes, auditing token naming and structure for compliance, or having AI read existing Variables to reverse-engineer design components. Triggers: create Variables, apply Variables, Figma variables, M3 token, design token, token inheritance, token audit, audit variables, design component from variables, three-tier token.
tools
Turn screenshots or Figma exports into token-backed Storybook components and composed product screens.