Back

PROCESS · FIGMA TO CODE WITH CLAUDE CODE

Figma to implementation-ready UI, with the system as the only material.

Figma to implementation-ready UI, with the system as the only material.

Figma to implementation-ready UI, with the system as the only material.

A hiring manager asked for one real example: the source design, the instruction pattern, the generated output, and how I checked it against the design system. This page is that example, end to end. Ledger is a small MVP I built to show the system: a design system and one checkout screen.

ROLE

Designer, system owner

MODEL

Claude Code, Figma MCP

STACK

Figma · Tailwind v4 · Playwright

THE LOOP

a gap found in QA goes back to Figma
Hover a step

86

variables in 4 collections

primitives hidden, every role an alias

6

components, 12 icons

every property bound to a token

10 × 2

states, 2 widths

all instances from the library

5 of 7

went back to Figma

4 into the library, 1 a new frame, 2 code only

1 · SOURCE

Where the design comes from.

86 variables in 4 collections. Primitives are hidden from publishing, so the only tokens a designer or the model can pick are semantic roles, layout and typography. Every semantic value is an alias. Every variable carries scopes, so a text color never shows up in a fill picker, and a CSS name, so the export already knows what it will be called in code. Pick a role and follow it.

Local variables⋯×
Primitives31
Semantic38
Layout9
Typography8
All variables
cta
text
focus
state
+Create collection
Semantic38 variablesMode Default ▾
NameDefault
▼cta
primary/bgaccent/600
primary/hoveraccent/700
▼text
primaryneutral/900
secondaryneutral/600
placeholderneutral/500
▼focus
ringaccent/500
▼state
error/textred/600
selected/bgaccent/100
+Create variable
Edit variable×
Name
cta/primary/bg
Value
accent/600#0B5C4D
Description
The one filled button on a screen.
Code syntax
Web
▍
Scoping
Frame fillShape fillText fillStrokeEffect
Hide from publishing
tokens/figma.tokens.json
"$value": "{primitives.accent.600}", "codeSyntax": { "WEB": "var(--color-cta-primary-bg)" }
src/tokens/theme.css
--color-cta-primary-bg: #0B5C4D;
the class the model may type
bg-cta-primary-bg
Playing. Hover to pause, click a row to pick it. No default Tailwind palette exists in the project. A color that is not one of these roles is not a class.

6 component sets and 12 Lucide icons. Every fill, stroke, padding and radius is bound to a variable, every label uses a text style, and every set has a description that says what it is for and what it maps to in code. The screen frames were composed by script from these components, which is how the system is meant to be used. The layout, the states, the copy and the hierarchy are my decisions.

Foundations / Colors · semantic, published
Background
bg/canvas
--color-bg-canvas
bg/surface
--color-bg-surface
bg/subtle
--color-bg-subtle
Text
text/primary
--color-text-primary
text/secondary
--color-text-secondary
text/placeholder
--color-text-placeholder
text/inverse
--color-text-inverse
text/link
--color-text-link
Border
border/default
--color-border-default
border/strong
--color-border-strong
border/focus
--color-border-focus
CTA
cta/primary/bg
--color-cta-primary-bg
cta/primary/hover
--color-cta-primary-hover
cta/primary/text
--color-cta-primary-text
cta/secondary/border
--color-cta-secondary-border
cta/secondary/text
--color-cta-secondary-text
cta/secondary/hover-bg
--color-cta-secondary-hover-bg
State
state/error/text
--color-state-error-text
state/error/bg
--color-state-error-bg
state/success/text
--color-state-success-text
state/success/bg
--color-state-success-bg
state/disabled/bg
--color-state-disabled-bg
state/disabled/text
--color-state-disabled-text
state/selected/bg
--color-state-selected-bg
state/selected/border
--color-state-selected-border
Figure 1a. Semantic color roles with the CSS name each one carries into code. Primitives are hidden.1 of 3
The Button component set: primary, secondary, tertiary, in two sizes and five states.

Figure 2. The Button set: 3 variants, 2 sizes, 5 states, 30 combinations, every property bound to a variable.

Figure 2. The Button set: 3 variants, 2 sizes, 5 states, 30 combinations, every property bound to a variable. Scroll sideways.

2 · INSTRUCTION PATTERN

What I told the model.

The brief, then 3 files. The model reads the frame itself through the Figma connection, so the prompt only needs the link to the frame.

