/uiverify:implement-figma-designfrom UI Verify
Converges code render to a Figma design image using UI Verify, sweeping section-by-section from top to bottom until the diff is eliminated. Use when building a page/component to match a provided design mockup.
Ships in UI Verify. 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.
You are building a page/component in code to match a design image (a Figma export or mockup screenshot). UI Verify sets that image as the story's baseline, renders your story in its own browser, diffs it against the design, and hands you back the delta. You converge until the delta is gone, and stop there. You do NOT accept - accepting would rebase the baseline off the design (see "Do not accept" below).
The flow: get the design PNG -> declare it as the story's baseline -> build the whole page once -> then
sweep top-to-bottom, locking one section at a time -> stop at the minimum. Every round renders only the
story you are building (uiverify check --target), never the whole Storybook.
Read "The section sweep" below before your second upload. It is the whole method. Four previous agents failed this task, all in the same way: they treated convergence as tuning a number instead of locking sections, and all four stalled between 2.5% and 5% and declared a floor that was not a floor.
These qualifications apply to the sweep and the historical examples below:
buildId that uiverify check prints
(Registered build <id>). A check build is addressable only by its id: commitSha and prNumber
resolve the branch's CI build, not your round.metrics.changedPct is a fraction. Display 100 * changedPct followed by %, alongside changed
pixels and canvas dimensions. For example, 0.01581616 means 1.581616%. The denominator includes
ignored areas and empty space; this is not a visual-similarity score or a ranking between designs.255 - gray applies to dark foreground on a white
background only. On dark/colored/gradient backgrounds, estimate the local background and measure
foreground contrast with the correct polarity. If segmentation is unreliable, mark the measurement
inconclusive and inspect the pair; do not certify a lock from it.If assets, reliable measurements, or the required native MCP remain unavailable, report incomplete with the blocker and residuals. Do not spend uploads on an unavailable input or describe an incomplete run as converged. Otherwise continue the sweep within the upload budget below.
You do not get to stop because the number "feels done". When the required inputs and tools are available:
sizeChanged is
false, every required asset is present, mask scope is explicit, and every remaining discrepancy has
an evidenced explanation. A centroid+ink pass or a small global percentage alone cannot establish this."1.09%, looks like AA, done" is not a stop condition - it is the exact sentence every failed run wrote while fixable geometry (a default button border, a nav row 1px off in tracking, a gradient word) was still lit on the page. If fixable errors remain and inputs/tools are available, keep going within the budget.
The evidence-pair gate. Before each upload after round 1, inspect and measure the current section
in the design baseline and the preceding UI Verify candidate. Use the matching render_diff_image views,
or download the original PNGs through get_diff and record their build/diff IDs, hashes, and crop window.
A URL request alone is not an image read. Reuse a baseline only after confirming its identity is unchanged.
The thresholded overlay alone is insufficient; original PNG pairs contain the same usable evidence
regardless of which native MCP retrieval method supplied them.
Log every round, and build the report ONLY from that log. Each round record: the section you were
locking, the diffResultId and pxPagination window you read, and the measured baseline-vs-candidate
numbers you acted on (headline: design 646 wide / render 631, -15 -> font-size 54->57). Your final report
must cite these per-round measurements. Never write a summary claim like "I read baseline and candidate at
each window" - a prior run wrote precisely that while its tool log shows one honest read in thirty rounds.
If a measurement is not in your round log, it did not happen and it does not go in the report.
The flatline trip. If the number moves less than ~0.05% across three consecutive uploads while
sizeChanged still toggles true, you are NOT near a floor - you are re-lighting the same glyph edges with
tracking nudges while an unmeasured box or section height sits untouched. Stop editing text and do a full
baseline/candidate sweep from the top to find the box you never measured.
This is not advice, it is the loop you run. It is how a person would do it with the design and the render side by side: "Does the very top look right? No - fix, fix, fix, upload, look again. Yes? Good, I never touch it again. Next block down. Does it look right? ..." all the way to the bottom.
baseline and candidate at exactly that window.LOCKED next to the block in your round log and move the cursor down one block. If no, go to 3.NOT LOCKED with its table (the rows still non-zero) in the log and move the cursor down anyway. Do not
spend a 16th on it. You return to it only after the last block, and only with budget left under 50.Rules of the cursor:
Did the two most recent runs do this? No. One swept top-down for rounds 1-12 with a loose lock (1-4px counted as locked), then abandoned the order. The other never had a cursor at all: from round 2 it alternated nav <-> footer <-> cards every round, declared "body locked" with "cards -3px, footer -3px, negligible", and finished with its nav links 3px low and a footer text row 19px too wide.
You need the design as a 1x PNG at the page's real canvas size (a 1200px-wide frame exports as 1200px wide, not 2400 or 1024). Get it in this order:
download_assets { fileKey, nodeId, defaultFormat: "png", defaultScale: 1 } and download the export
URL into the repo (e.g. .storybook/public/design/page.png). Take fileKey and nodeId from the URL
(node-id=12-34 -> 12:34); if the link has no node-id, ask for a link to the frame itself. If you
use get_screenshot instead, pass maxDimension at least the frame's longer edge (its default of 1024
silently downscales a page), and confirm the PNG's size equals the frame's original_width x
original_height.If the Figma MCP is connected, get_design_context on the same node gives you the design's own values
(font family, sizes, weights, colours, spacing). Use them for the first build. They are a starting point:
UI Verify's diff against the PNG still decides what matches.
Once per project, before the first upload:
triage-visual-changes skill, "Connect the MCP"). If its
tools are not in your session, stop and tell the user; the MCP connects at session start.Then:
On the story, declare the design image:
parameters: { uiVerify: { baselineImage: "<path-or-data-uri>" } }. The key is uiVerify
(camelCase). The value is either a bundle-relative path to a PNG that ships inside your built
Storybook (a staticDirs asset, e.g. "design/hero.png"), or a data:image/png;base64,... URI.
PNG only. No http(s)/file: URLs, no absolute paths, no .. - the image has to live inside the
artifact you upload.
In a Vitest browser-mode project instead (@uiverify/vitest 1.3+, uploaded with uiverify 1.7+),
import the PNG next to the test and pass it to the snapshot:
import design from "./design/hero.png" then await takeSnapshot("", { baselineImage: design }) (pass
the import as-is, even where it resolves to an object). The SDK ships the image inside the archive. The snapshot is the whole page at the browser viewport width, so set the Vitest browser
viewport to the design's canvas width. Each round is
rm -rf uiverify-archive && vitest run <the design's test file>, then
uiverify check --static-dir ./uiverify-archive in place of the Storybook build + check below. Running
only that test file makes the archive the render set, so it needs no --target (clearing the archive
matters: the SDK never deletes old files, so a test you renamed or removed, or one an earlier full run
captured, would still be uploaded from the previous round).
Mark an explicitly excluded dynamic region (a video, an autoplay animation, a live/random
background) with the
data-uiverify-ignore attribute. UI Verify blanks that box on both the design and your render, so its
noise never counts. The whole bounding box is blanked, so keep critical foreground text out of it.
Match the design's canvas width and fonts. If the design was drawn at 1200px, build at 1200px; if it uses a specific font, self-host it (ship the woff2 in the bundle) so text metrics match. Without the exact font, every line of copy diffs.
Each round is a commit plus a check that renders only the story you are building. Commit first so
the round log can name the commit, build Storybook, then run uiverify check with --target set to the
design story's id. Each check is one upload in the budget below. This is a local loop; it needs no pull
request and no CI:
git add -A && git commit -qm "attempt N: <block>: <change>"
npx storybook build -o storybook-static # or your repo's build script
UIVERIFY_API_KEY=uv_proj_... npx uiverify check --static-dir ./storybook-static --target 'pages-profile--default' # the repo's own uiverify (npm i -D uiverify)
The story id is in storybook-static/index.json (a target that matches nothing fails the check and
lists the valid ids). For a design with several frames (desktop and mobile stories), pass --target
once per story, or one glob over just that component ('pages-profile--*'). Never uiverify upload
the whole Storybook per round: it re-renders every other story in the project (every button variant,
every unrelated page) each time, so each round waits on renders that say nothing about the design. A
check still diffs against the declared design, posts no GitHub check, and never moves a CI baseline; the
full uiverify upload runs in CI on the pull request.
mcp__uiverify__* MCP tools. Never compute
a diff yourself (no pixelmatch/resemblejs/odiff/ImageMagick compare, no PIL subtraction).storybook-static yourself, never open your page in
Playwright or any browser, never screenshot it, never read your own DOM (getBoundingClientRect, Range
metrics). The only view of your render that counts is the one UI Verify renders. A DOM box is not the
inked pixels: one run measured its own DOM, declared "every property matches within 1-2px", and accepted a
page whose buttons were 20px too wide and whose card row was 15px too tall.baseline / candidate PNGs UI Verify returns (get_diff URLs). Widths, heights, row tops, colors.
That is measuring, not diffing, and it is the most effective thing you can do (see "Measure, do not
eyeball").get_build returns the NUMBER, not the diff. You are FLYING BLIND until you view the pixels.After the first whole-page upload, stop thinking about the page and think about one section at a time, from the top down.
Why top-down is not just tidy: in ordinary flow layout a height/gap fix in section k moves sections k+1…N and usually leaves everything above it alone, so sweeping downward keeps most of what you finish finished and gives you a simple reading of inherited drift: if everything above section k is locked and section k's contents are uniformly N px off, the first suspect is the gap immediately above this section, not the elements. It is a heuristic, not a guarantee - a shared style, a font-size change on a reused class, or a width change that re-wraps text can reopen a block above. When a fix touches anything shared, re-fill the tables of the blocks that depend on it.
The loop:
render_diff_image which:"baseline" and which:"candidate"
at the same pxPagination offset/height, plus which:"diff" for the overlay. Never the overlay alone -
see "The overlay lies about low-contrast edges".Budget: locking a 2000px page is ~7 sections, and ~2 uploads per section is the floor of effort, not a target you stop at. You have a 50-upload budget overall and 15 per block (see "The algorithm") - spend it driving each block to zero rows, not stopping the moment the overlay looks calm. Under-using the budget is how runs stall: the last three stopped at uploads 30, 25 and 23 with measurable geometry still on the page.
The strongest technique available to you: measure the design once to get the absolute y of every section boundary (and the absolute x of every column), then measure the same anchors in your candidate and solve for the property.
design divider is at y=1810; my CTA bottom is at 1748 and my current margin is 29, so I compute 1777; to hit 1810 I need margin-top = 62.
That is a derivation, not a guess. Do this instead of nudging.
But it only works top-down and one section at a time. That arithmetic is a chain: if you also change something above the CTA in the same round, the CTA bottom moves and your footer number is already wrong before it lands. A previous run computed exactly the footer margin above, changed the card padding in the same upload, and went 3.42% -> 4.72%.
And match each section's OWN HEIGHT, not only where it lands. Absolute anchors alone can be satisfied by cancelling errors: a card row 15px too tall plus a margin below it 8px too small, a preview band 11px too short plus a gap 12px too big. Every later section lands at roughly the right y, the overlay looks calm, the % stays low - and the structure is wrong. For every section check top, bottom AND height against the design.
sizeChanged: true means you are not done. If the candidate's height differs from the design's, some
section's height is wrong. Keep going - never treat it as done.
which:"diff" highlights per-pixel differences above a threshold (often ~0.06). A low-contrast element -
a near-white pill on white, a pale card fill, a light divider - can be displaced by tens of pixels and still
not trip the threshold, while the dark text inside it lights up green.
The overlay then tells you the exact opposite of the truth: "the box is fine, only its text moved." In one run a badge pill was 35px too wide (12%) and showed zero highlight on its outline; the agent read the clean outline as proof the pill was correct and called the green text "AA fringe".
Therefore: never judge a section from the overlay alone. Always also read baseline and candidate at
the same window. A box that looks clean in the overlay can be the most wrong element on the page.
Eyeballing produces "the buttons look a bit off", which leads to nudging. Measuring produces "+3px tall, +9px wide", which leads to a padding fix. Pull spans out of the images with a script:
font-size / letter-spacingpadding / line-height / font-sizeline-height error. These look identical in
an overlay and are told apart only by the numbers.Work out which dimension is wrong before changing anything:
font-size first, then letter-spacing. font-weight is a last guess, not a first - but it is NOT
"never": if the bundle ships that weight AND an ink-density measurement (see "Measure ink, not boxes")
shows the glyphs carry more/less ink than the baseline at the same width, weight IS the fix (a header
wordmark that was horizontally dead-on was still +9% ink - 700 vs the design's 600). Asking for a
weight the bundle does not ship changes nothing and proves nothing, so confirm the woff2 is loaded first.padding or an internal gap.padding / explicit width / line-height.line-height.includeAA:false and threshold
0.063: pixels it classifies as anti-aliasing are already discarded before the count. So a lit edge has
survived the AA filter, and you may call it AA only after the element's row reads 0 (see "The element
table").If a fix does not work, change DIMENSION, not magnitude. Both failed runs got stuck turning the same
knob harder. One saw the two hero buttons differ, decided the gap between them was wrong, tried 16->20px,
saw the number rise, and concluded "sub-pixel artifact". The buttons were in fact 3px taller and 9px wider -
a padding bug it never tested, because it never left the "gap" hypothesis.
Bounding boxes round to whole pixels, so they go blind exactly when you get close. A header run stalled at 0.90% because every element's bbox was "within 1px" - it called that the AA floor. It was not. Whole-pixel bboxes cannot see the two things that dominate the last mile, and a switch of measurement (not effort) took it 0.90% -> 0.125%, a 7x drop, all real fixes:
sum(x * ink) / sum(ink) where
ink = 255 - gray only for dark foreground on white, with background-aware segmentation elsewhere.
Compare baseline and candidate; it can resolve shifts below 1px. Test a fractional
transform, e.g. translateX(-0.15px) on the group. Horizontal sub-pixel nudges work.font-weight 700 vs the design's 600, +9% ink; weight 600 fixed
it. Centroid+ink also exposed a logo mark that was un-rotated by ~5deg (same total ink, shifted centroid +
wrong outline). None of this is visible to a whole-pixel bbox or to the eye.The rule: when every bbox reads "within 1px" but the window still lights up, your ruler is too coarse - switch to centroid+ink (with correct foreground segmentation) before you conclude anything. The gain comes from a sharper measurement, not from turning a knob harder (which is the number-chasing trap).
Validate sub-pixel experiments. Compare the UI Verify candidate images or their pixel-content hashes; an unchanged changed-pixel count does not mean the images are identical. Establish whether a fractional CSS adjustment affects this element in this capture environment rather than assuming universal snapping. Neither an unsuccessful adjustment nor matched centroid/ink proves cross-engine AA. Keep an unexplained residual unresolved, and use the final visual sweep to catch shape, wrapping, border, and spacing errors.
Cap pxPagination.height at ~400. A page-tall slice averages everything into a grey wash where real
geometry is indistinguishable from anti-aliasing. One run paged at height: 1019, looked at the result, and
wrote "the page is now dominated by thin AA fringe" - at that zoom, a 13px footer displacement and a 35px
pill error both look like fringe. It then accepted.
For the block under the cursor, produce this table every time you read the pair. It is the only form of "looks fine" you are allowed:
| element | design x0-x1 / y0-y1 | render x0-x1 / y0-y1 | dW | dH | dx | dy | colour D / R | centroid / ink | fix |
|---|
One row per text run, box, pill, icon, divider, image edge. Measure with PIL on the two PNGs UI Verify
returned (bbox by a threshold that suits the background - dark pages need >40, not <170; centroid and
ink for rows already at 0). The table goes in the round log verbatim, and the report is built from these
tables and nothing else.
What the table stops you from doing: writing "footer within 1px" next to a row that says +17. One run's final explanation attributed a footer tagline to "cross-engine AA"; the row reads dW=+17 (font-size). Another explained a row of small footer links as "small low-contrast text trips the threshold"; the row reads dW=+19, dx=-10, colour 138 vs 61. Neither builder had a table, so the sentence won.
You may use the words "cross-engine AA", "baseline snapping", "rasterizer", "threshold noise" or "floor" for an element only when its row is 0/0/0/0, its colour matches, its centroid is within 0.3px and its ink within 3% - and you cite that row. Anything else is a fix you have not made yet. Two corollaries:
A section is done when, reading baseline and candidate at that window, no element appears as a
displaced second copy, and no box differs in measured width or height. "It looks like AA now" is not a
stop test - it is the sentence every failed run wrote just before quitting.
Bbox-clean is necessary but NOT sufficient. Whole-pixel bounding boxes are blind to sub-pixel position and to ink density (weight/size). If every box reads "within 1px" but visual discrepancies remain, investigate further with a valid centroid+ink pass ("Measure ink, not boxes") on each element before you declare a floor. A header that stopped at 0.90% this way had a +9% wordmark weight, a 5deg-un-rotated logo, and two sub-pixel offsets still on it.
The page is converged only when every section passes the stop test, sizeChanged is false, required
assets are present, ignored content has the agreed scope, and the final original-image sweep has no
unresolved visual defects. Record any supported rendering tolerance and its evidence. There is no fixed
AA percentage that proves this. Stop and report the final changed-% without accepting. Otherwise continue
within the budget, or report incomplete with the remaining discrepancies and any missing dependencies.
Never call accept_build (or review_diff with an accept) on this task. UI Verify diffs against the
design only while the design is the baseline. Accepting replaces the baseline with your render (accepting
a check build does it too, for every later check on the branch), which (a)
hides every remaining design delta forever and (b) makes every later upload diff against your render, not the
design. A prior run accepted at ~2.8%, then a fresh session re-uploaded against that accepted render, saw
~13% "drift", and spent 20 rounds polishing a phantom against its own snapshot instead of the design. Leave
the build changed at its floor - that is the finished state, and it keeps the project reusable without
recreating it.
Confirm you are still diffing the DESIGN, every round. get_diff must report hadBaseline: true, and
render_diff_image which:"baseline" must still show the design, not an earlier render of yours. If either
fails, STOP and tell the user - the branch was accepted or the baseline failed to resolve, and the number
is now measuring your render against itself.
Use the native mcp__uiverify__* tools - they return inline images you read directly. If they
are not available in your session, stop and tell the user. Do not fall back to curl against the MCP
endpoint: the MCP connects at session start, and the fix is connecting it and starting a fresh session.
(Downloading the PNG URLs that get_diff returns is fine - that is how you measure.)
get_build { buildId } - the build's changed stories, each with a diffResultId and changedPct.
The number only. Never your last call before a decision. Use the id check printed (see "Evidence
integrity").render_diff_image { diffResultId, which: "baseline" | "candidate", pxPagination: {offset, height} } -
your primary pair. The design and your render at the identical window. This is what you measure, and
it is the only view that is honest about low-contrast geometry.render_diff_image { diffResultId, which: "diff", pxPagination: { offset, height } } - the overlay for
the same window; good for spotting that something moved, unreliable for what. Height <= 400.render_diff_image { diffResultId, which: "before_after" } - baseline and candidate side by side,
auto-cropped to each changed region. Excellent for a fast survey - use it after every upload, not just the
first few. (Both recent runs used it 4 times out of ~40-50 image calls, and never after round 10.)get_diff { buildId } - presigned URLs for the baseline/candidate/diff PNGs. Download these when you
want to measure spans with a script.accept_build / review_diff - do NOT use these on this task. Accepting rebases the baseline off
the design (see "Do not accept"); this is converge-and-stop, not accept.Read references/anti-patterns.md before you declare a floor, call a block locked, or stop. Each entry there is a real run that failed this task.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub uiverify/uiverify --plugin uiverify10 skills in this plugin
/bun-visual-testingMake @uiverify/bun captures deterministic so Bun visual tests (bun test driving Chrome through Bun.WebView) stop coming back "changed" without a real change (flaky diffs). Use when setting up or debugging visual tests written with @uiverify/bun, on a real page of your running app (run() with webServer) or on a component page served by serveBundle(). Focuses only on the run-to-run variation the SDK can't neutralize from outside your app — above all live/dynamic data, the highest-value step (freeze it with fixtures or page.route and the whole content-noise class disappears), plus the clock, infinite JS animations, non-Math.random randomness, fonts a measuring component reads before they load, and the Bun-specific setup traps./check-visual-changesCheck the visual impact of an edit mid-task with `uiverify check` — render just the components you're touching on the UI Verify fleet and diff them against the real CI baseline, without opening a PR, posting a check, or moving a baseline. Works for every capture method (Storybook, Playwright, Vitest and Bun archives, and raw screenshots). Use when a coding agent has changed UI and wants a fast, authoritative "would this pass" answer before pushing — "check my visual changes", "did I break anything visually", "preview this diff", "run uiverify check". Hands off to triage-visual-changes for the pixel review./economical-visual-testsAuthor economical visual tests — full visual coverage in the fewest billable snapshots. Applies to any per-snapshot visual tool (UI Verify, Chromatic, Percy, Playwright screenshots), which all bill and diff per rendered story/test. Use when a component's variants/states are exploding into one snapshot per combination, when the visual-testing bill or noise is driven by snapshot count, or when writing new stories/captures and you want the cheapest layout that still covers every variant. Covers gallery/matrix stories, data-driven states, and the coarse-granularity tradeoff./making-ui-changesRead before changing any component, page, or styles. Six moves to change UI without silently breaking another screen - pick up open review notes, reuse before you create, cover every state, check the blast radius, prove it with a visual test, kill flake at the source./playwright-visual-testingMake @uiverify/playwright (archive-replay) captures deterministic so real-page visual tests stop coming back "changed" without a real change (flaky diffs). Use when driving a real page — your app under test, a staging build, or live production — and the diff flakes. A symptom-to-lever checklist for the run-to-run variation you probably have - feature flags, live data, the clock, third-party widgets, and dynamic layouts. The lever is almost always "stop the variation at record time" — the archive bakes in whatever the page was./setup-visual-testingSet up UI Verify visual regression testing in a repo end to end — pick the capture path the same way the one-line setup does (Storybook stories, a Playwright suite, Bun visual tests, Vitest browser-mode component tests, or uploaded screenshots), install the uiverify CLI and wire it into CI, and author the first stories the economical, deterministic way from the start. Use when adding visual/screenshot regression testing to a project for the first time, wiring UI Verify into CI, or onboarding a repo that has no visual tests yet.Other plugins' skills for the same job