Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Workflow recipe

Turn a Figma design into code with an agent

Connect the Figma MCP server, map the design's variables to your tokens first, build one frame, then run a visual diff and an axe check.

By Intermediate2 h 5 min7 steps
Bookmark

Bookmarks are kept in your free account, so you can find this page again on any device.

Sign in to bookmark
On this page

To turn Figma into code with AI, tidy the frame in Figma, connect Figma’s MCP server to your coding agent with Figma’s skills, and ask for a table that maps every Figma variable the frame uses to a token in your code before any component is written. Then have the agent build the one frame with your existing components and tokens, compare a screenshot of the result with the Figma render side by side, run an automated accessibility check, and review the diff for hard-coded values.

The Figma MCP server gives an agent the design’s structure, variables, a screenshot and reference code, which is far better than pasting an image. Its reference code is still a prototype: absolute positions, raw colour values and new copies of components you already have. Without rules, the agent ships that as is, and you end up with a second design system inside your first. Mapping tokens first and reviewing for hard-coded values is what keeps the output in your codebase’s own terms; the screenshot and accessibility checks catch what looks right in Figma and fails in a browser.

FigmaAbout 15 min

1. Prepare one frame so the agent reads it correctly

Pick one screen or one component, not a whole page; Figma’s own guidance warns that large selections slow the tools down or return incomplete results. Then make the frame easy to read:

  • Make repeated elements (buttons, inputs, cards) components.
  • Use variables for colour, spacing, radius and type, not raw values.
  • Rename layers like Frame 1268 to what they are (PriceCard, PrimaryButton).
  • Use auto layout rather than absolute positions, and resize the frame once to check it behaves.
  • Add annotations for behaviour the picture cannot show: hover and focus states, what happens on narrow screens, which text is dynamic.

Copy the link to the frame (right-click, Copy link to selection). Each link points at one node, which keeps the agent’s context small.

TerminalAbout 10 min

2. Connect the Figma MCP server and its skills

Figma recommends its plugin where one exists, because it installs the MCP server settings and Figma’s skills together. The remote server is at https://mcp.figma.com/mcp and signs you in with OAuth.

claude plugin install figma@claude-plugins-official

Then run /plugin, open the Installed tab, select figma and allow access in the browser. Without the plugin, claude mcp add --transport http figma https://mcp.figma.com/mcp adds the server only (no skills); authenticate from /mcp.

The skill that matters here is Figma’s figma-design-to-code, which tells the agent to request a screenshot with the design context, reuse the project’s components and tokens, translate absolute positioning into normal layout, and never leave temporary Figma asset URLs in code. Our directory lists the older Figma to code skill from OpenAI’s catalogue, which does the same job if you install skills by hand.

Check the connection with a cheap call: ask the agent “Use the Figma MCP whoami tool and tell me my plan and seat.” On a View or Collab seat you get up to 20 tool calls a month, which this recipe can use up in one run.

Your agentAbout 20 min

3. Map the design’s variables to your tokens before building

This step decides whether the result uses your design system or invents a new one. Ask for a mapping, read it, and fix the gaps before any code exists.

Variables to tokens, no code yet · Claude Code, Codex or Cursor
Use the Figma MCP server on this frame: [FIGMA FRAME LINK]. Do not write or edit any code yet. 1. Call get_variable_defs for the frame and list every variable and style it uses (colour, spacing, radius, typography, shadow). 2. Read our token source: [TOKEN FILE PATHS, E.G. src/styles/tokens.css AND tailwind config]. Map each Figma variable to the closest existing token. Mark each row EXACT, CLOSE (say what differs) or MISSING. 3. List the existing components in [COMPONENT FOLDER] that match parts of the frame (buttons, inputs, cards), with the Figma layer each one replaces. 4. List any raw values in the frame that do not use a variable. Rules: do not propose new tokens or components yet. If two Figma variables map to the same token, say so.

Read the table with the designer if you can. For each MISSING row, decide: add a token (a design decision, not the agent’s), or use the nearest one and tell the designer. Raw values in the frame usually mean the design is not using its own library there; ask before you copy them into code. Save the final table to a file in the repository so step 4 can use it.

Your agentAbout 30 min

4. Build the frame with your components and tokens

Now ask for the component, with the mapping as the rulebook.

Implement one frame · Claude Code, Codex or Cursor
Implement this Figma frame as a component: [FIGMA FRAME LINK]. Put it in [TARGET FILE PATH]. Use the figma-design-to-code skill if it is installed. Use the token mapping in [MAPPING FILE] and these rules: - Use only the tokens in the mapping. No hex, rgb or pixel values in the component, except where the mapping row says so. - Reuse the existing components listed in the mapping. Do not create a new button, input or card. - Use the project's normal layout (flex or grid), not absolute positioning, unless the design can only be built that way; say where you did. - Use semantic HTML: real buttons and links, headings in order, labels for inputs, alt text for images that carry meaning and empty alt for decorative ones. - Download every image and icon the design context lists into [ASSETS FOLDER]; leave no Figma asset URLs in code. - Do not change other components or the token files. When you finish, list: files changed, components reused, any value that is not a token and why, and what the frame shows that you could not build (interactions, states).

Treat the agent’s “could not build” list as the start of a conversation with the designer, not as a to-do list for the agent. Interactions and states that the frame does not show (loading, error, empty) are still undecided.

