figma-generate-library

figma/mcp-server-guide · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/figma/mcp-server-guide --skill figma-generate-library
0 commentsdiscussion
summary

Build professional-grade design systems in Figma that match code. This skill orchestrates multi-phase workflows across 20–100+ use_figma calls, enforcing quality patterns from real-world design systems (Material 3, Polaris, Figma UI3, Simple DS).

skill.md

Design System Builder — Figma MCP Skill

Build professional-grade design systems in Figma that match code. This skill orchestrates multi-phase workflows across 20–100+ use_figma calls, enforcing quality patterns from real-world design systems (Material 3, Polaris, Figma UI3, Simple DS).

Prerequisites: The figma-use skill MUST also be loaded for every use_figma call. It provides Plugin API syntax rules (return pattern, page reset, ID return, font loading, color range). This skill provides design system domain knowledge and workflow orchestration.

Always pass skillNames: "figma-generate-library" when calling use_figma as part of this skill. This is a logging parameter — it does not affect execution.


1. The One Rule That Matters Most

This is NEVER a one-shot task. Building a design system requires 20–100+ use_figma calls across multiple phases, with mandatory user checkpoints between them. Any attempt to create everything in one call WILL produce broken, incomplete, or unrecoverable results. Break every operation to the smallest useful unit, validate, get feedback, proceed.


2. Mandatory Workflow

Every design system build follows this phase order. Skipping or reordering phases causes structural failures that are expensive to undo.

Phase 0: DISCOVERY (always first — no use_figma writes yet)
  0a. Analyze codebase → extract tokens, components, naming conventions
  0b. Inspect Figma file → pages, variables, components, styles, existing conventions
  0c. Search subscribed libraries → use search_design_system for reusable assets
  0d. Lock v1 scope → agree on exact token set + component list before any creation
  0e. Map code → Figma → resolve conflicts (code and Figma disagree = ask user)
  ✋ USER CHECKPOINT: present full plan, await explicit approval

Phase 1: FOUNDATIONS (tokens first — always before components)
  1a. Create variable collections and modes
  1b. Create primitive variables (raw values, 1 mode)
  1c. Create semantic variables (aliased to primitives, mode-aware)
  1d. Set scopes on ALL variables
  1e. Set code syntax on ALL variables
  1f. Create effect styles (shadows) and text styles (typography)
  → Exit criteria: every token from the agreed plan exists, all scopes set, all code syntax set
  ✋ USER CHECKPOINT: show variable summary, await approval

Phase 2: FILE STRUCTURE (before components)
  2a. Create page skeleton: Cover → Getting Started → Foundations → --- → Components → --- → Utilities
  2b. Create foundations documentation pages (color swatches, type specimens, spacing bars)
  → Exit criteria: all planned pages exist, foundations docs are navigable
  ✋ USER CHECKPOINT: show page list + screenshot, await approval

Phase 3: COMPONENTS (one at a time — never batch)
  For EACH component (in dependency order: atoms before molecules):
    3a. Create dedicated page
    3b. Build base component with auto-layout + full variable bindings
    3c. Create all variant combinations (combineAsVariants + grid layout)
    3d. Add component properties (TEXT, BOOLEAN, INSTANCE_SWAP)
    3e. Link properties to child nodes
    3f. Add page documentation (title, description, usage notes)
    3g. Validate: get_metadata (structure) + get_screenshot (visual)
    3h. Optional: lightweight Code Connect mapping while context is fresh
    → Exit criteria: variant count correct, all bindings verified, screenshot looks right
    ✋ USER CHECKPOINT per component: show screenshot, await approval before next component

Phase 4: INTEGRATION + QA (final pass)
  4a. Finalize all Code Connect mappings
  4b. Accessibility audit (contrast, min touch targets, focus visibility)
  4c. Naming audit (no duplicates, no unnamed nodes, consistent casing)
  4d. Unresolved bindings audit (no hardcoded fills/strokes remaining)
  4e. Final review screenshots of every page
  ✋ USER CHECKPOINT: complete sign-off

3. Critical Rules

