/mvp-builder:figma-extractorfrom mvp-builder
Extracts design tokens, styles, component metadata, and screen structure from Figma files via MCP. Supports three extraction depths from quick read-only to deep library search.
Ships in mvp-builder. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Extract design tokens, styles, component metadata, and screen structure from Figma files.
Process: CHECK → PARSE → DISCOVER → EXTRACT → ORGANIZE
Every extracted value carries a source tag — downstream consumers use this for conflict resolution priority. A variable definition is stronger evidence than an inferred applied style.
Not every workflow needs every tool. Three levels control extraction depth:
Level 1 (Quick): whoami → get_metadata → get_variable_defs → get_design_context → get_screenshot
Fast, read-only MCP tools. No Plugin API.
Level 2 (Deep): Level 1 + use_figma read-only scripts
Adds: collections with modes, codeSyntax, scopes, aliasing chains,
text styles, effect styles, paint styles.
Level 3 (Targeted): Level 2 + search_design_system + get_context_for_code_connect
Adds: library asset discovery, exact component property definitions.
The calling workflow determines the level. When in doubt, start at Level 1 and escalate if data is sparse.
Level 2-3 use use_figma for read-only extraction scripts only. Scripts from scripts/ are pre-built for this purpose.
Rules:
return { ... } containing extracted datause_figma is unavailable → graceful fallback to Level 1skillNames: "figma-extractor" in every use_figma call (logging only)The calling agent must ensure figma-use skill rules are known when using Level 2+ (color range 0–1, return pattern, page context reset per call). The scripts in scripts/ already follow these rules.
Every extracted value is tagged with its source. Priority for conflict resolution:
| Tag | Meaning | Priority |
|---|---|---|
figma-variables | Explicitly defined Figma Variable | Highest |
figma-library | Asset from a subscribed design library | Medium |
figma-context | Inferred from applied styles on frames | Lowest |
whoami()
If this fails → warn user, skip all Figma steps. Don't attempt tool calls that will error out.
https://figma.com/design/:fileKey/:fileName?node-id=X-Y
https://figma.com/file/:fileKey/:fileName?node-id=X-Y
https://figma.com/proto/:fileKey/:fileName?node-id=X-Y
/design/, /file/, or /proto/node-id query param, convert dash → colon (1-2 → 1:2)| Condition | Action |
|---|---|
URL has /design/, /file/, /proto/ | Parse and proceed |
URL has /board/ (FigJam) | Warn: "FigJam not supported" → skip |
URL has /slides/ | Warn: "Slides not supported" → skip |
| No URL, MCP connected | Can still extract variables — get_variable_defs works without nodeId |
| No URL, MCP not connected | Warn: "No Figma source available" → skip |
| nodeId missing in URL | Fetch root pages first, then navigate |
Call get_metadata at the provided nodeId (or 0:1). Large files — narrow to individual pages, then identify top-level frames as screens.
SCREENS[] = [{
nodeId, name, page, width, height,
slug ← kebab-case: "Login Screen" → "login-screen"
}]
get_variable_defs returns a flat map of paths to values. Categorize by inspecting path structure and value types:
color/primary/500 → color token
spacing/lg → spacing token
radius/md → border-radius token
font/body/size → typography token
Mark all: source: "figma-variables".
When variables come back empty — common. Many files use local styles instead of Variables. Fall back to 3.2.
get_design_context returns applied styles, layout, component structure. Use when variables are empty or sparse, or when you need component patterns.
Extract: color fills, text styles, spacing/padding, corner radius, effects, component instances.
Mark all: source: "figma-context".
Usage tracking: When extracting from multiple screens, count how many times each value appears and record where it's used. This serves two purposes:
primary-500 → Button fill, Header background) gives downstream consumers concrete usage context for generating actionable rules.For each extracted value, track:
usageCount: N // how many nodes reference this value
usedIn: ["Button/fill", "Header/bg"] // screen/component + property pairs
Run get_design_context on 2-3 complex screens minimum to build meaningful usage data. Single-screen extraction gives unreliable frequency.
Truncation: If response is too large → fetch child nodes individually via get_metadata node IDs, then get_design_context per child.
get_screenshot per screen in SCREENS[]. Visual truth for implementation and validation. If a screenshot fails → log warning, continue.
Level 2 adds data that Level 1 tools cannot provide: variable metadata (codeSyntax, scopes, aliasing chains, modes), text styles, effect styles, paint styles.
Prerequisite: use_figma tool must be available. If unavailable → stay at Level 1.
Embed extractVariableMetadata.js in a use_figma call.
Returns for every local variable:
codeSyntax (WEB, ANDROID, iOS) — the CSS/Swift/Kotlin token namescopes — which pickers this variable appears invaluesByMode — resolved values per mode, including alias targetsVARIABLE_ALIAS, the target variable nameCritical nuance: getLocalVariablesAsync() returns only local variables. If empty, it does NOT mean no variables exist — library variables are invisible to this API. Use Level 3 (search_design_system) to check linked libraries.
Mark all: source: "figma-variables" (enriches 3.1 data with metadata).
Embed extractStyles.js in a use_figma call.
Returns:
These are data that no Level 1 tool exposes. get_variable_defs doesn't cover styles. get_design_context partially infers them from usage but without style names or precise values.
Mark all: source: "figma-variables" (styles are explicit design decisions, same as variables).
Embed extractComponentInventory.js in a use_figma call.
Returns for every component set across all pages:
componentPropertyDefinitions (property name, type, defaultValue, variantOptions)Mark all: source: "figma-variables".
Level 3 adds cross-library search and structured component metadata. Use when the file subscribes to external design libraries or when exact component property definitions are needed for code mapping.
Call search_design_system to find tokens, components, and styles across all subscribed libraries.
Load search-strategies.md for query patterns and result interpretation before calling. Key rules:
components[], variables[], styles[] with keys for importMark all: source: "figma-library".
Decision after search:
| Local variable exists | Library variable exists | Action |
|---|---|---|
| Yes | Yes | Keep local (intentional override), note library source |
| Yes | No | Keep local |
| No | Yes | Record as library asset — available for import |
| No | No | No token for this slot |
Call get_context_for_code_connect per component to get exact property definitions.
Parameters:
fileKey, nodeId (published component/set),
clientFrameworks: ["react"], clientLanguages: ["typescript"]
Returns: property definitions with types — TEXT, BOOLEAN, VARIANT (with options), INSTANCE_SWAP. Property names are case-sensitive and must match exactly.
This upgrades the Component List from 3.6 by adding precise property schemas instead of just names/counts.
The caller decides output paths. If no path specified, return data structures in-memory.
Load data-structures.md for detailed output schemas.
Merge tokens from all sources. figma-variables wins over figma-library wins over figma-context. Level 2 enriches each token with:
"primary-500": {
value: "#3B82F6",
source: "figma-variables",
codeSyntax: { WEB: "var(--color-primary-500)" }, // Level 2
scopes: ["FRAME_FILL", "SHAPE_FILL"], // Level 2
aliasOf: "blue/500", // Level 2
collection: "Color", // Level 2
modes: { "Light": "#3B82F6", "Dark": "#60A5FA" }, // Level 2
usageCount: 23, // from 3.2 analysis
usedIn: ["Button/fill", "Header/bg", "Link/color"] // from 3.2 analysis
}
usageCount and usedIn are populated from design context analysis (3.2). Tokens with usageCount: 0 are flagged as orphans in Quality Signals (4.7).
FIGMA_COMPONENTS = [{
figmaName: "Button",
variants: ["primary", "secondary", "ghost"],
properties: { "Label": "TEXT", "Size": "VARIANT", ... }, // Level 2-3
propertyClassification: { // derived from property types
state: ["State"], // VARIANT with Default/Hover/Pressed/Disabled → interactive state
size: ["Size"], // VARIANT with Small/Medium/Large → dimensional
style: ["Style", "Type"], // VARIANT with Primary/Secondary/Ghost → visual variant
content: ["HasIcon"] // BOOLEAN → content toggle (show/hide slot)
},
confidence: "high",
source: "figma-variables"
}]
Property classification rules:
Classification is best-effort by naming patterns. When ambiguous, leave unclassified — the caller can resolve.
FIGMA_TEXT_STYLES = [{
name: "Heading/H1", fontFamily: "Inter", fontStyle: "Bold",
fontSize: 48, lineHeight: 56, letterSpacing: -1.0
}]
FIGMA_EFFECT_STYLES = [{
name: "Shadow/Medium",
effects: [{ type: "DROP_SHADOW", offset: {x:0, y:4}, radius: 6, spread: -1, color: {r:0, g:0, b:0, a:0.1} }]
}]
FIGMA_LIBRARY_ASSETS = {
components: [{ name, libraryName, componentKey }],
variables: [{ name, variableType, key, scopes, collectionName }],
styles: [{ name, styleType, key }]
}
FIGMA_SCREENS = [{
slug, nodeId, name, page, dimensions,
hasScreenshot, hasDesignContext
}]
Figma Extraction Summary
Source: [URL or "no URL — variables only"]
Level: [1/2/3]
Screens: [N] discovered, [N] with screenshots
Tokens: [N] from Variables, [N] from Context, [N] from Library, [N] total unique
Styles: [N] text, [N] effect, [N] paint
Components: [N] discovered, [N] with property definitions
Quality: [N] warnings (see below)
After merging all data, flag design consistency issues. These are warnings for downstream consumers — they don't block extraction but signal that the design may produce noisy tokens.
| Signal | How to detect | Downstream impact |
|---|---|---|
| Hardcoded colors | Color value found in design context but no matching variable exists | Token may be one-off, not systematic — lower confidence |
| Inconsistent spacing | Multiple spacing values that don't fit a base grid (e.g., 5, 7, 13 alongside 4, 8, 16) | Spacing tokens may include accidental values |
| Detached instances | Component instance with no link to source component set | Component may have been modified locally — properties unreliable |
| Orphan variables | Variable defined but never used in any extracted screen | Token exists in system but may be deprecated |
| Style/Variable mismatch | Text style "Heading/H1" says 48px but variable font/heading/size says 44px | Conflict that downstream needs to resolve |
Detection happens automatically during ORGANIZE by cross-referencing:
Include in summary as warnings[]. Each warning: { type, token, details }.
CHECK → whoami
PARSE → URL → fileKey + nodeId
DISCOVER → get_metadata → SCREENS[]
EXTRACT:
L1: get_variable_defs → tokens
get_design_context on 2-3 complex screens → tokens + components + usage data
get_screenshot for each screen
L2: use_figma extractVariableMetadata.js → codeSyntax, scopes, aliases, modes
use_figma extractStyles.js → text/effect/paint styles
use_figma extractComponentInventory.js → component sets + properties
ORGANIZE → merge token map (with usage counts), style maps, component list
(with property classification), screen index, quality signals, summary
Full Extraction (Level 2) +
L3: search_design_system → library assets
get_context_for_code_connect per key component → exact property schemas
ORGANIZE → add library assets, upgrade component properties
CHECK → whoami
PARSE → URL → fileKey
EXTRACT:
L1: get_variable_defs → tokens
If sparse (<5): get_design_context on 1-2 screens
L2 (if needed): use_figma extractVariableMetadata.js → codeSyntax, scopes
ORGANIZE → token map with sources
CHECK → whoami
PARSE → URL → fileKey + nodeId
DISCOVER → get_metadata → SCREENS[]
EXTRACT: get_screenshot for each screen
ORGANIZE → screen index with screenshots
Extraction is enrichment, not requirement. The pipeline continues without Figma data — it just has less information.
| Error | Response |
|---|---|
whoami fails | MCP not connected → warn user, skip all |
| Invalid/unsupported URL | Warn → skip |
| Empty variables | Normal — fall back to design context (3.2) |
| Empty local variables + Level 2 | Not an error — check library via Level 3 before concluding "no tokens" |
use_figma unavailable | Fall back to Level 1 — warn about reduced extraction |
search_design_system empty | File may not subscribe to libraries — not an error |
| Truncated response | Narrow scope → fetch children individually |
| Screenshot timeout | Try smaller child frames → continue |
| Permission denied | Warn "check Figma file sharing settings" → skip |
Read-only Plugin API helpers. Embed in use_figma calls for Level 2 extraction.
| Script | Purpose | Level |
|---|---|---|
| extractVariableMetadata.js | Collections, modes, codeSyntax, scopes, aliases, valuesByMode | 2 |
| extractStyles.js | Text styles, effect styles, paint styles with full properties | 2 |
| extractComponentInventory.js | Component sets across all pages with property definitions | 2 |
Detailed documentation loaded on demand.
| Reference | Load when | Content |
|---|---|---|
| search-strategies.md | Level 3 — before calling search_design_system | Query patterns, result interpretation, local vs library decisions |
| data-structures.md | Step 4 ORGANIZE — when building output structures | Detailed schemas for token map, component list, style maps, library assets |
| Step | Tool | Level | Purpose |
|---|---|---|---|
| CHECK | whoami | 1 | Verify MCP connection |
| DISCOVER | get_metadata | 1 | File structure, pages, frames |
| EXTRACT | get_variable_defs | 1 | Variable values (flat map) |
| EXTRACT | get_design_context | 1 | Applied styles, layout, components |
| EXTRACT | get_screenshot | 1 | Visual reference per screen |
| EXTRACT | use_figma + scripts | 2 | Deep: metadata, styles, component inventory |
| EXTRACT | search_design_system | 3 | Library assets across subscribed libraries |
| EXTRACT | get_context_for_code_connect | 3 | Exact component property definitions |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub app-builders-club/mvp-builder --plugin mvp-builder14 skills in this plugin
/clarifyRefine an existing feature specification through targeted clarification dialogue. Use when a spec.md contains ambiguities — vague roles, non-testable requirements, unclear entities — that should be resolved before generating the doc chain./code-analyzerComprehensive codebase analysis for building mental model of project structure, dependencies, and implementation context. Use when needing to: (1) Understand project architecture before review or documentation, (2) Find dependencies and shared modules, (3) Trace execution paths and abstraction layers for similar features, (4) Locate implementation markers (AICODE-*), (5) Prepare context for review, memory generation, or agent creation. Triggers on: analyze code, load code context, scan codebase, understand project structure, trace feature./context7Up-to-date library documentation retrieval using Context7 MCP tools. Process THINK → RESOLVE → FETCH → APPLY. Use when fetching library docs, resolving package names to IDs, getting implementation guides, exploring API references. Provides package resolution strategy, trust score evaluation, token scaling (3K-20K), topic selection patterns./doc-templatesCanonical templates for every MVP Builder pipeline artifact. Use whenever generating, regenerating, or restructuring any ai-docs artifact — spec.md, FEATURES.md, ux.md, ui.md, plan.md, tasks.md, validation checklists, resolutions.md, feedback.md, design-system.md — so the exact section structure downstream agents parse is preserved. Triggers on: generate spec, create feature docs, write tasks, validation checklist, review feedback, design setup, artifact template./featureGenerate feature specifications from PRD or a user-provided feature description into structured spec files. Use after the PRD is finalized to extract all features, or to add a single new feature to an existing FEATURES.md index./feature-analyzerComprehensive feature artifact analysis for loading and understanding complete feature context. Use when needing to: (1) Load all feature documentation before implementation, (2) Build mental model of feature requirements and architecture, (3) Prepare context for downstream operations like checklist generation or task execution, (4) Analyze feature completeness and artifact availability. Triggers on: analyze feature, load feature context, prepare feature, check feature prerequisites, understand feature scope.Other plugins' skills for the same job