👁️ Why “seeing” your own work changes everything
In module 5.1, you saw why an agent’s front end comes out “generic”: it writes the code by looking only at the code, never at the result. It’s like painting a picture blindfolded — you know you moved the brush, but you don’t know whether you got the color, stroke, or proportions right. The code can be syntactically perfect and, even so, the rendered page (what actually appears on screen when the browser draws the HTML/CSS) can look bad, be broken, or miss what you asked for.
New here? Render is the process of the browser turning code (HTML, CSS, JavaScript) into pixels on the screen — it's the difference between "reading the recipe" and "tasting the finished dish." An agent that only reads the recipe never knows whether the dish turned out well.
The screenshot loop solves exactly this: it gives the agent a way to “taste the dish.” It writes the code, looks at the rendered result through a screenshot, compares it with what was requested, and makes corrections. Without this loop, the agent delivers on the first try and hopes for the best. With it, the agent iterates—repeats the cycle several times—until the result meets the goal. This is, by itself, the biggest lever for visual quality in this course.
💡 Main Concept
Without the loop, the agent is blind to its own visual result—it only sees text and code. With the loop, it gains a new sense: visual feedback on what it produced.
- •Blind: writes code → delivers it → you discover the defect later.
- •With visibility: writes code → sees the result → fixes it before handing it over to you.
✗ Without the loop
- ✗The misaligned button only appears when you open the page
- ✗Wrong background color, unreadable text — the agent “didn’t know”
- ✗Each fix becomes a new round of conversation with you
✓ With the loop
- ✓Agent spotted the crooked button and fixed it before calling you over
- ✓Contrast, spacing, and alignment come corrected
- ✓You only handle the final review, not the hunt for obvious defects
🔄 The 5 stages of the loop, in a circle
The loop has five stages that repeat in a circle — it’s not a straight line that ends, it’s a wheel that keeps turning until the result is good. Each complete turn is a iteration (a repetition of the same process, trying to improve a little each time).
Caption: the loop always runs in the same order — write, start the server, capture, compare, fix — and returns to the beginning (cyan arrow) until the “did it meet the goal?” question in the center gets a yes. Each complete cycle is an iteration.
🔍 Inside each stage
- 1. Write: the agent generates or adjusts the front-end HTML/CSS/JS.
- 2. Start local server: a program that runs on your own computer and displays the page as if it were a website — except only you (and the agent) can see it, at an address like
localhost:3000. - 3. Capture: takes a screenshot (an exact picture of what's on the screen at that moment) using browser automation—a program that controls the browser without you touching the mouse, opening the page and "pressing the button" to take a screenshot on its own.
- 4. Compare: looks at the screenshot alongside what was requested — the reference, the goal, the brand — and points out the differences.
- 5. Fixes: adjusts the code based on what it saw was wrong, and the cycle starts again at stage 1.
🔬 Take a look inside: what changes with each pass
On the first pass through the loop, the agent usually gets the overall structure right — the blocks are in the right places, the text is there — but misses details that only show up visually: tight spacing, poor contrast, elements "stuck" together. This is exactly the kind of mistake that goes unnoticed when reading only the code, but jumps out in a screenshot.
On the second and third passes, the agent is already fixing refinements: button alignment, font size on mobile (what changes when the screen is smaller — called responsive, when the layout adapts to the screen size), hover color (the visual effect when the mouse moves over a button). This incremental polish—small fixes, repeated—is what separates a “generic” result from an “almost professional” one.
Before (round 1)
- • "Subscribe" button cut off at the phone's right edge
- • White text on a light yellow background (illegible)
- • Title and paragraph crammed together, with no breathing room
Later (turn 3)
- • Button within the margins, with spacing on the sides
- • Contrast adjusted — dark text on a light background
- • Spacing between the title and paragraph; a layout that "breathes"
💡 Practical Tip
Always ask for at least two complete passes through the loop before considering it done. The first pass handles the obvious; the second is where the result goes from "works" to "looks professional".
🛠️ Build: requesting the loop in practice
In practice, you don't need to "teach" Claude Code to start a server and take a screenshot — it already has that capability when you ask. Your job is to make the request in a way that drives the full loop: give it the visual goal (the reference), explicitly ask it to run the server, capture, compare, and fix — and repeat until it matches.
Give the visual goal
Describe what the page should look like, or point to a reference (screenshot, website, brand image—covered in depth in module 5.5).
Explicitly ask for the loop
"Start a local server, take a screenshot, compare it with the goal, and make corrections" — without this clear instruction, the agent may go straight to delivery without visually checking.
Require repetition until it matches
Ask it to repeat the cycle until the result matches the goal — don't accept the first capture as "done".
Caption: the same sequence as the circular diagram, now shown as a timeline — the cyan arc at the top shows the cycle returning to stage 1.
📋 Copy-run block: asking for the complete loop
Objective: have the agent build a page and visually self-correct before handing it to you, using the full loop.
Crie a página <nome-da-pagina.html> com <descrição do que ela deve ter — seções, textos, botões>.
Depois de escrever o código:
1. Suba um servidor local nesta pasta (ex.: porta <3000>).
2. Abra a página e tire um screenshot da tela cheia.
3. Compare o screenshot com este objetivo: <descreva o visual esperado,
ou aponte a referência/imagem/marca a seguir>.
4. Se houver diferença (cor, espaçamento, alinhamento, texto cortado),
corrija o código.
5. Tire um novo screenshot e repita os passos 3-4 até o resultado bater
com o objetivo. Não pare na primeira tentativa.
Ao final, me mostre o último screenshot e liste o que foi corrigido em cada volta.
How to verify: ask the agent to list how many loop iterations it ran and what it corrected in each one. If it says "just one iteration, got it right the first time," be suspicious — ask it to show you the screenshot of the first and last attempts side by side.
🔍 Inside
Browser automation: a program that opens and controls the browser on its own — clicks, scrolls the page, takes a screenshot — without anyone needing to touch the mouse. It’s the “hand” that lets the agent capture its own visual result.
⚠️ Common mistakes that break the loop
The screenshot loop only works if you feed it the right information. The most common mistakes aren’t technical— they’re about how you make your request. Here are the two that come up most often.
✗ Mistake 1: vague objective
- ✗"Make it look good" gives the agent nothing to compare against
- ✗Without a clear visual reference, the comparison becomes the agent’s own opinion
- ✗Result: it “thinks” it matched, but you disagree when you see
✓ Fix
- ✓Describe the colors, text, sections, and expected behavior
- ✓Point to a reference screenshot or website when one exists (module 5.5)
- ✓The more concrete the goal, the more precise the comparison
✗ Mistake 2: thinking one pass is enough
- ✗Ask to "take a screenshot and show it to me" — without asking for a comparison and fixes
- ✗Accept the first screenshot as finished without checking the details
- ✗It's stuck halfway: you saw it but didn't fix it
✓ Fix
- ✓Explicitly ask it to "repeat until it matches" — not to "take a screenshot"
- ✓Require at least 2 iterations before considering it ready (topic 3)
- ✓Ask for the history of fixes made on each pass as proof
⚠️ Attention
This loop has limits — it doesn’t replace your final judgment or solve everything on its own. The specific limits (what it CANNOT see, when to stop trying) are the entire subject of the next module, 5.4.
✅ Checklist and exercise
Before considering any agent page “ready,” go through the checklist below. It summarizes the five stages of the loop as a practical check.
☑️ Screenshot loop checklist
- ☐I gave a concrete visual goal (not “make it look good”)
- ☐I explicitly asked to start a local server and capture a screenshot
- ☐I explicitly asked for a comparison between the screenshot and the goal
- ☐Require at least 2 loop iterations, not just one pass
- ☐I asked for a history of what was fixed each round
- ☐I reviewed the final result myself before approving it
🎯 Exercise
Choose a simple page (it can be a one-line landing page, like a "digital business card"). Ask Claude Code, using the copy-run block from topic 4, to:
- Create the page with at least 3 sections (top, middle, footer).
- Run the full loop — write, start the server, capture, compare, fix — at least 2 times.
- Show me a screenshot of the first and last attempts.
- List, in text, what changed between the two.
If the agent jumps straight to “done” without showing you both captures, the loop didn’t actually run—ask again and be more explicit.
Quick check (optional): why is the agent “blind” without the screenshot loop?