The brief, as a template
docs/prompt.mdsaved verbatim, so the run can be repeated
Role
You are the front-end engineer on Ledger. Read CLAUDE.md first.
One sentence sets the stance, and the file reference loads the rules before the task. Rules first, task second, so the rules win when the two collide.
Context
The frame is the 1280 default state: Ledger-Checkout, node 3:301. The 390 default is node 4:684.
The other states are the sibling frames on the same page. The four _note frames above them hold behavior, focus order, accessibility and breakpoint rules.
Point at the source of truth instead of describing it. The model reads the frame through the Figma connection, so the prompt stays short and cannot drift from the design.
Task
Build the Review and pay screen as src/screens/ReviewAndPay.tsx from this frame, and wire it as the app’s route.
One deliverable, one path, one route. Nothing is left to interpret.
Constraints
Use only the components in src/components and the token utilities in src/tokens/theme.css. Map Figma components with figma-map.json.
Every state in the Figma page must be reachable: default, field focus, validation errors, promo applied, promo invalid, submitting, declined, success, empty cart. Drive them from real form state and a mocked payment call: 4242… ok, …0002 declined, …0010 timeout.
Validation on blur and on submit. Field-level messages that say how to fix the problem. Focus moves to the first invalid field. Nothing is charged until Pay is pressed, and the UI says so.
Responsive: 390 single column with the summary first; 1280 two columns with a 360px aside. No third layout.
Accessibility: labels, inputMode, autocomplete, aria-invalid, live regions as the notes specify, 44px hit targets, visible focus. npm run test:e2e must pass axe.
Copy exactly as in the frames. Prices: items $68.00 and $50.00, shipping $10.00, SAVE10 takes $12.00 off.
Every constraint is something a check can fail on. The state list is the contract: a state that is not in it does not exist.
Process
1. Read the frame and the notes with the Figma connection. List the components and tokens the frame uses, matched to figma-map.json.
2. Write the plan before any code: layout, components, state model, how each state is reached, anything the system is missing. If something is missing, stop and say so instead of inventing it.
3. Implement. Add a Playwright test that walks every state at both widths, runs axe, and takes screenshots.
4. Run npm run check and npm run test:e2e. Report what passed, what failed, and what you changed to fix it.
Plan before code is the step that found the two gaps. Stop and say so turns a missing frame into a finding instead of an invention.
Boundaries
Do not add dependencies. Do not edit src/tokens/ or tokens/.
Generated files stay generated. A token fix goes to Figma, never to the output.
Six blocks, in this order, is the shape I reuse. The grey notes are why each block is there. The words in square brackets in the blank template are the only parts that change from project to project.

If I had to show one thing from this run in a review, it would be the plan. Before any code, the model went through the frame, listed the components and tokens it used and matched each one to the map. Then it added a section it called What the system is missing, with two items in it. Rule 8 says to stop when something does not exist, so it stopped at both and asked.

docs/run-plan.mdwritten by the model, before any code

3 · OUTPUT

What came out.

ReviewAndPay.tsx, 209 lines, using only the 6 components and the token utilities. Every one of the 10 states is reachable from real form state and a mocked payment call that behaves like a test mode. Validation runs on blur and on submit, errors are field-level and say how to fix the problem, and focus moves to the first invalid field. Submitting locks every control and the button keeps its height, so nothing jumps.