Plugin API basics (from use_figma skill — enforced here too):

  • Use return to send data back (auto-serialized). Do NOT wrap in IIFE or call closePlugin.
  • Return ALL created/mutated node IDs in every return value
  • Page context resets each call — always await figma.setCurrentPageAsync(page) at start
  • figma.notify() throws — never use it
  • Colors are 0–1 range, not 0–255
  • Font MUST be loaded before any text write: await figma.loadFontAsync({family, style}). Use await figma.listAvailableFontsAsync() to discover available fonts and verify exact style strings — if a load fails, query available fonts to find the correct name or a fallback.

Design system rules:

  1. Variables BEFORE components — components bind to variables. No token = no component.
  2. Inspect before creating — run read-only use_figma to discover existing conventions. Match them.
  3. One page per component (default) — exception: tightly related families (e.g., Input + helpers) may share a page with clear section separation.
  4. Bind visual properties to variables (default) — fills, strokes, padding, radius, gap. Exceptions: intentionally fixed geometry (icon pixel-grid sizes, static dividers).
  5. Scopes on every variable — NEVER leave as ALL_SCOPES. Background: FRAME_FILL, SHAPE_FILL. Text: TEXT_FILL. Border: STROKE_COLOR. Spacing: GAP. Radii: CORNER_RADIUS. Primitives: [] (hidden).
  6. Code syntax on every variable — WEB syntax MUST use the var() wrapper: var(--color-bg-primary), not --color-bg-primary. Use the actual CSS variable name from the codebase. ANDROID/iOS do NOT use a wrapper.
  7. Alias semantics to primitives{ type: 'VARIABLE_ALIAS', id: primitiveVar.id }. Never duplicate raw values in semantic layer.
  8. Position variants after combineAsVariants — they stack at (0,0). Manually grid-layout + resize.
  9. INSTANCE_SWAP for icons — never create a variant per icon. Cap variant matrices: if Size × Style × State > 30 combinations, split into sub-component.
  10. Deterministic naming — use consistent, unique node names for idempotent cleanup and resumability. Track created node IDs via return values and the state ledger.
  11. No destructive cleanup — cleanup scripts identify nodes by name convention or returned IDs, not by guessing.
  12. Validate before proceeding — never build on unvalidated work. get_metadata after every create, get_screenshot after each component.
  13. NEVER parallelize use_figma calls — Figma state mutations must be strictly sequential. Even if your tool supports parallel calls, never run two use_figma calls simultaneously.
  14. Never hallucinate Node IDs — always read IDs from the state ledger returned by previous calls. Never reconstruct or guess an ID from memory.
  15. Use the helper scripts — embed scripts from scripts/ into your use_figma calls. Don't write 200-line inline scripts from scratch.
  16. Explicit phase approval — at each checkpoint, name the next phase explicitly. "looks good" is not approval to proceed to Phase 3 if you asked about Phase 1.

4. State Management (Required for Long Workflows)

getPluginData() / setPluginData() are NOT supported in use_figma. Use getSharedPluginData() / setSharedPluginData() instead (these ARE supported), or use name-based lookups and the state ledger (returned IDs).

Entity type Idempotency key How to check existence
Scene nodes (pages, frames, components) setSharedPluginData('dsb', 'key', value) or unique name node.getSharedPluginData('dsb', 'key') or page.findOne(n => n.name === 'Button')
Variables Name within collection (await figma.variables.getLocalVariablesAsync()).find(v => v.name === name && v.variableCollectionId === collId)
Styles Name getLocalTextStyles().find(s => s.name === name)

Tag every created scene node immediately after creation:

node.setSharedPluginData('dsb', 'run_id', RUN_ID);        // identifies this build run
node.setSharedPluginData('dsb', 'phase', 'phase3');        // which phase created it
node.setSharedPluginData('dsb', 'key', 'component/button');// unique logical key

State persistence: Do NOT rely solely on conversation context for the state ledger. Write it to disk:

/tmp/dsb-state-{RUN_ID}.json

Re-read this file at the start of every turn. In long workflows, conversation context will be truncated — the file is the source of truth.

Maintain a state ledger tracking:

{
  "runId": "ds-build-2024-001",
  "phase": "phase3",
  "step": "component-button",
  "entities": {
    "collections": { "primitives": "id:...", "color": "id:..." },
    "variables": { "color/bg/primary": "id:...", "spacing/sm": "id:..." },
    "pages": { "Cover": "id:...", "Button": "id:..." },
    "components": { "Button": "id:..." }
  },
  "pendingValidations": ["Button:screenshot"],
  "completedSteps": ["phase0", "phase1", "phase2", "component-avatar"]
}

