Topic 1 of 4 · 4 min read
Giving agents designs and screenshots
Goal: Prepare a UI task with a screenshot, tokens and component references so the agent matches the design system.
A screenshot tells an agent what the result should look like; it does not tell it which components, tokens and spacing rules to build it with, so you must send both. Claude, GPT models, Gemini and the agents built on them (Claude Code, Cursor, Copilot) can read images. They read them the way a person glances at a photo: the layout and mood are right, the exact values are guesses.
Check yourself · 1 of 3
You give a coding agent a screenshot of a card and nothing else. What will it most likely get wrong?
Why it matters
An image has no measurements. The agent sees "a blue button" and picks a blue. It sees "some padding" and picks 16px. Ten such guesses later, the page looks close and is wrong everywhere, and none of it uses your design system.
How to build the input
- Send the picture. One screenshot or mockup per task, cropped to the part you want built. A full-page image with five features invites the agent to build all five.
- Add the numbers as text. Give colors, font sizes and spacing as design tokens (named values such as
color.brand.600orspace.4), exported from your design tool or read from the tokens file in the repo. Names beat hex codes, because the agent can then reuse the token. - Name the parts to reuse. Point to the files: "use
ButtonandCardfromsrc/components/ui". - State the states. The picture shows one moment. Say what happens when the list is empty, loading or failed.
- Say what to ignore. Placeholder photos, sample names and lorem text are not requirements.
Before and after
Weak prompt, with a screenshot attached:
Make this pricing page.
Better, same screenshot:
Build the pricing cards in the attached image as PricingCard in src/features/pricing.
Use Card and Button from src/components/ui and tokens from src/styles/tokens.css.
Do not add new colors. Three cards, stacked below 640px. The sample prices are placeholders; read them from props.
What goes wrong
- Misread detail. Models mistake similar icons, miss thin borders, and read small text wrongly. Anything that matters, such as a price or a label, goes in as text.
- Pixel guessing. Asked for "pixel perfect" from an image alone, an agent invents values that look plausible.
- Stale design. The mockup is two sprints old and the live component already changed. Say which one wins.
- Hidden state. A mockup with a hover or error state in a corner is easily ignored. List states in words.
Examples
A task with picture, tokens and parts
You attach settings-mockup.png and write:
Build the notifications panel from the image.
Reuse Switch and Panel from src/components/ui.
Colors and spacing only from src/styles/tokens.css.
Labels (copy exactly): "Email me", "Weekly digest", "Push on mobile".
States: loading shows skeleton rows; a failed save shows an inline error under the switch.
The image sets the layout. Everything the image cannot say is in the text.
A design-tool export as input
Export the frame from your design tool as an image and the variables as a tokens file, then commit the tokens file. The agent reads the file for exact values and the image for arrangement. When the file and the image disagree, tell the agent which one is the source of truth.
Key points
- An image gives layout and mood but no measurements, so the agent guesses colors, sizes and spacing.
- Send tokens and component paths as text next to the picture; names such as space.4 let the agent reuse your system.
- Crop to the one part you want built, and say which sample content in the image is only a placeholder.
- Anything exact, such as prices, labels and legal text, must be given as text because models misread small details in images.
- Describe the states a still picture cannot show: hover, focus, loading, empty and error.
Common mistakes
- Attaching a screenshot and a one-line prompt, then being surprised that colors and spacing are invented.
- Pasting a whole page mockup when only one component is wanted, so the agent builds extra things.
- Leaving copy inside the image only, so a misread word ships as the label.
- Not saying whether the mockup or the existing design system wins when they differ.
Check yourself · 2 of 3
Which addition to a screenshot task helps the agent stay inside your design system?
Check yourself · 3 of 3
A mockup shows a button labelled "Subscribe". The real label must be "Start free trial". Where should that go?
Practice items, not counted towards your mastery.
Start here
- Playwright MCP server (Microsoft) (opens in a new tab)ToolFree
The common way to let an agent drive a real browser and take screenshots.
- Chrome DevTools MCP (opens in a new tab)ToolFree
Gives an agent console, network and performance data from Chrome.
- WCAG 2 Quick Reference (W3C) (opens in a new tab)StandardFree
The accessibility success criteria to check agent-built UI against.
More for this topic
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
Includes the advice to give the agent images and a way to check its work against them.
- Design Tokens Community Group (opens in a new tab)StandardFree
The shared format for naming and exporting design values that tools and agents can read.