src/screens/ReviewAndPay.tsxgenerated, unedited
const payBlock = (
<div className="flex flex-col gap-3">
<Button type="submit" form="checkout" variant="primary" size="lg" loading={busy} iconLeft={<Lock strokeWidth={1.5} />} className="w-full">
{busy ? "Processing payment" : `Pay ${money(total)}`}
</Button>
<p className="flex items-center gap-2 text-caption text-text-secondary">
…
<div className="lg:hidden">{summary}</div>
<div className="grid gap-8 lg:grid-cols-[1fr_360px] lg:items-start">
<form id="checkout" onSubmit={submit} noValidate className="flex flex-col gap-6">
…
<aside className="hidden lg:sticky lg:top-8 lg:flex lg:flex-col lg:gap-4">
{summary}
{payBlock}
</aside>
Lines 114 to 119, 136 to 139 and 188 to 191, as the model wrote them at commit c84a551, wrapped to fit. No raw color, no raw button, every class a token utility. The summary renders before the form below lg, and at lg and up it moves into the 360px aside, the only layout switch the frame allows. F7 later changed two of these gap values for 390.
Rendered app
Figma frame
Figma frame
Rendered app
↔

Figure 3. Drag the handle: the Figma frame against the generated screen at 1280, after the findings below were fixed.

Default
Validation
Declined
Submitting
Default
Figure 4a. The default state at 1280.
Review and pay at 390 in Figma: order summary first
Review and pay at 390 in Figma: order summary first
Review and pay at 390 rendered: order summary first
Review and pay at 390 rendered: order summary first

Figure 5. The 390 layout, Figma on the left and the render on the right, after F7. Summary first, so the total is visible before the fields.

Figure 5. The 390 layout, the Figma frame first and the render under it, after F7. Summary first, so the total is visible before the fields.

Figure 6a. Success names the order, the amount and the card, and says where the receipt went.
1 of 3 · tap to flip
Figure 6a. Success names the order, the amount and the card, and says where the receipt went.
1 of 3 · tap to flip

4 · QA

How I checked it against the system.

There are 2 layers. The gates run on every change: the token build, lint, a guardrail that fails on raw colors, raw buttons and off-scale spacing, 33 unit tests including contrast on every text role, and Playwright at 390 and 1280 with axe at every state. Then the design review, by hand, Figma beside the render: type, color, spacing, radius, borders, heights, hierarchy, hover, focus, disabled, loading, every error state, both layouts, icons, copy, hit targets, semantics. 33 rows, the same number as the unit tests.

24 33 of 33
9 of the 33 review rows failed on pass 1. The findings behind them are F1 to F6, and the plan had already flagged two of those. F7 came from building this page.
Found by
axe, on the 12px helper text under an input: 4.37:1 on white. The same primitive feeds the placeholder and the muted icon.
Root cause
A token value. neutral/500 was chosen by eye and never measured against the surfaces it sits on.
Where the fix went
Darkened the primitive in Figma, re-exported, regenerated the theme. A unit test now measures every text role on every surface, so it cannot drift back.
Figma
Export
Code
Test
Found by
The plan, before any code. The frame has "Change" inside a sentence. The tertiary button is 44px tall and would break the line.
Root cause
Component coverage. The screen used a text link the system never defined.
Where the fix went
The model stopped and named the gap, as rule 8 says. Text link was added to the Figma library, to the code, and to the map.
Figma
Export
Code
Test
Found by
The plan. The prompt lists a timeout path from the mocked payment call. The Figma page defined 9 states and none was a timeout.
Root cause
The prompt and the frames were written apart. A state the code needs was never designed.
Where the fix went
2 timeout frames added to the Checkout file, which makes 10 states, so the design owns that copy. A Playwright test walks it.
Figma
Export
Code
Test
Found by
Playwright, mobile only. After tapping Pay with invalid fields, focus landed on the button, not the first invalid field.
Root cause
Event order. focus() ran inside submit and the tap's own focus ran after it. Desktop has a different order.
Where the fix went
Defer the focus move one frame. Code only. And run both widths from the start.
Figma
Export
Code
Test
Found by
Playwright, mobile. The tap blurred Expiry, the error text appeared above, the form grew, and the tap landed on nothing.
Root cause
Component design. A message line that appears on demand shifts everything under it.
Where the fix went
The Input reserves its message line in Figma and in code, and blur validation waits 150ms so a tap registers first.
Figma
Export
Code
Test
Found by
Visual QA. The radio had no dot, Apply sat 20px low, an icon was 24px where the frame says 20.
Root cause
Token architecture. Figma names spacing by step, Tailwind by multiple. The theme picked the wrong one, and any class outside the list produced nothing. No error, no pixel.
Where the fix went
Figma variables renamed by pixel value. The theme declares one 4px base. The guardrail fails any multiple that is not a Figma step.
Figma
Export
Code
Test
Found by
Visual QA while building this page. Measuring the Figma frame against the render at 390, every card sat 8px lower than the one before.
Root cause
The generation read the 1280 frame first and carried its spacing to 390. The frame uses 24 between blocks and 16 inside the form at 390, 32 and 24 at 1280. No note stated the 390 gaps.
Where the fix went
Code only: gap-6 lg:gap-8 on the screen, gap-4 lg:gap-6 on the form, Back to shipping centered at 390 as the frame has it. Snapshots regenerated. Still to do in Figma: write the 390 gaps into the breakpoint note.
Figma
Export
Code
Test
5 of 7 went back to Figma, 4 into the library and 1 as a new frame. F4 and F7 were code only.
The validation state at 390: three invalid card fields with messages, and the Pay button below.

1

2

3

1 · F4

F4 · Card number

After a tap on Pay, focus now lands on the first invalid field, this one, once the tap has finished.

2 · F1

F1 · Name on card

This placeholder text, and every helper line in the same color, measured 4.37:1 before the primitive was darkened.

3 · F5

F5 · Pay button

A message appearing on blur above this button is what pushed it out from under the finger. The Input now reserves its message line.

Figure 7. The validation state at 390, and where 3 of the 7 findings sit.

Before F6: the selected radio has no dot.
Before F6: the selected radio has no dot.

Before F6

After F6: the selected radio shows its dot.
After F6: the selected radio shows its dot.

After F6

Figure 8. Before F6 the selected radio had no dot, because spacing classes outside the theme were resolving to nothing. After: one 4px base, Figma steps named by pixel value, a guardrail on the multiples. Same crop, same scale.

The Text link component set: default, hover, focus, disabled.

Figure 9. Text link, the component F2 added to the library, in its 4 states left to right: default, hover, focus, disabled.

Anchal Nagdev

Work

Work

About

About

Contact

Contact

Resume

Resume