Idempotency check before every create: query by name + state ledger ID. If exists, skip or update — never duplicate.

Resume protocol: at session start or after context truncation, run a read-only use_figma to scan all pages, components, variables, and styles by name to reconstruct the {key → id} map. Then re-read the state file from disk if available.

Continuation prompt (give this to the user when resuming in a new chat):

"I'm continuing a design system build. Run ID: {RUN_ID}. Load the figma-generate-library skill and resume from the last completed step."


5. search_design_system — Reuse Decision Matrix

Search FIRST in Phase 0, then again immediately before each component creation.

search_design_system({ query, fileKey, includeComponents: true, includeVariables: true, includeStyles: true })

Reuse if all of these are true:

  • Component property API matches your needs (same variant axes, compatible types)
  • Token binding model is compatible (uses same or aliasable variables)
  • Naming conventions match the target file
  • Component is editable (not locked in a remote library you don't own)

Rebuild if any of these:

  • API incompatibility (different property names, wrong variant model)
  • Token model incompatible (hardcoded values, different variable schema)
  • Ownership issue (can't modify the library)

Wrap if visual match but API incompatible:

  • Import the library component as a nested instance inside a new wrapper component
  • Expose a clean API on the wrapper

Three-way priority: local existing → subscribed library import → create new.


6. User Checkpoints

Mandatory. Design decisions require human judgment.

After Required artifacts Ask
Discovery + scope lock Token list, component list, gap analysis "Here's my plan. Approve before I create anything?"
Foundations Variable summary (N collections, M vars, K modes), style list "All tokens created. Review before file structure?"
File structure Page list + screenshot "Pages set up. Review before components?"
Each component get_screenshot of component page "Here's [Component] with N variants. Correct?"
Each conflict (code ≠ Figma) Show both versions "Code says X, Figma has Y. Which wins?"
Final QA Per-page screenshots + audit report "Complete. Sign off?"

If user rejects: fix before moving on. Never build on rejected work.


7. Naming Conventions

Match existing file conventions. If starting fresh:

Variables (slash-separated):

color/bg/primary     color/text/secondary    color/border/default
spacing/xs  spacing/sm  spacing/md  spacing/lg  spacing/xl  spacing/2xl
radius/none  radius/sm  radius/md  radius/lg  radius/full
typography/body/font-size    typography/heading/line-height

Primitives: blue/50blue/900, gray/50gray/900

Component names: Button, Input, Card, Avatar, Badge, Checkbox, Toggle

Variant names: Property=Value, Property=Value — e.g., Size=Medium, Style=Primary, State=Default

Page separators: --- (most common) or ——— COMPONENTS ———

Full naming reference: naming-conventions.md


8. Token Architecture

Complexity Pattern
< 50 tokens Single collection, 2 modes (Light/Dark)
50–200 tokens Standard: Primitives (1 mode) + Color semantic (Light/Dark) + Spacing (1 mode) + Typography (1 mode)
200+ tokens Advanced: Multiple semantic collections, 4–8 modes (Light/Dark × Contrast × Brand). See M3 pattern in token-creation.md

Standard pattern (recommended starting point):

Collection: "Primitives"    modes: ["Value"]
  blue/500 = #3B82F6, gray/900 = #111827, ...

Collection: "Color"         modes: ["Light", "Dark"]
  color/bg/primary → Light: alias Primitives/white, Dark: alias Primitives/gray-900
  color/text/primary → Light: alias Primitives/gray-900, Dark: alias Primitives/white

Collection: "Spacing"       modes: ["Value"]
  spacing/xs = 4, spacing/sm = 8, spacing/md = 16, ...

9. Per-Phase Anti-Patterns

Phase 0 anti-patterns:

  • ❌ Starting to create anything before scope is locked with user
  • ❌ Ignoring existing file conventions and imposing new ones
  • ❌ Skipping search_design_system before planning component creation

Phase 1 anti-patterns:

  • ❌ Using ALL_SCOPES on any variable
  • ❌ Duplicating raw values in semantic layer instead of aliasing
  • ❌ Not setting code syntax (breaks Dev Mode and round-tripping)
  • ❌ Creating component tokens before agreeing on token taxonomy

Phase 2 anti-patterns:

  • ❌ Skipping the cover page or foundations docs
  • ❌ Putting multiple unrelated components on one page

Phase 3 anti-patterns:

  • ❌ Creating components before foundations exist
  • ❌ Hardcoding any fill/stroke/spacing/radius value in a component
  • ❌ Creating a variant per icon (use INSTANCE_SWAP instead)
  • ❌ Not positioning variants after combineAsVariants (they all stack at 0,0)
  • ❌ Building variant matrix > 30 without splitting (variant explosion)
  • ❌ Importing remote components then immediately detaching them

General anti-patterns:

  • ❌ Retry
how to use figma-generate-library

How to use figma-generate-library on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add figma-generate-library
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/figma/mcp-server-guide --skill figma-generate-library

The skills CLI fetches figma-generate-library from GitHub repository figma/mcp-server-guide and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/figma-generate-library

Reload or restart Cursor to activate figma-generate-library. Access the skill through slash commands (e.g., /figma-generate-library) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

User Story & Requirements Generation

Create detailed user stories, acceptance criteria, and feature specs

Example

Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios

Reduce spec writing time by 50%, ensure comprehensive coverage

Competitive Analysis

Research competitors, compare features, identify gaps

Example

Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities

Complete competitive research in 2 hours instead of 2 days

Roadmap Prioritization

Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs

Example

Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale

Make data-driven prioritization decisions faster

Stakeholder Communication

Draft PRDs, status updates, and stakeholder presentations

Example

Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement

Save 3-5 hours/week on communication overhead

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client
  • Access to product documentation and roadmap tools (Jira, Notion, etc.)
  • Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
  • Stakeholder contact information and communication channels

Time Estimate

30-60 minutes to see productivity improvements

Installation Steps

  1. 1.Install product management skill
  2. 2.Start with user story generation for known feature
  3. 3.Progress to competitive analysis: research 2-3 competitors
  4. 4.Use for roadmap prioritization: apply RICE/ICE scoring
  5. 5.Draft stakeholder communications and refine based on feedback
  6. 6.Build template library for recurring PM tasks
  7. 7.Share effective prompts with product team

Common Pitfalls

  • Not validating competitive research—verify facts before sharing
  • Accepting user stories without involving engineering team
  • Over-relying on frameworks without qualitative judgment
  • Not customizing outputs to company culture and communication style
  • Skipping stakeholder validation of generated requirements

Best Practices

✓ Do

  • +Validate research and competitive analysis with real data
  • +Collaborate with engineering when generating technical requirements
  • +Customize frameworks and templates to your company context
  • +Use skill for first drafts, refine with stakeholder input
  • +Document successful prompt patterns for PM tasks
  • +Combine AI efficiency with human judgment and intuition

✗ Don't

  • Don't publish competitive analysis without fact-checking
  • Don't finalize user stories without engineering review
  • Don't make prioritization decisions solely on AI scoring
  • Don't skip customer validation of generated requirements
  • Don't ignore company-specific context and culture

💡 Pro Tips

  • Provide context: company goals, constraints, customer feedback
  • Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
  • Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
  • Use skill for 70% generation + 30% customization to company needs

When to Use This

✓ Use When

Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.

✗ Avoid When

Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.

Learning Path

  1. 1Basic: user stories, feature specs, status updates
  2. 2Intermediate: competitive analysis, prioritization frameworks, PRDs
  3. 3Advanced: product strategy, go-to-market planning, OKR setting
  4. 4Expert: product vision, market positioning, business model innovation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.462 reviews
  • Luis Jain· Dec 16, 2024

    We added figma-generate-library from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Ganesh Mohane· Dec 12, 2024

    We added figma-generate-library from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

  • Amina Bansal· Dec 8, 2024

    Keeps context tight: figma-generate-library is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • James Smith· Dec 4, 2024

    figma-generate-library has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Isabella Abebe· Dec 4, 2024

    figma-generate-library is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Hiroshi Kim· Nov 27, 2024

    figma-generate-library is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Kofi Robinson· Nov 23, 2024

    Solid pick for teams standardizing on skills: figma-generate-library is focused, and the summary matches what you get after install.

  • Isabella Okafor· Nov 7, 2024

    figma-generate-library reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Rahul Santra· Nov 3, 2024

    figma-generate-library reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Anaya Agarwal· Oct 26, 2024

    figma-generate-library is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

showing 1-10 of 62

1 / 7