Terminal and browserAbout 20 min

5. Compare a screenshot of the build with the Figma render

Put the component on a page at the frame’s width and take a screenshot. A short Playwright script does it repeatably:

// scripts/shot.spec.ts
import { test } from "@playwright/test";

test("price card screenshot", async ({ page }) => {
  await page.setViewportSize({ width: 1440, height: 900 }); // the Figma frame width
  await page.goto("http://localhost:5173/preview/price-card");
  await page.locator("[data-testid=price-card]").screenshot({ path: "shots/price-card.png" });
});
npx playwright test scripts/shot.spec.ts

Open the screenshot next to the Figma frame (or ask the agent to fetch the frame with get_screenshot and compare the two images) and look for: spacing that is a few pixels off everywhere (a wrong spacing token), the wrong font weight or line height, text that wraps differently, icons swapped for look-alikes, and colours one shade away. Fix by correcting the mapping, not by adding one-off values. Once the component matches, keep the screenshot as a baseline with Playwright’s toHaveScreenshot so later changes show up as a diff.

TerminalAbout 15 min

6. Run an accessibility check the design cannot show

A frame can look perfect and still fail keyboard and screen reader users. Add an axe scan to the same test file:

import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

test("price card has no serious accessibility violations", async ({ page }) => {
  await page.goto("http://localhost:5173/preview/price-card");
  const results = await new AxeBuilder({ page })
    .include("[data-testid=price-card]")
    .withTags(["wcag2a", "wcag2aa"])
    .analyze();
  expect(results.violations.filter((v) => ["serious", "critical"].includes(v.impact ?? ""))).toEqual([]);
});

Then check by hand what axe cannot: tab through the component and confirm every control is reachable with a visible focus ring, the order makes sense, and nothing is announced twice. Colour contrast failures usually trace back to the design, so take them to the designer with the token names. For a fuller pass, the Accessibility review skill or the accessibility audit with an agent recipe goes further.

TerminalAbout 15 min

7. Review the diff for hard-coded values and duplicates

git diff main --stat
git diff main | grep -nE "#[0-9a-fA-F]{3,8}\b|rgb\(|[0-9]+px|position: ?absolute|figma\.com"

Red flags: raw colours or pixel values outside the token files, absolute positioning, a new component that duplicates one you have, edited token files you did not approve, and Figma URLs left in code. Each needs a reason or a fix. Then ask the designer to look at the screenshot from step 5 before you merge.

Check it worked

Verification checklist

0 of 6 done

When it goes wrong

If the tools are slow, time out or return partial results, the selection is too big. Link a smaller node, or ask the agent to call get_metadata first for an outline and then fetch design context only for the parts it needs, which is what Figma’s documentation recommends.

If the agent stops working after a few calls, check your seat. View and Collab seats are limited to 20 tool calls a month on every plan; Dev and Full seats on paid plans get a daily allowance (200 a day on Professional). The whoami tool tells you which seat the server sees.

If the code is full of absolute positions and fixed widths, the frame probably was not using auto layout, so the design context could only describe positions. Fix the frame in Figma and fetch again; it is quicker than fixing the layout by hand.

If colours or spacing are slightly off everywhere, a mapping row is wrong, usually a CLOSE match that should have been MISSING. Correct the mapping file and ask the agent to re-apply it, rather than patching values one by one.

Variations

If your design system is not in the repository yet, write it down first as an Agent Skill, as in the design system skill recipe; the agent then knows your tokens and do and don’t rules in every session, not only when the mapping file is open.

With Figma’s Code Connect set up, the design context names your real components for each Figma component, which makes step 3 shorter. For a quick prototype rather than production code, an app builder is faster; see prototype an internal tool with an app builder.

If your agent cannot reach the Figma MCP server, Figma’s desktop app also runs a local server for Dev and Full seats on paid plans. Connect MCP servers to your agent covers adding servers in each client.

Web design guidelines reviews the finished component against a public checklist of interface rules. The glossary entry for an MCP server explains what the Figma server is doing for the agent.

Outcome and tools

Outcome
One Figma frame built as a component in your codebase with your existing tokens and components, a side-by-side screenshot comparison and an accessibility check with no serious violations.
For
Developers
Variants for
Claude Code, Codex, Cursor
  • Skill recipe: your design system

    A worked skill that teaches coding agents your tokens, components and do and don't rules, with detail in reference files so it loads only when needed.

    Skill guideIntermediate

  • Run an accessibility audit with an agent

    Run an AI accessibility audit against WCAG 2.2 AA with Playwright, axe-core and an agent, add the manual checks scanners miss, and rank fixes by user impact.

    WorkflowIntermediate2 h 30 min7 steps

  • Connect MCP servers to Claude Code, Codex and Cursor

    Add local and remote MCP servers to Claude Code, Codex and Cursor, choose the right scope, sign in with OAuth and check which tools actually loaded.

    TutorialBeginner25 min

  • MCP server

    A program that exposes tools, resources or prompts to MCP clients, running locally over stdio or remotely over HTTP, so any MCP host can use them.

    Glossary

  • Prototype an internal tool with an app builder

    Build an internal tool prototype with AI with v0, Lovable or Bolt in an afternoon, test it with real users, and list what must change before it meets real data.

    WorkflowBeginner3 h6 steps

Back to top