agentsclimarketplace

Figma design fetch

Skill jajupmochi/agent-harness/skills/figma-design-fetch

Use when the user shares a figma.com URL, wants to implement/mock a UI from Figma, or do design-to-code — connect the Figma MCP, fetch the design (code/assets/screenshot) to disk, then rebuild with existing design-system components and visually self-verify against the Figma screenshot.From its SKILL.md

Install
npx -y skills add jajupmochi/agent-harness --skill figma-design-fetch

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

4 things to look at

  • reads credentialsReads from 1 credential source: `.figma-token`.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
  • runs commandsInstructs the agent to run 6 commands, including `claude mcp add --transport http figma https://mcp.figma.com/mcp` and 5 more.
  • fetches URLsInstructs the agent to fetch 1 URL, including https://mcp.figma.com/mcp.

SKILL.md

12.2 KB, ~3.2k tokens by cl100k_base, as published. Nobody here has run it

/figma-design-fetch

The full Figma → code pipeline via the official Figma MCP: connect, fetch the design (code / vector / bitmap / screenshot) to disk, rebuild the screen with the project's existing token-mapped components + real data, and visually self-verify against the Figma screenshot until it converges. Agent-assisted with a mandatory verification gate — never paste raw generated code as production UI.

The reliability of design-to-code comes less from the MCP than from three things you control: (a) a token-driven, mappable component library, (b) this fixed workflow with a mandatory visual gate, and (c) deterministic non-LLM hooks (typecheck, prettier). None depend on your Figma plan.

Master TOC

When to use

  • The user pastes a figma.com/design/... (or /file/...) URL.
  • The user asks to implement / mock / rebuild a UI from a Figma design, or says "design-to-code".
  • You need a screen's visual truth, structure, reference code, tokens, or assets to reconstruct it.

Prerequisites

  1. Figma account + seat: at least a Full or Dev seat. A starter (free) tier + Full seat is enough for get_design_context to emit code; Code Connect requires an Organization/Enterprise plan (see gotcha 2).
  2. The Figma MCP is available — deferred tools mcp__plugin_figma_figma__*. If not (do this only if the user asks — it changes their config):
    claude mcp add --transport http figma https://mcp.figma.com/mcp   # remote, recommended
    
  3. A token-mapped component library in the target repo (a component barrel + design tokens). The pipeline maps Figma values onto these, never hardcoded hex.

PAT + local stdio fallback (tradeoff). The default is the official remote MCP (OAuth). Its PKCE flow expires in minutes (gotcha 1); if re-auth is too painful you may instead run a local stdio server with a Personal Access Token — npx figma-developer-mcp --figma-api-key=<PAT> --stdio — which has no minute-expiry. Cost: a different, non-official tool surface (no get_code_connect_map, different fetch shape) and you hold a PAT. Adopt only if OAuth churn blocks you, and never commit/print the PAT (read it from env / a gitignored .figma-token).

