/ui:compare-ui-to-designfrom Diorama UI
Measures a rendered UI against a Figma or Paper design using pixel diffs. Exports references at 1x, reproduces exact state, and generates a visual diff report with wipe sliders.
Ships in Diorama UI. 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.
None: SKILL.md is the whole skill.
Eyeballing a screenshot is not a check. The first app built on Diorama
was 8–12px off on every section of its main screen, and nobody saw it until
a diff drew the difference in red. This is the method that found it, and the
script that runs it ships as the visual-diff registry item.
The loop: export → reproduce → diff → read the red → measure → fix → rerun. Never skip from "read" to "fix".
npx @bydiorama/ui add visual-diff
— the skill comes from the ui plugin, the script from the registry, so
install it even when the skill is already loaded. It lands at
scripts/visual-diff.mjs; its header documents every option.pnpm add -D playwright && pnpm exec playwright install chromium.design/references/ (or pass --refs); cases in
scripts/visual-cases.mjs (or --cases); the report folder visual/ goes
in .gitignore. Add "visual": "node scripts/visual-diff.mjs" to scripts.pnpm visual [case-id …] and open
visual/report.html — a wipe slider per case and the diff in red.deviceScaleFactor: 1; a 2× export
diffs as a different size, not as a mismatch you can read.target should be the element's own box. An export with an OPAQUE margin
(a frame background around the component) defeats that — give the case an
explicit refCrop: [x, y, w, h].CONFIG.links) so the report links back.get_screenshot with enableBase64Response for a reference (with
contentsOnly for a component); for a vector, use_figma running
await node.exportAsync({ format: "SVG_STRING" }) returns the SVG source.
Paper: get_screenshot (scale 1) for a reference; get_jsx returns an SVG
node's markup. A raster you need as an asset: crop it from a saved
screenshot — never retype base64 by hand.The diff is only as honest as the state behind it.
viewport = the frame's size; fullHeight for a frame
taller than the viewport.getByRole("dialog", { name: "Tags" })), never by coordinates: open the menu, tick the three rows,
type the text the frame shows. A state you set up by hand cannot be rerun.CONFIG.reset: clear storage, reload); hide dev
chrome the design does not draw (CONFIG.css); wait for fonts; let enter
transitions settle (settleMs). The script disables animations and the
caret at capture.A design tool and Chromium rasterise glyphs differently, so 0% never happens. The percentage only compares runs of the same case.
| What the diff shows | What it is |
|---|---|
| A red outline of every glyph | Font rasterisation. Not a defect — unless the outline is offset (then it is position) |
| A doubled element: two copies, red where they disagree | An offset. The gap between the copies is the error in px |
| A red block | A missing, extra or mis-sized part |
| A red band along one edge of the whole case | The two images differ in size — the console prints size ref … vs actual …. Fix the size first; everything below it shifts |
| Red arcs only at the corners of an element case | The export is transparent outside a rounded box, the app has page ground there. Ignore |
| A red line where a hairline should be | Stroke placement — see the strokes trap below |
Red says where; it does not say why. Before editing, hold two numbers:
// Playwright, in the reproduced state
const box = await page.getByRole("article").first().evaluate((el) => {
const r = el.getBoundingClientRect();
return { x: r.x, y: r.y, w: r.width, h: r.height };
});
…and the design's own layout values for the same node: Figma
get_design_context on the section (padding, gap, sizes); Paper
get_computed_styles plus get_node_info world coordinates. Subtract.
"The row is 126px and the frame says 124" is a fix; "it looks a bit tall"
is three wrong fixes. Measure the element, then its children, until the
delta lands on one property.
| Trap | Rule |
|---|---|
| A 0.5px border made a 124px row 125–126px | Figma draws an inside stroke within the box (check the stroke alignment in your tool); a CSS border adds to it. On a fixed-height box use an inset outline (outline-offset negative) or an inset box-shadow |
| Masking the red away | A mask (masks) is only for what the app cannot reproduce on purpose — a sticker menu drawn over a row, rows the frame does not draw — and every mask carries a comment saying why. A mask without a reason hides the next regression |
| An empty, collapsed element still pushed its neighbours | It is still a flex child, so the container's gap applies to it. Group it with its neighbour in a gap-less wrapper, or remove it from the flow |
| Text wrapped at a different word than the design | Check the text STYLE first — the frame used Body/12 where Body/13 was assumed — before suspecting the font or the renderer |
| "Fixing" a 1px hairline | Diorama's 1.5px hairline renders at 1px in Chromium at DPR 1, and Paper's canvas snaps it the same way. Compare at the same DPR, and check what your design tool draws, before changing a stroke |
| A case that passes on the second run only | An enter transition was still running. Raise settleMs for that case, or wait for the element's final state in setup |
| A component restyled until the diff is green | When the design and a Diorama component disagree on geometry, that is a design-system gap: style through className, and report it upstream rather than forking the component silently |
| A screenshot judged at 2× in a viewer | Zoom lies about subpixels. Judge from the diff at 1×, and from the measured numbers |
No new red blocks on the screens you touched; what remains is glyph outline and the masked areas, each with its reason. Paste the before → after percentages for the touched cases into the pull request — they show the direction, the diff images show the proof.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
visual-diff, pixel-diff, design-matching, ui-testing, diorama
npx claudepluginhub bydiorama/ui --plugin ui8 skills in this plugin
/animate-app-interactionsAnimate state changes in an app that consumes Diorama components. Use when a count, label, icon or list should animate, a transition does not replay, or an interaction must respect reduced motion./apply-effectsApply glass, grain, sheen, glow, shimmer, ink or shaders to Diorama components. Use when adding texture, emphasis, a gradient ground or a loading halo without changing the component API./build-demo-pageTurn a screen design into a scripted, interactive demo page. Use when storyboarding a UI walkthrough, animating a Paper mockup, or preparing component snippets and compositions for capture./design-componentDesign a component and its states before implementation, as a contract in code drawn in Paper or Figma. Use when turning references into a token-based spec, extending a component sheet, drawing motion frames or preparing a handoff./hydrate-componentsUse Diorama components in Astro, SSR and static exports. Use when deciding what must hydrate, composing compound components in an island, or debugging a control that looks right but does nothing./polish-interfacePolish an interface built with Diorama components. Use when spacing, radii, elevation, type, icon alignment, hit areas or interaction states look or feel wrong without a specific design frame to compare.Other plugins' skills for the same job