Building Blocks
4 Min

Agentic Design Pattern: Visual Verification

When AI agents write your UI, check their work the way a person does: by looking at the page after the browser has drawn it.

Filed underAgentic Design PatternCoding AgentsUI Testing
4 Min Read
Building Blocks
On this page

In App Zoo, the product I'm building, coding agents write most of the screens. They write code that compiles, passes its tests, and still looks wrong: a name cut off mid-word, two buttons at different heights, a header that starts a few pixels off the title. I kept catching these by eye. So I built a camera: a checker that looks at each page after the browser has drawn it, at three screen widths, against about 110 written design laws.

The loop
  1. 01
    Draw
    Render every page in a real browser, at 1920, 1440 and 390 px.
  2. 02
    Measure
    Run each written law against the boxes, lines and colors on screen.
  3. 03
    Compare
    Count only what a change added, not what was already there.
  4. 04
    Judge
    The next full walk decides whether a fix held.

Everything below moves. Click through it.


Why it has to look at the drawing

Most of the defects you catch by eye don't show up anywhere in the code. A code checker reads the component and sees nothing wrong. The browser draws it and the name is gone.

Press the button
What a code checker reads
<Card>
  <Name>{person.name}</Name>
  <Role>{person.title}</Role>
</Card>
Code checker: looks fine
What the browser actually draws
Wilhelmina Okafor
Chief Operating Officer
The point: a name cut to “Wilh…”, a label breaking onto two lines, two buttons at different heights. All of them come from perfectly legal code. They only exist once a browser has laid the page out at a real width.

So the camera measures the drawing, never the source.


Be the camera

This is the core move, small enough to run right here. The page below has six planted mistakes. The checks are real: they measure the drawn page the same way the full laws do.

Be the camera

Below is a small Bills page with six planted mistakes. Pick a screen width, then run the camera. The checks really run in your browser: they measure boxes, line counts and colors, the same way the real laws do. Fix a mistake, run it again, and watch the finding clear.

app/bills · 1440 px wide
Run the camera to see what it finds at this width.
Try this: run it at 1440, then switch to Phone. Two new mistakes show up that the bigger screens never had: a label that wraps and a button too small for a thumb. That’s why every page gets drawn at all three widths.

The night shift

Every night, while I sleep, the camera walks every page of the development site. Nobody types the list of pages, and nobody grades their own fixes.

Press play, or click any step
3:15 am

It wakes from a fresh copy of the code

It never borrows a copy an agent is working in, so the laws it runs are always the ones everyone shares.

The rule behind it: no sweep verifies itself. A fixer saying “done” counts for nothing. The next night’s walk of every page is the judge, and its numbers are the only ones reported.

The camera on every preview

Before an agent opens a preview for me, the camera draws the pages it's about to show at all three widths. It also draws the same pages from the shared, current code. It only stops the preview for problems the change added.

Pick a case
This change’s page1 off-inset heading
vs
The shared copy of the same page1 off-inset heading
→
Preview opensThe old problem is carried along as a count. It doesn’t block the agent.

When the camera is wrong

An agent can report a false alarm, with a reason. Click to step through what that does.

1 reportThe law goes quiet on that page only.
2 reportsThe law goes quiet everywhere. It’s clearly misfiring.
Law’s code changedEvery quieting is undone. The fixed law has to earn trust again.
Why it compares against the shared code: without that comparison, every preview would be blocked by problems someone else left behind, and the camera would get switched off. It never runs during a deploy. It only stands between an agent and showing me something.

The laws are measurements

There are about 110 laws, and every one is a measurement written in plain words. Each law exists because I caught that defect by eye at least once. Here's a sample, by family.

Pick a family
Text cut off with no way to read itA name ends in “…” and nothing shows the rest.
A control’s label wraps to another lineA button’s words break onto two lines.
A KPI caption is longer than its boxMeasured at the box’s narrowest width.
Text beside text sits off its baselineTwo pieces of one row that don’t share a line.
A badge painted outside the status colorsPills must use the status palette.
A glossy gradient inside the productGradients belong to marketing pages.
Tuned for no false alarms: every law flags only the case it can’t be wrong about. It allows generous slack and has written exceptions for patterns I approved. Screenshot-comparison tools are commonly wrong 20 to 40% of the time, and teams stop reading them. Three earlier checkers of mine died exactly that way.

Who checks the camera

A law doesn't count until the camera has been shown it can fail it. Every law ships with a test page that has the mistake planted on purpose, and a clean twin.

A law's own test
Planted mistake
two buttons, 40px and 34px tall, side by side
Clean page
the same two buttons, both 40px tall
It passes only if it fires on the first and stays silent on the second.

And the camera's own numbers need the same suspicion.

Quick question
Over eleven days, the nightly count fell from 932 findings to 33. Did the pages get 96% better?

What it can and can't see

What it can see
  • Text cut off, wrapped or spilling out of its box
  • Things out of line, at the wrong height, overlapping
  • Colors that aren't the approved ones, read pixel by pixel
  • Missing headers, footers and summary states
  • Tables whose columns don't share the space evenly
What it can't see
  • A section, button or label nobody asked for
  • Whether a page was built from an approved recipe
  • A layout that's legal but wastes space
  • Pages and states the nightly walk never reaches
  • Anything taste-shaped that hasn't been written as a law

Two rules keep the whole thing honest. A law is not ratified until the camera can fail it. And no sweep verifies itself. I wrote both after finding defects by eye three nights in a row that the checks had reported clean. A checker that grades its own work always passes.