# Claude Code and Playwright: a screenshot review loop for better design

> Make your agent look at what it built. A three-pass loop with phone and desktop screenshots, a critique prompt, a fix prompt and a checklist for each pass.

Canonical page: <https://aymu.dev/blog/screenshot-critique-fix-loop>

Published 28 Nov 2026.

Claude Code writes a page and says it's done, but it has never seen it. It read the markup, not the result. That
gap is where most of the slop hides. A card wraps to three lines on a phone. A heading sits too close to its
paragraph. A button floats away from its form. You won't spot these in the code. You'll spot all of them in a
screenshot.

The fix is a loop. Run the site and take screenshots. Have the agent critique them against your rules. Fix the worst
problems, then take new screenshots. Three passes is usually enough to move a page from "generated" to "reviewed".

## What you need before the first pass

You need three things in place.

1. **A running dev server.** For an Astro site that's `npm run dev`, which serves on `http://localhost:4321` by
   default.
2. **A way to take screenshots from the terminal.** Playwright's CLI does this in one line. Install the browser
   once with `npx playwright install chromium`.
3. **Written rules to judge against.** Without them, the critique turns into "looks clean and modern". Your
   `CLAUDE.md` design rules are the right source. If you don't have any yet, start with
   [CLAUDE.md best practices: design rules Claude Code actually follows](/blog/claude-md-design-rules).

Then take two screenshots, one at phone width and one at desktop width:

```sh
mkdir -p .review
npx playwright screenshot --viewport-size "390,844" --full-page http://localhost:4321 .review/home-phone.png
npx playwright screenshot --viewport-size "1440,900" --full-page http://localhost:4321 .review/home-desktop.png
```

Add `.review/` to `.gitignore`. Claude Code can open PNG files with its Read tool, so the agent sees the same
images you do. You can also ask the agent to run these commands itself. That keeps the whole loop in one session.

## Pass 1: structure and hierarchy

The first pass ignores color and polish. It checks one thing: in five seconds, can someone tell what this page is
and what to do next?

![Three numbered passes with the first one highlighted: structure and hierarchy, then type and spacing, then the slop pass.](/blog/figures/screenshot-critique-fix-loop-1.png)

Paste this prompt:

```text
Read .review/home-phone.png and .review/home-desktop.png.
Critique the page for structure and hierarchy only. Ignore color and fonts for now.
For each problem, give: the section, what you see in the screenshot, which rule in CLAUDE.md it breaks,
and the smallest fix. List at most 8 problems, worst first.
Do not change any files yet.
```

The "do not change any files yet" line matters. If the agent critiques and fixes in one step, it may fix the first
two problems and lose track of the rest. Splitting the steps gives you a list you can read, cut and reorder.

Checklist for this pass:

- One clear headline above the fold at both widths.
- One primary action, visible without scrolling on desktop.
- Sections in the same order as the questions a visitor has.
- No section that repeats another in different words.
- On the phone screenshot, nothing side by side that should be stacked, and nothing cut off.

When the list looks right, send the fix prompt:

```text
Fix problems 1 to 5 from your list. Keep every change small and inside the existing components.
Then take both screenshots again with the same commands and tell me what changed.
```

## Pass 2: type and spacing

Now the page has the right shape. The second pass looks at what makes it feel cheap or expensive.

```text
Read the new screenshots. Critique type and spacing only.
Check against the type scale and spacing scale in CLAUDE.md.
Name any text size, line length or gap that is not on the scale, and say where it is.
List at most 8 problems, worst first. Do not change files yet.
```

Checklist for this pass:

- Body text line length between about 50 and 75 characters on desktop.
- Headings tighter than body text in line height, and closer to their own paragraph than to the section above.
- Gaps between sections clearly larger than gaps inside a section.
- No more than three or four distinct text sizes on the page.
- On the phone, body text at least 16px and tap targets that a thumb can hit.

If spacing problems keep coming back, it's usually because there's no scale at all. See
[Website spacing: the simple scale that stops a layout looking cheap](/blog/spacing-makes-ai-sites-look-cheap) for a short one to add to your
rules.

## Pass 3: the slop pass

The last pass looks for the patterns that make a site look generated. This is where a ban list really helps.

![A slop pass checklist, all ticked: one accent color, meaningful icons, a section that breaks the grid, real images, plain headlines.](/blog/figures/screenshot-critique-fix-loop-2.png)

```text
Read the new screenshots. Look only for these patterns:
purple or blue-to-purple gradients, glows, decorative blobs, emoji or sparkle icons used as decoration,
three identical feature cards, centered text everywhere, buzzwords in headings,
stock or abstract filler images where a product screenshot should be.
For each one you find, say where it is and what to replace it with. Do not change files yet.
```

A longer version of that list, grouped by category with a replacement for each item, is in
[AI slop website fixes: a ban list to paste into your AI agent](/blog/anti-slop-ban-list).

Checklist for this pass:

- One accent color, used for actions and data, not for decoration.
- Icons only where they carry meaning a label can't.
- At least one section that breaks the even grid.
- Real product images, or nothing.
- Headlines that say what the product does, in plain words.

![Medly template hero: a white headline over a doctor photo with small cards for stats and care notes](/blog/examples/medly.jpg)

*Example: [Medly](/templates/medly), a designed Astro template on Aymu.*

## Make the agent prove it looked

Sometimes an agent describes a screenshot from what it remembers of the code. You can catch this. Ask for details
only the image can give:

```text
Before the critique, tell me: the exact text of the main heading as it wraps on the phone screenshot,
and how many lines it takes.
```

If the answer doesn't match what you see, ask it to read the file again. It costs one turn, and it saves a round of
fixes aimed at a page that doesn't exist.

## Review one section at a time

Full-page screenshots of a long page get scaled down, and small problems vanish. When a page has more than five or
six sections, take screenshots of one section at a time. Playwright can screenshot a single element with a short
script:

```js
// .review/shot.mjs
import { chromium } from 'playwright';

const [selector, name] = process.argv.slice(2);
const browser = await chromium.launch();
for (const [label, width] of [
  ['phone', 390],
  ['desktop', 1440],
]) {
  const page = await browser.newPage({ viewport: { width, height: 900 } });
  await page.goto('http://localhost:4321');
  await page
    .locator(selector)
    .first()
    .screenshot({ path: `.review/${name}-${label}.png` });
  await page.close();
}
await browser.close();
```

Run it with `node .review/shot.mjs "#pricing" pricing`. This needs `playwright` installed as a dev dependency.
Now the agent can look at the pricing block alone, at full resolution.

## Know when to stop

Three passes is a good default. Stop early if a pass finds nothing worse than taste. If the same problem comes back
twice, stop and change your approach. That usually means the rule is missing from `CLAUDE.md`, or it's too vague to
follow. Write the rule down, then run the pass again.

Keep the screenshots from the first and last pass side by side. It's the quickest way to see if the loop helped, and
to spot a fix that made something else worse.

## The whole loop on one card

Copy this into a note and keep it next to your terminal:

```text
1. npm run dev
2. Screenshot at 390 and 1440 wide into .review/
3. Critique (one topic, max 8 problems, no edits)
4. Read the list, cut what you disagree with
5. Fix the top 5, then screenshot again
6. Repeat for: structure -> type and spacing -> slop
7. Same problem twice? Add a rule to CLAUDE.md
```

The loop is slow the first time and fast by the third. It also changes what the agent pays attention to. Once it
has looked at its own output a few times in a session, its next page tends to start closer to right.
