Figma extract tokens

From TheBushidoCollective/han · View interactive version

Figma extract tokens is an AI agent skill from the GitHub repository TheBushidoCollective/han. Extract design tokens and variables from a Figma file to create or update a design system

How to use this skill

Skill file

Extract Design Tokens from Figma

Name

figma:figma-extract-tokens - Extract design tokens and variables from Figma files

Synopsis

Extract design tokens (colors, spacing, typography, etc.) from Figma files and generate token files in various formats (CSS Custom Properties, TypeScript, JSON, Style Dictionary, Tailwind config).

Description

You are tasked with extracting design tokens and variables from a Figma file using the Figma MCP server. This command analyzes Figma variables and variable collections to generate structured token files for your design system.

Implementation

Connects to the Figma Desktop MCP server to access Figma variables API. Extracts all variable types (colors, numbers, strings, booleans) and organizes them into primitive and semantic token hierarchies. Supports multiple output formats and theming variations.

Your Task

  1. Access the Figma File:
  1. Extract Variables:
  1. Analyze Token Structure:
  1. Generate Token Files:
  1. Provide Documentation:

Output Formats

CSS Custom Properties

/**
 * Design Tokens - Extracted from Figma
 * File: [Figma file name]
 * Generated: [date]
 */

:root {
  /* Colors - Primitives */
  --color-blue-500: #3b82f6;
  --color-gray-900: #111827;

  /* Colors - Semantic */
  --color-primary: var(--color-blue-500);
  --color-text: var(--color-gray-900);

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;

  /* Typography */
  --font-family-base: 'Inter', sans-serif;
  --font-size-body: 1rem;
  --line-height-body: 1.5;
}

TypeScript/JavaScript

/**
 * Design Tokens - Extracted from Figma
 * File: [Figma file name]
 * Generated: [date]
 */

export const tokens = {
  colors: {
    primitives: {
      blue500: '#3b82f6',
      gray900: '#111827',
    },
    semantic: {
      primary: '#3b82f6',
      text: '#111827',
    },
  },
  spacing: {
    xs: '0.25rem',
    sm: '0.5rem',
    md: '1rem',
  },
  typography: {
    fontFamily: {
      base: "'Inter', sans-serif",
    },
    fontSize: {
      body: '1rem',
    },
    lineHeight: {
      body: 1.5,
    },
  },
} as const;

export type Tokens = typeof tokens;

Style Dictionary Format

{
  "color": {
    "primitive": {
      "blue": {
        "500": { "value": "#3b82f6" }
      },
      "gray": {
        "900": { "value": "#111827" }
      }
    },
    "semantic": {
      "primary": { "value": "{color.primitive.blue.500}" },
      "text": { "value": "{color.primitive.gray.900}" }
    }
  },
  "spacing": {
    "xs": { "value": "0.25rem" },
    "sm": { "value": "0.5rem" },
    "md": { "value": "1rem" }
  }
}

Best Practices

  1. Token Naming:
  1. Token Organization:
  1. Token Values:
  1. Maintenance:

Additional Deliverables

After extracting tokens, also provide:

  1. Token Documentation:
  1. Integration Guide:
  1. Validation:

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.