.wrangler/memory/knowledge-base/reference-prompts/skills/ui-related-skills/figma-variables-generator/SKILL.md
Generate JSON files for creating Figma variable collections from text descriptions or design token data. Use when designers need to create or convert design tokens (colors, spacing, typography, etc.) into Figma variables format. Supports multiple modes (Light/Dark), code syntax definitions, variable references/aliases, and hierarchical organization. Triggers include requests to "create Figma variables", "generate variables JSON", "convert design tokens", or working with design system tokens.
npx skillsauth add bacchus-labs/wrangler figma-variables-generatorInstall 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.
Generate properly formatted JSON files for creating Figma variable collections from text descriptions, existing design token data, or images showing design systems.
This skill helps designers create Figma variable collections by generating the JSON format required by Figma variable import/export plugins. The output can be directly imported into Figma using plugins like "Variables Import Export" or similar tools.
Figma supports only 4 core variable types:
$type: "color") - RGB hex values, rgba, or variable references$type: "number") - Numeric values (spacing, sizes, radius, weights, etc.)$type: "string") - Text values (font families, names, etc.)$type: "boolean") - True/false valuesImportant: Types like spacing, borderRadius, fontSize, fontWeight should use number type. Use semantic naming in your variable paths to indicate their purpose (e.g., spacing.xs, radius.md, fontSize.body)
{collection.subcategory.variableName} syntax to reference other variablesCRITICAL: When the user asks to update, add to, or reformat an existing JSON file, you MUST:
Example Scenario:
{"Spacing": {"space": {"sm": {"$type": "number", "$value": 8}}}}{"Spacing": {"space": {"sm": {...}, "md": {...}}}}{"Spacing": {"spacing": {"md": {...}}}} (creates duplicate category)Before generating the JSON, ask the user:
Create a JSON file following this structure:
When generating or reformatting JSON, follow these ordering principles for maximum human readability:
1. Property Order within Each Variable:
{
"variableName": {
"$type": "color", // 1. Type first
"$value": "#ffffff", // 2. Value second
"$description": "...", // 3. Description (if present)
"$extensions": {...} // 4. Extensions last
}
}
2. Variable Ordering within Categories:
3. Category Ordering: Order categories logically:
4. Indentation and Formatting:
Example of Well-Ordered JSON:
{
"Design System": {
"primitives": {
"gray": {
"100": {"$type": "color", "$value": "#f7f7f7"},
"200": {"$type": "color", "$value": "#e1e1e1"},
"300": {"$type": "color", "$value": "#cfcfcf"}
}
},
"semantic": {
"text": {
"primary": {"$type": "color", "$value": "{Design System.primitives.gray.300}"},
"secondary": {"$type": "color", "$value": "{Design System.primitives.gray.200}"}
}
},
"spacing": {
"xs": {"$type": "number", "$value": 4},
"sm": {"$type": "number", "$value": 8},
"md": {"$type": "number", "$value": 16},
"lg": {"$type": "number", "$value": 24},
"xl": {"$type": "number", "$value": 32}
}
}
}
Create a JSON file following this structure:
{
"Collection Name": {
"category": {
"subcategory": {
"variableName": {
"$type": "color",
"$value": {
"Light": "#ffffff",
"Dark": "#000000"
},
"$extensions": {
"codeSyntax": {
"WEB": "categorySubcategoryVariableName"
}
}
}
}
}
}
}
When code syntax is requested:
camelCase (default for WEB):
foreground.base → foregroundBasebackground.interactive.primary → backgroundInteractivePrimarysnake_case (common for Python, some backend systems):
foreground.base → foreground_basebackground.interactive.primary → background_interactive_primarykebab-case (common for CSS):
foreground.base → foreground-basebackground.interactive.primary → background-interactive-primaryPascalCase (common for some component systems):
foreground.base → ForegroundBasebackground.interactive.primary → BackgroundInteractivePrimaryCRITICAL: Figma only works with pixel values. Always convert relative units to pixels:
Common Conversions (assuming 16px base font size):
1rem → 16 (pixels)2rem → 32 (pixels)0.875rem → 14 (pixels)1em → 16 (pixels, context-dependent)1.5em → 24 (pixels, context-dependent)Percentage/Viewport Units (ask user for context if needed):
100% → ask for parent container size50vw → ask for viewport width or use common breakpoint10vh → ask for viewport height or use common breakpointOther Units:
1pt → 1.333 (pixels)1pc → 16 (pixels, 1 pica = 12 points)When encountering unit-based values, automatically convert to pixels without units in the JSON output.
Example:
font-size: 1.5rem → Output: "$value": 24spacing: 2rem → Output: "$value": 32line-height: 1.5em → Output: "$value": 24For variables that reference other variables (aliases), use the reference syntax:
{
"Semantic Colors": {
"text": {
"primary": {
"$type": "color",
"$value": {
"Light": "{Color Primitives.gray.gray900}",
"Dark": "{Color Primitives.gray.gray100}"
}
}
}
}
}
The reference format is: {CollectionName.category.subcategory.variableName}
Input: "Create a collection called 'Brand Colors' with primary (#389fba), secondary (#c9a0dc), and white (#ffffff) colors for light and dark modes"
Output:
{
"Brand Colors": {
"primary": {
"$type": "color",
"$value": {
"Light": "#389fba",
"Dark": "#389fba"
}
},
"secondary": {
"$type": "color",
"$value": {
"Light": "#c9a0dc",
"Dark": "#c9a0dc"
}
},
"white": {
"$type": "color",
"$value": {
"Light": "#ffffff",
"Dark": "#ffffff"
}
}
}
}
Input: "Create a spacing scale collection with values 0, 8, 16, 24, 32px. Use camelCase for web."
Output:
{
"Spacing": {
"space": {
"0": {
"$type": "number",
"$value": 0,
"$extensions": {
"codeSyntax": {
"WEB": "space0"
}
}
},
"1": {
"$type": "number",
"$value": 8,
"$extensions": {
"codeSyntax": {
"WEB": "space1"
}
}
},
"2": {
"$type": "number",
"$value": 16,
"$extensions": {
"codeSyntax": {
"WEB": "space2"
}
}
},
"3": {
"$type": "number",
"$value": 24,
"$extensions": {
"codeSyntax": {
"WEB": "space3"
}
}
},
"4": {
"$type": "number",
"$value": 32,
"$extensions": {
"codeSyntax": {
"WEB": "space4"
}
}
}
}
}
}
Input: "Create typography tokens: body is 1rem, heading-sm is 1.25rem, heading-md is 1.5rem, heading-lg is 2rem"
Output:
{
"Typography": {
"fontSize": {
"body": {
"$type": "number",
"$value": 16,
"$extensions": {
"codeSyntax": {
"WEB": "fontSizeBody"
}
}
},
"headingSm": {
"$type": "number",
"$value": 20,
"$extensions": {
"codeSyntax": {
"WEB": "fontSizeHeadingSm"
}
}
},
"headingMd": {
"$type": "number",
"$value": 24,
"$extensions": {
"codeSyntax": {
"WEB": "fontSizeHeadingMd"
}
}
},
"headingLg": {
"$type": "number",
"$value": 32,
"$extensions": {
"codeSyntax": {
"WEB": "fontSizeHeadingLg"
}
}
}
}
}
}
Input: "Create semantic colors that reference primitives. Text primary should use gray900 in light mode and gray100 in dark mode."
Output:
{
"Semantic Colors": {
"text": {
"primary": {
"$type": "color",
"$value": {
"Light": "{Primitives.gray.gray900}",
"Dark": "{Primitives.gray.gray100}"
},
"$extensions": {
"codeSyntax": {
"WEB": "textPrimary"
}
}
}
}
}
}
Existing JSON:
{
"Spacing": {
"space": {
"xs": {
"$type": "number",
"$value": 4
},
"sm": {
"$type": "number",
"$value": 8
}
}
}
}
User Request: "Add medium (16px) and large (24px) spacing values"
Correct Output (preserves naming and structure):
{
"Spacing": {
"space": {
"xs": {
"$type": "number",
"$value": 4
},
"sm": {
"$type": "number",
"$value": 8
},
"md": {
"$type": "number",
"$value": 16
},
"lg": {
"$type": "number",
"$value": 24
}
}
}
}
❌ Incorrect Output (would create duplicates in Figma):
{
"Spacing": {
"spacing": {
"md": {
"$type": "number",
"$value": 16
},
"lg": {
"$type": "number",
"$value": 24
}
}
}
}
This is wrong because the category name changed from "space" to "spacing", which would create a separate category in Figma instead of adding to the existing one.
Messy Input (from plugin, poorly ordered):
{
"Colors": {
"button": {
"hover": {"$value": "#2563eb", "$type": "color"},
"default": {"$value": "#3b82f6", "$type": "color"},
"pressed": {"$value": "#1d4ed8", "$type": "color"}
},
"text": {
"tertiary": {"$value": "#9ca3af", "$type": "color"},
"primary": {"$value": "#111827", "$type": "color"},
"secondary": {"$value": "#6b7280", "$type": "color"}
},
"gray": {
"900": {"$value": "#111827", "$type": "color"},
"500": {"$value": "#6b7280", "$type": "color"},
"100": {"$value": "#f3f4f6", "$type": "color"}
}
}
}
Reformatted Output (properly ordered for readability):
{
"Colors": {
"gray": {
"100": {
"$type": "color",
"$value": "#f3f4f6"
},
"500": {
"$type": "color",
"$value": "#6b7280"
},
"900": {
"$type": "color",
"$value": "#111827"
}
},
"text": {
"primary": {
"$type": "color",
"$value": "#111827"
},
"secondary": {
"$type": "color",
"$value": "#6b7280"
},
"tertiary": {
"$type": "color",
"$value": "#9ca3af"
}
},
"button": {
"default": {
"$type": "color",
"$value": "#3b82f6"
},
"hover": {
"$type": "color",
"$value": "#2563eb"
},
"pressed": {
"$type": "color",
"$value": "#1d4ed8"
}
}
}
}
Improvements Made:
$type before $valueUpdating Existing Collections: When adding to or updating an existing JSON file:
{"Spacing": {"space": {...}}}, adding new values must use "space" not "spacing" or "spaces"Only 4 Variable Types: Figma's variable system only supports color, number, string, and boolean. DO NOT use types like spacing, borderRadius, fontSize, or fontWeight - these are invalid and will cause import errors. Instead:
number for spacing, radius, font sizes, weights, dimensionsstring for font families and text valuesspacing.sm, fontSize.body, radius.lg)Pixel Values Only: Figma only accepts pixel values for numeric types. Always convert rem, em, %, vw, vh, pt, and other units to pixels:
Single Mode Collections: If only one mode is needed, omit the mode structure and use direct values:
{
"Collection": {
"variable": {
"$type": "color",
"$value": "#ffffff"
}
}
}
Code Syntax is Optional: Only include $extensions.codeSyntax when explicitly requested by the user
Consistent Hierarchy: Maintain consistent depth in variable paths (e.g., all variables at same nesting level within a category)
Valid Color Formats:
#ffffff, #fff{r: 1, g: 1, b: 1} (values 0-1)rgba(255, 255, 255, 0.5){collection.path.to.variable}File Naming: Use descriptive names like brand-colors.json, spacing-tokens.json, semantic-colors.json
Reformatting Plugin-Generated JSON: When a user provides JSON from a plugin that's hard to read:
$type → $value → $description → $extensionsCreate two collections: one for primitives (base colors, raw values) and one for semantic tokens (purpose-based references).
When supporting multiple platforms, include all in the same variable:
{
"$extensions": {
"codeSyntax": {
"WEB": "backgroundPrimary",
"iOS": "backgroundColor.primary",
"ANDROID": "background_color_primary"
}
}
}
For design systems with deep organization:
{
"Design System": {
"component": {
"button": {
"background": {
"primary": {
"default": { ... },
"hover": { ... },
"pressed": { ... }
}
}
}
}
}
}
Always create the JSON file and provide it to the user in /mnt/user-data/outputs/ with a clear, descriptive filename. Include a brief summary of what was generated and how to import it into Figma.
tools
Use when creating technical specifications for features, systems, or architectural designs. Creates comprehensive specification documents using the Wrangler MCP issue management system with proper structure and completeness checks.
testing
Creates and refines agent skills using TDD methodology with pressure testing and rationalization detection. Use when creating new skills, editing existing skills, testing skills with pressure scenarios, or verifying skills work before deployment.
tools
Use when design is complete and you need detailed implementation tasks - creates tracked MCP issues with exact file paths, complete code examples, and verification steps. Optional reference plan file for architecture overview.
development
Validates governance file completeness, format compliance, and metric accuracy. Use when auditing governance health, after bulk changes, or ensuring documentation integrity.