figma-m3-variables/SKILL.md
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.
npx skillsauth add harrychuang/cursor-skills figma-m3-variablesInstall 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.
Complete workflow for managing Variables in Figma using Google Material Design 3 three-tier inheritance (Ref → Sys → Comp).
MANDATORY prerequisite: Read the figma-use skill before any use_figma call.
Always pass skillNames: "figma-m3-variables" to every use_figma call.
use_figma to confirm current state, then proceed with writes.var(--{prefix}-{layer}-{name}), e.g. var(--md-sys-color-primary).return all affected variable IDs and node IDs.use_figma calls are strictly sequential — Never run two use_figma calls in parallel.Three layers have different naming jobs. When creating, applying, or auditing Variables, enforce this split:
| Layer | Role | Naming rule |
|-------|------|-------------|
| Reference (ref) | Raw values only (hex, px, weight). | Primitive, scale, or value — a name must read as “what number or swatch is this?” with no component, screen, or layout region. |
| System (sys) | Product-wide semantics shared by many components. | Shared, semantic — roles like primary, error, inset, gap — no names tied to one component’s structure or anatomy. |
| Component (comp) | Bind real UI to Sys. | Component and structure — button, input, card, bottom-bar, container/padding-horizontal, etc. |
Reference — intuitive value naming (good)
ref/color/red/50, ref/palette/primary/40 — the name reflects the color scale, not where it is used.ref/size/12 → 12px, ref/spacing/16 → 16 — not roles like “bottom bar” or “button”.ref/radius/12, ref/type/size/14 — still primitive.Reference — forbidden
button, input, card, fab, chip, dialog).bottom-bar, top-app-bar, navigation-bar, sheet).ref/spacing/bottom-bar/padding or ref/spacing/button/padding-h — those belong in Comp (and may alias Sys generic spacing).System — good
sys/color/primary, sys/color/on-primary, sys/spacing/inset-horizontal-md, sys/spacing/gap-inline-sm, sys/shape/corner-full.System — forbidden
sys/spacing/button-padding-h, sys/color/top-app-bar-surface, sys/size/navigation-bar-height — push the component name to Comp; keep Sys generic (e.g. inset-horizontal-md, surface-container).Component — where structure lives
comp/filled-button/..., comp/text-field/..., comp/navigation-bar/..., container/padding-horizontal, with-icon/icon-label-gap, etc. Comp tokens alias Sys (and Sys aliases Ref).Detailed naming patterns, WEB examples, and the Filled Button walkthrough with corrected Ref/Sys names are in references/token-spec.md §1 and §4.
Trigger: User provides a Figma URL + node-id and requests Variables to be applied.
Inspect — List all variable collections and variables in the file:
const cols = await figma.variables.getLocalVariableCollectionsAsync();
const result = [];
for (const c of cols) {
const vars = [];
for (const id of c.variableIds) {
const v = await figma.variables.getVariableByIdAsync(id);
if (v) vars.push({ name: v.name, id: v.id, type: v.resolvedType, scopes: v.scopes });
}
result.push({ collection: c.name, id: c.id, modes: c.modes.map(m => m.name), variables: vars });
}
return result;
Evaluate:
Match component requirements — Based on the component type (Button, Card, etc.), find the corresponding tokens from the Comp layer, list the proposed bindings, and present them to the user for confirmation.
Bind — Execute:
figma.variables.setBoundVariableForPaint(paint, "color", variable) → assign the resulting paint back to the nodenode.setBoundVariable("topLeftRadius", variable) × all 4 cornersnode.setBoundVariable("paddingLeft" | "paddingRight" | "paddingTop" | "paddingBottom", variable)node.setBoundVariable("itemSpacing", variable)setBoundVariableForPaint on the text node's fills)Validate — Call get_screenshot to confirm visual correctness.
Trigger: No M3 three-tier Variables found in the file, or user explicitly requests creation.
Discover design guidelines — Run the same discovery check as Workflow D Step 1.
Ask for prefix — Use AskQuestion to let the user choose (e.g. md, dd, bd, or custom).
Ask for Collection structure — Use AskQuestion:
{Prefix} · Reference, {Prefix} · System, {Prefix} · Component · {ElementName}Inspect — Confirm there are no duplicate collection names in the current file.
Create Variables — Follow the token list in token-spec.md, using values informed by the design guidelines gathered in Step 1:
[] (hidden, not shown in picker)VARIABLE_ALIAS) pointing to Ref; scope set by roleBind — Once Variables are created, run Workflow A Step 4 to bind them to target nodes.
Validate — Call get_screenshot to confirm visual correctness, and report the variable counts for each of the three-tier collections.
Ref layer variables must not appear in the designer's picker. Their scope must be set to [] (empty array).
Trigger: User requests a check, audit, or asks "is the naming correct?".
Inspect — Read all collections, variables, scopes, code syntax, and valuesByMode.
Apply audit-rules.md — Check each violation type (including Ref/Sys naming in §7) and compile a list of issues.
Report — Present as a table or list:
Ask whether to fix — After presenting the issues, use AskQuestion: "Do you want to automatically fix the above issues?" If the user agrees, execute fix scripts for each item.
Validate after fix — Inspect again to confirm zero violations remain.
Trigger: User wants the AI to understand existing tokens and use them to create or update components.
Discover design guidelines — Before doing anything else, inspect the file for an existing design system or style guide. Run the following script:
const pages = figma.root.children.map(p => p.name);
const paintStyles = await figma.getLocalPaintStylesAsync();
const textStyles = await figma.getLocalTextStylesAsync();
const effectStyles = await figma.getLocalEffectStylesAsync();
const components = figma.root.findAllWithCriteria({ types: ['COMPONENT', 'COMPONENT_SET'] });
return {
pages,
paintStyleCount: paintStyles.length,
textStyleCount: textStyles.length,
effectStyleCount: effectStyles.length,
componentCount: components.length,
paintStyles: paintStyles.map(s => ({ name: s.name, description: s.description })),
textStyles: textStyles.map(s => ({ name: s.name, fontSize: s.fontSize, fontName: s.fontName })),
};
Evaluate the result and branch:
Path A — Design guidelines exist (paint styles ≥ 3 OR text styles ≥ 2 OR components ≥ 5, OR a page name contains "guideline / style / brand / design system / foundation / principle"):
Path B — No design guidelines found (counts are all low and no guideline page exists):
Inspect variables — List all variables, analyze the three-tier structure and token semantics (primary, on-primary, container-shape, etc.).
Understand semantic mapping:
**/color/primary or **/container/background-color → component background**/color/on-primary or **/label-text/color → component foreground text**/shape/** or **/container/shape → corner radius**/padding-horizontal / **/padding-vertical → padding**/spacing/** or **/gap → gapIdentify variants and states — Before building, analyze the component type and propose which variants and interaction states are applicable. Use AskQuestion (multi-select) to let the user choose:
Variants (structural differences — become Component Set properties):
Size (Small / Medium / Large), Style (Filled / Outlined / Text), Leading icon (True / False)Interaction states (visual overrides — become additional Component Set properties or separate frames):
DefaultHovered — container color lightens/darkens by state layer opacityFocused — typically adds a focus ring or outlinePressed — deeper state layer overlayDisabled — reduced opacity or dedicated disabled tokensError — replaces primary color tokens with error tokensSuccess — replaces primary color tokens with success/positive tokensPresent the proposed list and ask: "Which variants and states would you like to include?"
Plan state tokens — For each selected state, determine whether existing Comp tokens cover it or new state-specific tokens are needed:
…/container/background-color/hovered → reuse themBuild the component — Based on the token mappings, confirmed design guidelines, and selected variants/states:
Default state (no variants) → create a single Frame / Component and bind variables using Workflow A Step 4figma-generate-library skill for Component Set structureState=Hovered, Size=MediumValidate — Call get_screenshot to confirm the component looks correct, token colors resolve properly, and all selected states are visually distinct.
| Skill | Responsibility |
|-------|----------------|
| figma-use | Underlying Plugin API rules (colors 0–1, return, page switching, etc.) — must be read first |
| figma-m3-variables (this skill) | Creating, applying, auditing, and reverse-engineering M3 Variables in Figma |
| design-system-governance | Code-side token governance (CSS/SCSS tokens) — complements this skill |
| figma-generate-library | Full multi-phase design system build; refer to its Phase 3 when Workflow D involves component creation |
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.
tools
Turn screenshots or Figma exports into token-backed Storybook components and composed product screens.
tools
Turn screenshots or Figma exports into token-backed Storybook components and composed product screens.
development
Bootstrap a full frontend delivery workspace from UI screenshots or a Figma URL, then carry the implementation through Storybook-first, token-first development and visual parity. Use when the user wants to start a new product build from reference images, a Figma design, or both.