Setup A — Connect the Figma MCP (OAuth)

  1. Call authenticate → it returns an authorization URL.
  2. The user opens it, logs into Figma (never enter the user's password), clicks Authorize (read-only mcp:connect scope).
  3. Redirect http://localhost:<port>/callback?code=...: same-machine browser → the local listener auto-completes; otherwise the user pastes the full address-bar URL back and you call complete_authentication.
  4. Verify with whoami → account + seat.

⚠️ Gotcha 1 — OAuth PKCE expires in minutes. Authorize within a few minutes of authenticate, else No OAuth flow in progress → re-run authenticate.

Setup B — Get a node-specific link

https://www.figma.com/design/<fileKey>/<name>?node-id=<1-23> → extract fileKey (after /design/) and nodeId (after node-id=; 4001-8 == 4001:8). The link must include node-id, and it must be the target frame, not the file cover.

Pre-fetch design pre-check lint (gate)

Before generating any code, check the frame and warn / stop if the design won't produce clean code — these mean it violates the authoring constraints (see the figma-authoring-constraints skill) and get_design_context will degrade to a rigid pixel snapshot:

  1. Unbound-variable colors — colors not bound to Figma variables (→ get_variable_defs returns {}; you'd be forced to eyeball hex).
  2. Default layer namesFrame\d+ / Group\d+ (no semantic structure).
  3. Pure image / rasterized nodes — a flattened mockup has no semantics → pixel snapshot only.
  4. Absolute-positioned children — no auto layout → no responsive intent, won't map to flexbox.

On a hit: report it and either go back to Figma to fix the design, or get the user's explicit OK to proceed with a degraded (pixel-snapshot) result. Do not silently generate from a non-conformant frame.

The 5-step pipeline (each step is mandatory)

1. Extract (real values, never estimate from the image)

For the fileKey + nodeId, call in order and record the real values (do NOT guess from the picture):

ToolWhat you get
get_design_contextReact + Tailwind reference code + structure + asset URLs
get_metadatadimensions / padding / fills / hierarchy / layer names + annotation text (intent)
get_variable_defsdesign tokens (use them if present; empty {} → gotcha 3)
get_screenshotthe visual ground truth (short-lived URL; curl it now, it's the diff baseline)
download_assetsreal bitmaps / logos (defaultFormat=svg for vector) — 7-day URLs, save now
get_code_connect_mapFigma→code component mapping — only on an Org/Enterprise plan (gotcha 2)

Produce a per-frame design doc in <frontend-repo>/.design-imports/<feature>/ (gitignored): spacing(px), fonts, colors (hex → token TBD), radius/shadow/opacity, layout, component hierarchy + states, and a hand-annotation → requirement table. Save export.png / design.svg / assets/raw_image_*.png / link.txt.

2. Map to the design system (Need→Token contract)

Map before writing code — never recreate what exists:

  • Open the component barrel (e.g. components/src/index.ts), enumerate existing components, and pick one existing wrapper for each Figma element.
  • Map Figma colors/spacing onto tokens (primary.main, theme.spacing(n), …). Never hardcode #xxx / rgb().
  • Code Connect needs Org/Enterprise. Without it, keep a hand-maintained Need → Token markdown table + the component barrel as the mapping contract (this is what the reference project does). Keep the table even if you later get Code Connect — it's the human-readable fallback. Empty get_variable_defs → read concrete values from get_design_context code / the exported CSS and record them in this table.

3. Implement

Use only design-system components; split by domain; put logic in use-*.ts hooks; wire real backend data (not placeholders). Do not paste raw get_design_context output as production code — it's context.

4. Visual self-check (mandatory gate)

  1. Start the local app → Playwright browser_navigate to the route → browser_resize to the Figma frame's EXACT dimensions (critical — only same-size images compare) → browser_take_screenshotget_screenshot for the same node → compare layout / spacing / fonts / colors / radius / shadow / states → on any difference, go back to step 3 and loop until aligned.
  2. Objective gate (our hardening over "the model eyeballs it"). On top of the model's judgment, run a numeric check at the exact frame size + a fixed DPR: pixelmatch (or SSIM) with a numeric pass threshold, so "matches" is not just the model's subjective opinion. A helper is provided:
    node skills/figma-design-fetch/scripts/visual-diff.mjs <impl.png> <figma.png> [--threshold 0.02] [--dpr 2]
    #  → exits non-zero if the mismatch fraction exceeds the threshold; writes a diff PNG next to the inputs.
    
    Capture both PNGs at the same pixel dimensions and DPR, or the metric is meaningless.

5. Report

New/changed components · the token mapping (Figma value → token) · anything that did not map cleanly · the visual-diff result (mismatch fraction vs threshold).

Deterministic hooks (the quality spine)

Wire these agent-harness hooks in the frontend repo so quality doesn't depend on the model remembering:

  • typecheck-on-edit (PostToolUse) — after a .ts(x) edit, prettier --write then tsc --noEmit; type errors exit 2 and block the turn. hooks/typecheck-on-edit/.
  • block-env-read (PreToolUse) — deny reading .env* so secrets stay out of the transcript. hooks/block-env-read/.
  • Keep git / destructive shell off the agent's tool allowlist.

Gotchas (tested — read before fetching)

⚠️ 1. OAuth PKCE expires in minutes → authorize promptly; re-issue on No OAuth flow in progress.

⚠️ 2. Code Connect is paywalled → auto-mapping to your React components (get_code_connect_map) needs Org/Enterprise. Without it, map manually via the Need→Token table + barrel.

⚠️ 3. get_variable_defs returns empty = the design bound no Figma variables → read concrete values from get_design_context / exported CSS. Fix at the design side (see figma-authoring-constraints).

⚠️ 4. Low-fidelity spec mockupsget_design_context returns a pixel snapshot (absolute + <img>), not componentized code. Do not paste verbatim. This is what the pre-check lint catches.

⚠️ 5. Asset URLs expire in ~7 days (renders ~minutes) → curl to disk immediately. Prefer token/component rendering; use download_assets only for real bitmaps/logos, consumed at once.

⚠️ 6. Browser auto-login scraping: not recommended — can't enter the user's password, Figma's canvas is WebGL (unscrapeable), and it's redundant with (and worse than) the official MCP.

Figma export options ↔ MCP

Figma optionWhat it isMCP equivalent
PNGraster renderdownload_assets (default png) / get_screenshot
SVGvector exportdownload_assets(defaultFormat=svg)
CSS codeCSS of the one selected layerget_design_context (React+Tailwind, not raw single-element CSS)
CSS (all layers)flat absolute-positioned dump of the subtreeget_design_context (nested React+Tailwind, richer)
Property / Inspectdimensions / spacing / typographyget_metadata + get_variable_defs
iOS / Android codenative SwiftUI / Composenone — not needed for a web frontend

References

Cite, don't copy:

  • Pipeline (Part A flow + Part B design constraints): neobanker-docsdocs/platform/guides/figma-to-code-pipeline.md.
  • Fetch flow + the 6 gotchas: neobanker-docsdocs/platform/guides/figma-mcp-fetch-tutorial.md.
  • Reusable REST-API script (PAT): neobanker-frontend-MVP-V3.design-imports/figma-fetch.sh.
  • Reference implementation (method, not code): https://github.com/aliafsahnoudeh/figma-to-code-claude-pipeline.

Companion

  • figma-authoring-constraints — the Figma-side design constraints (Part B) that make a design cleanly code-able; the pre-check lint above enforces a subset as a gate.
  • verify-visual — screenshot + self-critique loop (step 4).
  • typecheck-on-edit, block-env-read — the deterministic hooks referenced above.
  • ui-iteration-loop rule — the autonomous visual-convergence loop.

Provenance

Distilled from a Neo Horizon design-to-code run (official Figma MCP, tested end-to-end) plus the aliafsahnoudeh reference pipeline, adapted to the official MCP. Consolidated into agent-harness so any session hitting a Figma design follows the tested flow, maps to the design system instead of eyeballing pixels, and verifies its own work against an objective gate.

What ships with it: 2 files

7.4 KB alongside SKILL.md, 2 of them executable

scripts/

Gives 0 of the 12 instructions most design frontend skills give in ~3.2k tokens

Counted across 1,179 of the 2,086 authors here whose files we hold, read 2026-09-06

  • Commit to a bold aesthetic directionin 31 of 1179, across 24 files
  • Prefer component composition over inheritancein 28 of 1179, across 14 files
  • Animate only transform and opacity propertiesin 27 of 1179, across 22 files
  • Memoize expensive computations with useMemoin 26 of 1179, across 13 files
  • Use semantic HTML elementsin 24 of 1179, across 23 files
  • Virtualize long lists for performancein 21 of 1179, across 10 files
  • Use CSS variables for design tokensin 20 of 1179, across 14 files
  • Implement loading, empty, and error statesin 20 of 1179
  • Lazy load heavy components with Suspensein 19 of 1179, across 8 files
  • Respect prefers-reduced-motion media queriesin 18 of 1179, across 10 files
  • Prioritize CSS-only animations for HTMLin 18 of 1179, across 16 files
  • Use compound components for related UI elementsin 18 of 1179, across 7 files

Said here and by no other author read

  • connect the Figma MCP
  • fetch design context and assets to disk
  • verify implementation against Figma screenshot
  • run numeric visual diff check
  • report token mapping and visual diff results
  • save design documentation in gitignored directory

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.