agentleFS
pedroab0pedroab0/skills/figma-to-code/SKILL.md

figma-to-code

Skill1 starsChanged 8 days agoMITView on GitHub

Converts a Figma frame or component directly into production-ready UI code in a single pass, fetching a compact design-token-aware node tree from the Figma REST API and reusing the host project components and styles. Use when the user shares a figma.com link and explicitly asks to build, code, or implement it right away, without an intermediate spec review step. Supports React, Vue, Svelte, Angular, and plain HTML/CSS.

  • Reads credentials

18 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use systematic-debugging, mcp-builder and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • OpenAISkill

    systematic-debugging

    Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

    Also in 3 projects that use this

  • MicrosoftSkill

    mcp-builder

    Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

    Also in 3 projects that use this

  • GoogleSkill

    tdd

    Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the user only wants to inspect, document, or plan the design, stop and suggest the figma-extractor skill instead.

    line 16
  2. Very specific:

    1. Discover the host project: check package.json (framework, styling, icon library), reusable components in components/ui/ or …

    line 30
  3. Distinctive:

    3. Build: follow the Build rules, adapting syntax to the detected stack.

    line 40
  4. Very specific:

    Run the project's existing checks: typecheck or lint scripts from package.json, or npx tsc --noEmit when TypeScript is already installed.

    line 44
  5. Distinctive:

    If checks fail in the files you created or changed, fix them and run the checks again.

    line 45
  6. Very specific:

    If a preview image was downloaded (image.path in the output), compare it visually with the result.

    line 47
  7. Very specific:

    Reuse existing components (no div soup): when an INSTANCE matches an existing component, import and render it with the spec props (<Button …

    line 51
  8. Very specific:

    Colors and typography: never guess values. Use the semantic token when present (mapped to the project CSS variable or Tailwind class), …

    line 53
  9. Very specific:

    Run fetch_figma.js once per target frame or component.

    line 71

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Figma To Code

Fetches a compact, design-token-aware node tree for a Figma frame and immediately builds the component in the host project, reusing its existing components and styles.

Requires Node.js >= 16.7. The scripts have zero dependencies (no npm install).

Boundaries

  • Never open Figma URLs with browser tools (Playwright, Puppeteer, Chrome DevTools). The Figma canvas is WebGL, so there is no DOM to read. Do not search for local browser binaries.
  • API errors are final: report them to the user. Never fall back to scraping.
  • If the user only wants to inspect, document, or plan the design, stop and suggest the figma-extractor skill instead.

Workflow

Copy this checklist and track your progress:

Build Progress:
- [ ] 1. Discover the host project (stack, UI primitives, tokens, icons)
- [ ] 2. Fetch the node tree (once)
- [ ] 3. Build the component following the build rules
- [ ] 4. Validate and fix

1. Discover the host project: check package.json (framework, styling, icon library), reusable components in components/ui/ or src/components/, and theme files (tailwind.config.*, theme.css, globals.css).

2. Fetch the node tree (1 Tier 1 API call; JSON is printed to stdout):

node "<skill-dir>/scripts/fetch_figma.js" "<FigmaURL>"

For large frames, add --shallow-instances (collapses instance internals into props) or --depth 2. All flags, the output schema, token setup per OS, and proxy options: see REFERENCE.md (located at <skill-dir>/REFERENCE.md).

3. Build: follow the Build rules, adapting syntax to the detected stack.

4. Validate and fix

  1. Run the project's existing checks: typecheck or lint scripts from package.json, or npx tsc --noEmit when TypeScript is already installed. Never install new dependencies to do this.
  2. If checks fail in the files you created or changed, fix them and run the checks again. Repeat until they pass.
  3. Report pre-existing failures in other files instead of fixing them.
  4. If a preview image was downloaded (image.path in the output), compare it visually with the result.

Build rules

  1. Reuse existing components (no div soup): when an INSTANCE matches an existing component, import and render it with the spec props (<Button variant="primary" size="large" hasIcon>Confirm Order</Button>). Never rebuild existing primitives from raw elements.
  2. Layout: layoutMode: "HORIZONTAL" → flex row; "VERTICAL" → flex column; itemSpacing → gap; padding → padding; primaryAxisAlignItems / counterAxisAlignItems → justify-* / items-*. Prefer the matching *Token when present.
  3. Colors and typography: never guess values. Use the semantic token when present (mapped to the project CSS variable or Tailwind class), otherwise the exact hex color. Map font size, weight, and line height to existing typography tokens or classes.
  4. Icons and vectors (VECTOR nodes, isSvg: true, or icon instances): normalize the name by stripping icon/, ic_, ico- (icon/search → search), then resolve in order:
    1. Local assets or components in components/icons/, src/assets/, or public/ only (no repo-wide searches).
    2. The icon library installed in package.json (e.g. import { Search } from 'lucide-react').
    3. An accessible placeholder with a TODO: Missing icon 'search' comment. Never invent raw SVG <path d="..."> coordinates.
  5. Image fills (fills: [{ type: "IMAGE" }]): apply only the spec styling (size, radius, scaleMode: "FILL" → object-cover, "FIT" → object-contain). Never fetch or invent image URLs. Render <img src="" alt="..."> with a TODO comment naming the layer and its size.

Resolving <skill-dir>

Substitute <skill-dir> with the directory where this skill is installed. Never guess another agent's folder, and keep the double quotes around the script path (Windows/macOS/Linux):

  • Standard skills (SKILL.md): the parent directory of this SKILL.md file.
  • Cursor rule (.cursor/rules/figma-to-code.mdc): the sibling .cursor/skills/figma-to-code directory.

Quota rules (Zero-Hammer Protocol)

The script enforces a local rate gate and a persistent circuit breaker, but the agent must also follow these rules:

  1. Run fetch_figma.js once per target frame or component. Never retry in a loop.
  2. Do not pass -i unless the user explicitly requests a preview image. The JSON already contains layout, dimensions, colors, radii, typography, and text.
  3. Figma Starter plans and View seats have very small monthly Tier 1 quotas, so every call matters.

Errors

Error codeAction
FIGMA_ACCESS_TOKEN is not set / FIGMA_TOKEN_EXPIRED_OR_INVALIDTell the user the token is missing, invalid, or expired. They create one in Figma Settings → Personal Access Tokens and set FIGMA_ACCESS_TOKEN (setup per OS in REFERENCE.md).
Node not foundReport that the node-id does not exist in the file.
FIGMA_SSL_CERTIFICATE_ERRORCorporate proxy or self-signed certificate: suggest FIGMA_IGNORE_SSL=true in .env.
FIGMA_RATE_LIMIT_EXCEEDED / FIGMA_CIRCUIT_BREAKER_ACTIVEReport the cooldown. Suggest duplicating the file in Figma Drafts (Right-click → Duplicate) for a fresh URL, or exporting the selection with the companion Figma Node JSON Extractor plugin and building from that JSON.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.