/storybook-workbench:sb-figmafrom Storybook Workbench
Bridges Figma and Storybook in both directions: maps design tokens (color/spacing/type) from Figma variables with parity/drift detection, delivers approved Figma components into Storybook, and builds Code Connect mappings so Figma Dev Mode shows real code. For syncing tokens, delivering approved designs, or connecting components to Figma.
Ships in Storybook Workbench. 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.
sb-figma moves an approved design into production Storybook (Jobs 1–2) and pushes the code's truth
back to Figma (Job 3, and opt-in writes). It uses the Figma MCP, but it is not the exploration skill.
| Job | Needs | Tools |
|---|---|---|
| Read tokens (Job 1, preferred) | edit access to the file; the remote server | use_figma (read-only script) |
| Read tokens (fallback) | any seat | get_variable_defs |
| Deliver a component (Job 2) | any seat | get_design_context, get_metadata, download_assets |
| Code Connect (Job 3) | Organization or Enterprise plan, published library components | get_code_connect_suggestions, get_context_for_code_connect, send_code_connect_mappings |
| Write to Figma (opt-in) | Full seat for an existing file (any seat can write to drafts); remote server; beta | use_figma, generate_figma_design |
https://mcp.figma.com/mcp). The desktop server has no write, no
code-to-canvas and no skills.whoami, add_code_connect_map and create_new_file don't count.whoami (plans + seats) and report what's
missing instead of retrying.figma-use, figma-design-to-code, figma-code-connect, figma-generate-design) come
with the Figma plugin; without it, read them from the MCP as skill://figma/<name>/SKILL.md. Tools that
require one say so in their description — load it first and pass skillNames.The lifecycle line (load this first). Undecided / trying options →
sb-explore(Lab sandbox, iterate against a Figma node) →sb-ship(graduate the Lab experiment). Already approved in Figma →sb-figma(deliver direct to prod). Both touch Figma MCP; the difference is exploration vs delivery. If the user is still deciding, hand off tosb-explore. Seereferences/figma-token-sync.md.
Every run starts here and ends here:
node scripts/workbench-settings.mjs gaps. Each one says what a previous run
couldn't do and how to fix it. Show them to the user before starting new work..storybook/figma/gaps.json: collision (several Figma variables
on one token), weak-match (named on the last word only), unmapped-name (Figma variables with no code
token), unsupported-value (a colour syntax the parity can't read), unmapped-variant-value (a Figma
variant value with no code value). A gap a later run no longer finds is marked resolved.missing-token), a tool Figma
refused (tool-refused):
node scripts/workbench-settings.mjs add --kind missing-token --detail "icon #116932 has no token" --suggestion "…"..storybook/workbench.json (scaffold:
node scripts/workbench-settings.mjs --init; schema references/workbench.schema.json); the project owns
the file, so skill updates never overwrite it, and command-line flags still win:
css — where the token CSS lives · darkSelectors — what marks the dark themenameMap — "fg/error": "--color-error-text": beats name guessing, settles collisionsignore — Figma variables to leave out ("Size/*") · variantValues — "status - success": "success"codeConnectLabel — default Code Connect labelreport-issue.sh --gaps
drafts a sanitized issue with the open gaps as counts per kind — no names or values.Force the NATIVE structured tools — never work from a screenshot. A screenshot is pixels; it cannot give you variables, styles, or component props. The full picture comes ONLY from the native MCP tools, and you must pull all three categories before building or connecting:
- Variables →
get_variable_defs(the token values: color/spacing/type/effect, resolved).- Components + styles →
get_design_context(the reference code, applied styles, props/variants).- Structure →
get_metadata(the node tree; on truncation, drill to child node-ids — never give up at the parent).get_screenshotis visual reference only — for an eyeball diff after you've built from the structured data. NEVER read tokens, props, or layout off a screenshot. If a tool returns "nothing selected" on a page id, drill to a concrete component node (a page is not a layer).
Scripts can't call the Figma MCP, and an MCP result lives only in the agent's context — ephemeral, gone on the next session, absent headless. So every Figma MCP call you make, persist it through the universal store before using it. This is what makes the pipeline reproducible and iterable.
# pipe each tool's output straight in (JSON, code text and XML are all stored as returned):
<get_variable_defs output> | node scripts/capture-figma.mjs --tool get_variable_defs --file <FILE> --node <NODE> --from-mcp -
<get_design_context output> | node scripts/capture-figma.mjs --tool get_design_context --file <FILE> --node <NODE> --from-mcp -
<get_metadata output> | node scripts/capture-figma.mjs --tool get_metadata --file <FILE> --node <NODE> --from-mcp -
<get_code_connect_map out> | node scripts/capture-figma.mjs --tool get_code_connect_map --file <FILE> --node <NODE> --from-mcp -
# get_screenshot returns an image — save it, then register the file:
node scripts/capture-figma.mjs --tool get_screenshot --file <FILE> --node <NODE> --image /tmp/frame.png
# see the whole inventory (degrade / iterate):
node scripts/capture-figma.mjs --list
Store layout: .storybook/figma/manifest.json + .storybook/figma/<tool>/<node>.json (images keep their
ext). Re-capturing a (tool,node) overwrites — diff against git to see what moved in Figma. Downstream steps
read the store, never re-call MCP.
What the live Figma MCP actually returns — the scripts already handle these; know them so you don't fight the output:
get_variable_defs is a FLAT { "name": "value" } map (not nested DTCG, not an array). Colors come already
resolved to hex ("semantic/background":"#fbfcfc"), incl. 8-digit alpha ("#e4e5e580"). Numbers are bare
strings ("spacing-2":"8", "wght/semibold":"650"). Typography is an opaque Font(family: …, size: …)
string — pull-figma-variables parses it to {family,size,weight,lineHeight,…} (a field may itself be a
var-name ref like size/text-lg). Shadows are Effect(…) → the effect family. classify() buckets by VALUE.get_metadata returns XML and TRUNCATES on large frames (a table view blew past the token limit). When it
truncates: read the child node ids from the partial XML and get_design_context/get_metadata the sub-node,
not the parent. Capture each sub-node to the store so you never re-fetch.1-6965, the API examples use 1:6965; every tool accepts both. capture-figma
stores captures under the dash form so they're found either way. Every tool also needs the fileKey from
the URL (figma.com/design/<fileKey>/…; for a branch URL use the branch key).get_design_context returns code text plus a screenshot by default; get_metadata returns XML. Only
get_variable_defs and the use_figma read script return JSON.Foundations/Colors|Tokens|Type (sb-figma writes these directly)No other skill maps Figma variables to code tokens, so sb-figma owns the foundation parity end to end.
figma-use skill (or the
skill://figma/figma-use/SKILL.md resource), then call use_figma with the contents of
references/read-figma-variables.js as code and skillNames: "figma-use". It only reads: every local
collection, every mode (Light, Dark, …), aliases resolved. Big system (output is capped near 20 kB): set
ONLY to one collection and call once per collection. Capture the result (Job 0).
Fallback, when you can't run use_figma (no edit access to the file): get_variable_defs on the node
that uses the tokens. It returns only the variables that node uses, in one mode — dark is not compared.
Library variables the file consumes but doesn't own: get_libraries, then search_design_system with
{"entity":"variable", …}.node scripts/pull-figma-variables.mjs --from-mcp .storybook/figma/<tool>/<NODE>.json --out .storybook/figma-variables.json.
It accepts either shape; the default mode fills color/spacing/type, other modes land in modes.
With no --from-mcp it reuses the last cache (the headless degrade path).node scripts/build-token-parity.mjs --variables .storybook/figma-variables.json --css <token-css-glob> --out .storybook/figma-token-parity.json.
The CSS is read per theme: :root is the default, .dark / [data-theme=dark] / dark @media blocks
are the dark theme. Figma's default mode is compared with the default theme, a Figma "Dark" mode with the
dark theme (modes.Dark in the output). OKLCH channel triplets resolve to hex; semantic/* maps to the
project's --token, following var() alias chains.figmaParity to TokenMatrix (it reads figma-token-parity.json)
to show drift in the color table's issue column (figma Δ, code #X vs figma #Y on hover). The fields are
optional: a project with no Figma file renders as before.--popover, --ring, …) are expected, not failures.get_design_context now requires it: use the
/figma-design-to-code skill (Figma plugin) or read the skill://figma/figma-design-to-code/SKILL.md
MCP resource, and pass skillNames: "figma-design-to-code" ("resource:figma-design-to-code" when read
from the resource) on the call. Set clientFrameworks/clientLanguages (e.g. react, typescript).get_design_context call returns reference code, asset download
URLs and a screenshot; capture it. If it comes back as metadata only (too large), fetch the child nodes
listed in it instead of the parent. get_metadata gives the tree when you need structure alone.search_design_system finds library components by name.get_design_context response describes, into the
project's asset folder. No placeholders, no new icon package, no temporary Figma asset URLs left in code.sb-stories' conventions (materially different states only; a factory when 3+
stories share a shape), stamp the node-id in a top-of-file comment and parameters.design (Shared
plumbing), then validate light / dark / mobile against the captured screenshot.python3 scripts/record-figma-delivery.py . \
--figma-url "<board url>" [--feature "<Name>"] --spec-url "<spec node url>" --node-ids 101-9717 \
--description "<one line>" \
--story "Hunts/Hunt Packs:hunts-hunt-packs--default:component" # repeat per story you created
Then ensure the root surface exists: scaffold once with scaffold-wrapper.sh --figma, drop the
figma-inventory.stories.tsx template (title Figma Inventory), add one export per feature
(export const Hunts = { args: { feature: 'Hunts' } }), and pin it to the top in .storybook/preview
via options.storySort.order: ['Figma Inventory', '*']. The FigmaInventory wrapper reads
figma-inventory.json and renders the index + each feature's board link + the stories it brought in.Push the code's truth back so Figma Dev Mode shows your real components. Code Connect needs an Organization or Enterprise plan and published library components (see Preconditions). Follow Figma's order; every call goes through the Job-0 store:
whoami. No Org/Enterprise plan → stop and say so; Dev Mode won't show mappings.get_code_connect_suggestions on the page or frame (excludeMappingPrompt: true
for a lean list of unmapped components).get_context_for_code_connect per component node: its properties, variant options and
descendants. Match it to the code component (a story with parameters.design for that node is the
strongest signal; else the component name).comps.json (component, codeFile, figmaNode, optional componentName,
label, tokens, variantProperties, modes), then:
node scripts/build-code-connect.mjs --components comps.json --file <FILE_KEY> \
--parity .storybook/figma-token-parity.json --usage .storybook/component-usage.json \
--out .storybook/code-connect.json
send is the exact send_code_connect_mappings input (fileKey, nodeId,
mappings[{nodeId, componentName, source, label}]); context holds tokens, real props and variant →
prop mappings for review; reverseParity lists components with no Figma node or no source, unsupported
labels, drifted tokens.send_code_connect_mappings with
send as-is. One mapping only: add_code_connect_map works too. Both write to Figma.Component.figma.ts for the
@figma/code-connect CLI 2.x (template files are the only maintained format since 2.0; .figma.tsx +
figma.connect() are migrate-only), or pass template in the mapping. Figma's /figma-code-connect
skill covers templates; context[].propMappings is the input.Components with no Figma node (componentsWithoutNode) have nothing to connect to; creating them is a
write (below).
The loop closes: the parameters.design node-id added when delivering (Jobs 1–2) is what Job 3 reads to
connect back.
Only on the user's explicit request, and confirm before each write — it changes their file. Needs a Full seat for an existing file (see Preconditions).
use_figma (load figma-use first, skillNames: "figma-use"). Build from the file's own
components and variables (search_design_system), return every created node id, and record them.node scripts/build-figma-variables.mjs --css "src/**/*.css" --prefix "--color-bg,--color-text-" \
--collection "Code tokens" --out .storybook/figma-variables-push.json
Paste one entry as PAYLOAD into references/write-figma-variables.js and run it with use_figma —
DRY = true first: it returns what it would create and update. Show that to the user, then run with
DRY = false. It reuses a collection or variable with the same name and overwrites values; it deletes
nothing. Check with Job 1: reading the collection back and running parity should show zero drift.generate_figma_design only to capture a rendered page the first time — e.g. a story rendered in
isolation: http://localhost:6006/iframe.html?id=<story-id>&viewMode=story. It makes a pixel copy; refine
it with use_figma against the library components. Updating a page already captured → use_figma.parameters.design, so Jobs 2–3 see it.Every story sb-figma touches gets the design source preserved on its catalog page:
parameters: { design: { type: 'figma', url: 'https://figma.com/file/<FILE_ID>?node-id=<NODE_ID>' } }
This is @storybook/addon-designs (the "Design" tab — the same mechanism sb-explore uses for frames). Plus
a node-id stamp + link in parameters.docs.description. sb-explore and sb-stories can reuse this snippet
whenever the node-id is known.
sb-explore (Lab). sb-figma is for approved designs only.sb-ship (preserve cp, rewrite callsites). sb-figma delivers from
Figma, not from a /explore/ experiment.sb-stories. sb-figma calls sb-stories' rules to
author; it never reimplements them.sb-health / sb-inventory (Figma-free). sb-figma adds the
design↔code parity those can't see.fileKey every tool needs; a node URL for Jobs 2–3 (and for the
get_variable_defs fallback: a frame that uses the tokens). Ask if not pasted.--token: <value> declarations live (e.g. src/styles/**/*.css).sb-explore.whoami).Run Job 1 (tokens) first so components built in Job 2 consume real, parity-checked tokens. Append progress to
.storybook/audit/status.md for clean resume. Full call sequence + the OKLCH→hex notes:
references/figma-token-sync.md.
CONTEXT.md (opens in a new tab)agents/openai.yaml (opens in a new tab)decorators/withLayoutFrame.tsx (opens in a new tab)references/figma-token-sync.md (opens in a new tab)references/read-figma-variables.js (opens in a new tab)references/workbench.schema.json (opens in a new tab)references/write-figma-variables.js (opens in a new tab)scripts/build-code-connect.mjs (opens in a new tab)scripts/build-figma-variables.mjs (opens in a new tab)scripts/build-token-parity.mjs (opens in a new tab)scripts/capture-figma.mjs (opens in a new tab)scripts/css-tokens.mjs (opens in a new tab)scripts/pull-figma-variables.mjs (opens in a new tab)scripts/record-figma-delivery.py (opens in a new tab)scripts/workbench-settings.mjs (opens in a new tab)templates/figma-inventory.stories.tsx (opens in a new tab)wrappers/FigmaInventory.tsx (opens in a new tab)wrappers/ReportIntro.tsx (opens in a new tab)wrappers/TokenMatrix.tsx (opens in a new tab)wrappers/TokensCanvas.tsx (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
figma, storybook, design-tokens, code-connect, design-system, token-parity
npx claudepluginhub strongeron/storybook-workbench --plugin storybook-workbench11 skills in this plugin
/sb-auditPeriodic Storybook audit — naming-drift survey, archived/decision-board review, lifecycle tagging, usage refresh. Use for 'audit my Storybook', 'find drift', 'show pending decisions', or a periodic catalog health check./sb-exploreIterate on a new or redesigned component in a sandboxed Explore story outside src/components/ (+ Figma), checked against a graduation gate. Use for 'prototype this', 'try a v2', 'explore from Figma', or net-new UI not ready to ship./sb-flowsMap the whole app — routes, navigation edges, and persistent nav chrome, not just a screen list. Use for 'map the app', 'show the flow', 'app map', 'audit navigation', or 'how do screens connect'./sb-healthCheck design-system health for a React+Vite app — raw hex, undefined/unused tokens, scale gaps, DESIGN.md drift, and (opt-in) property→token-family misuse. Use for 'is my design system healthy', 'find raw colors', 'check tokens', or a mixed design system./sb-hubHub for the Storybook CSF3 bundle — diagnose a repo, orchestrate the audit→stories pipeline, or name the next sb-* step. Use for 'set up Storybook', 'audit my app', 'where do I start', 'what's next'./sb-inventoryAudit a React+Vite app for real-vs-slop components (by actual imports), the dominant design system, and real prop-value usage at call sites. Use for 'what components do I have', 'which are dead', 'audit this vibe-coded app'.Other plugins' skills for the same job