Vibe coding with Claude Code course ยท Module 4: Instagram clone
The Crow's Nest: a Screenshot as a Request and Claude in Chrome
In this lesson10
The gallery has a grid, a preview window, reactions, a skeleton and a search. So far you checked all of it yourself: you opened the browser, clicked, pressed Escape and looked. Claude sees the code and the results of commands, but it does not see the page itself. In this lesson you will give it eyes in two ways: a screenshot in the request and the Claude in Chrome extension, with which it opens the page and checks it on its own.
The problem: "it looks different" is not enough
In lesson 3_2 a sketch told Claude where you are sailing. When something already stands but not as in the mockup, the sketch alone is not enough. Claude does not know what is on the screen today, so it guesses what to fix, and often fixes the wrong thing. A second image is missing: a screenshot of the current state. The mockup and the screenshot laid side by side show the difference, and the difference is exactly the task.
A screenshot next to the mockup
Take the gallery header. Draw on a sheet of paper how it should look: the avatar on the left, the title next to it, and under the title the search field, like the button under the profile name on Instagram. Save the photo of the sheet as sketches/header.jpg, like the sketch in lesson 3_2. Then take a screenshot of the current page, the way you take screenshots every day, and save it as sketches/now.png. A request with two images looks like this:
Compare the mockup sketches/header.jpg with the current state
sketches/now.png. On the mockup the search field stands in the header,
under the title, and on the screenshot under the whole header, at full
width. Move it in @app/gallery/page.tsx like on the mockup; on a phone
it may stay under the header. Change nothing else. At the end run
npm run build and npm run lint.Each image has its role in the request: the mockup is the goal, the screenshot is today's state. Next to the images stand the things an image will not tell: what exactly should change, in which file and what not to touch. The sentence about the phone adds what a sketch of one screen will not show. Without those sentences Claude would fix everything that looked different on the screenshot than on the paper, including the colors you never drew.
When an image and when words
An image wins where a thing has to be seen because the code does not show it: layout, spacing, the order of elements, the look on a narrow screen, a caption that sticks out of a tile. The Claude Code documentation advises reaching for an image when a description in words would be unclear or long. Words win with logic and data. A like counter that jumps from 42 to 44 after a click is better described by the steps that lead to the bug and the result you expect than by a screenshot with the number 44. A good request often has both.
The image loop
One fix with an image rarely settles the matter. You work in a loop of five steps:
- You take a screenshot of the current state.
- You send a request with the mockup, the screenshot, one difference and a file.
- Claude makes the change, and you read the diff in Cursor.
- You check the page in the browser, also in a narrow window.
- You take a new screenshot and lay it next to the mockup.
If a difference remains, you go back to the second step with the new screenshot. One round is one difference: five fixes at once blur just like a long description. And when two rounds in a row miss, do not add a third patch. The Claude Code best practices advise /clear and a better request then.
Steps four and five you can hand to Claude. The same best practices list a browser screenshot next to a mockup among the checks Claude can run itself, like a build or a linter. It needs a browser for that, though.
Claude in Chrome
Claude in Chrome is a browser extension through which Claude Code controls Chrome. Claude opens tabs in it, clicks, types text, reads errors from the console and the state of the page, takes screenshots and saves them to disk, and even records the run as a GIF. The extension works in Google Chrome and Microsoft Edge, and in other Chromium-based browsers, for example Brave and Arc; it does not work in WSL. You need the extension from the Chrome Web Store and a Claude plan bought directly from Anthropic: Pro, Max, Ultra, Team or Enterprise (as of November 2026). Claude Code must be logged in through /login: with an API key the browser will not turn on.
You start a session with the browser in the Cursor terminal with a flag:
claude --chromeThe first time a window appears describing the integration and the permissions, which you approve with Enter. The /chrome command during a session shows the state of the connection (it works when you see "Status: Enabled" and "Extension: Installed"), lets you reconnect the extension and turn the browser on permanently with the Enabled by default option. I do not recommend that option at the start, because the browser tools then take up the context of every session. If you do not have the extension yet and you ask Claude to work in the browser, Claude Code itself will suggest installing it. In the Claude Code extension for VS Code the same is given by @browser in the request field.
Request for Claude Code: the window test
Run npm run dev in a second terminal and hand Claude a test you have been doing by hand:
Request for Claude Code:
Open localhost:3000/gallery, click the first photo and check whether
the window closes with the Escape key. Tell me which element has focus
after closing and whether the page scrolls again. Then look at the
console: I am interested in errors and warnings, not the whole log.
Do not fix anything yet, just report.Before the first action Claude Code may ask for permission with a window that starts with "Claude in Chrome wants to". For localhost you can allow all actions on that site until the end of the session. Claude opens a new tab in a visible Chrome window, so you watch it work live. The request says what to look for in the console, because the documentation warns that the full log can be very long.
What Claude found
In our project this test showed three things. Escape closes the window and scrolling comes back, so the effect from lesson 3_2 cleans up correctly. After closing, however, focus lands on <body>, that is, at the start of the page: a person who tabbed to the fifth photo starts over after every preview. In the console there was one warning:
Image with src "/images/kapitan.jpg" was detected as the Largest Contentful Paint (LCP). Please add the `loading="eager"` property if this image is above the fold.LCP (Largest Contentful Paint) is the moment when the largest element visible right after entering the page appears. Since lesson 3_4 the grid waits for the server, so the largest one is the avatar, and it loads lazily. The cure is loading="eager" on the avatar, like on the first row of thumbnails in lesson 3_1.
What Claude wrote: focus returns to the tile
You ask for both fixes in one request with a goal for each: "After closing the window, focus should return to the tile that opened it (@components/Gallery.tsx). The avatar in @app/gallery/page.tsx gets loading="eager". Then repeat the Escape and console test". Open components/Gallery.tsx. Above the gallery functions a ref and a closing function appeared:
const openerRef = useRef<HTMLButtonElement | null>(null);
const closeModal = () => {
setSelectedId(null);
openerRef.current?.focus();
};useRef from lesson 2_5 keeps a value between renders and does not make the component redraw. Here it holds the button that opened the window. ?. calls focus() only when some button is remembered. The window now gets onClose={closeModal}, so the cross, Escape and a click on the backdrop close it the same way.
The tile is saved at the moment of the click:
onClick={(event) => {
openerRef.current = event.currentTarget;
setSelectedId(photo.id);
}}event.currentTarget is the element the event handler is attached to, that is, the tile button, even when the click landed on the image inside. Likes, comments and the grid did not change. The second browser test gave us focus on the right tile and a console without warnings.
Captain's review: where it may click
Claude in Chrome works in your browser and, according to the documentation, uses its logged-in sessions: it will enter any site where you are logged in, also your mail or bank. That is both its strength and its risk:
- Only known ports. Send it to
localhostand to sites you trust. Anthropic's help advises starting with trusted sites and avoiding unknown ones and ones full of content from strangers. Instructions hidden on a page can trick it as if you were the one asking; this is called prompt injection. - A separate browser profile. The same help recommends a separate profile without access to sensitive accounts: bank, health, official matters. For the gallery tests a profile with only the extension is enough.
- Site permissions. You set site permissions in the extension settings. Give the permission for the whole session to
localhost, not to every site Claude visits. - You do the logging in. When Claude lands on a login page or a CAPTCHA, it stops and asks you to take care of it by hand. Never type a password into a request.
- Alert windows. An
alertwindow blocks the browser and Claude stops getting answers from it. Close it yourself and tell Claude to continue. - Recordings. A GIF saves everything visible in the window, also data from logged-in sites. Watch it before you send it to anybody.
Next step
When the review passes, ask for a commit, for example "Gallery: focus returns to the tile, avatar without lazy loading". Then close the image loop from lesson 3_2, this time without your own screenshots:
Open localhost:3000/gallery, click the first photo, save a screenshot
of the open window to disk and give me the file path. Compare the
screenshot with the sketch sketches/gallery.jpg and list the
differences. Do not fix anything.Some of the differences will be intended, because the likes and comments from lesson 3_3 were not on the first sketch. Pick from the list one difference that should not stay, and fix it with another round of the loop.
In the editor below waits a grid with a window and a switch for returning focus. Tab to a tile, open it with Enter, close it with Escape and see where focus lands with the switch and without it.
Remember: the mockup tells Claude where you are sailing, the screenshot tells where you are, and Claude in Chrome climbs to the crow's nest by itself to check; you decide over which ports it may look around.
Code for this lesson: App.jsx
// Focus after closing the window: does it return to the tile or jump to the top of the page?
// This is exactly what Claude in Chrome checked. Tab to a tile,
// open it with Enter and close it with Escape, with the switch on and off.
import { useEffect, useRef, useState } from 'react';
const photos = [
{
id: 'zachod-na-plazy',
src: 'https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=600',
alt: 'Waves on a sandy beach at sunset',
caption: 'We buried the chest here',
},
{
id: 'fale-z-gory',
src: 'https://images.unsplash.com/photo-1505118380757-91f5f5632de0?w=600',
alt: 'Turquoise waves at a white beach seen from above',
caption: 'The bay from the lookout',
},
{
id: 'zaglowka-noca',
src: 'https://images.unsplash.com/photo-1534447677768-be436bb09401?w=600',
alt: 'A small sailboat on a calm sea under a starry sky',
caption: 'Night watch',
},
{
id: 'palmy',
src: 'https://images.unsplash.com/photo-1519046904884-53103b34b206?w=600',
alt: 'Palm trees and a straw umbrella on a white beach',
caption: 'The island from the map',
},
];
// Description of the element that has focus now
function describeFocus(element) {
if (!element || element === document.body) return 'body, the top of the page';
if (element.dataset.caption) return 'tile "' + element.dataset.caption + '"';
return element.getAttribute('aria-label') || element.tagName.toLowerCase();
}
function PhotoModal({ photo, onClose }) {
useEffect(() => {
const handleKeyDown = (event) => {
if (event.key === 'Escape') onClose();
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [onClose]);
return (
<div
className="fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4"
onClick={onClose}
>
<div
role="dialog"
aria-modal="true"
aria-labelledby="photo-modal-title"
className="w-full max-w-md overflow-hidden rounded-lg bg-white text-gray-900"
onClick={(event) => event.stopPropagation()}
>
<div className="flex items-center justify-between p-3">
<h2 id="photo-modal-title" className="font-semibold">{photo.caption}</h2>
<button
type="button"
onClick={onClose}
aria-label="Close preview"
autoFocus
className="rounded px-2 text-2xl leading-none"
>
ร
</button>
</div>
<div className="relative h-56 bg-black">
<img
src={photo.src}
alt={photo.alt}
className="absolute inset-0 h-full w-full object-contain"
/>
</div>
</div>
</div>
);
}
export default function App() {
const [selectedId, setSelectedId] = useState(null);
const [returnFocus, setReturnFocus] = useState(false);
const [focused, setFocused] = useState('body, the top of the page');
const openerRef = useRef(null);
const selected = photos.find((photo) => photo.id === selectedId) ?? null;
// Read the focus at every Tab move
useEffect(() => {
const update = () => setFocused(describeFocus(document.activeElement));
document.addEventListener('focusin', update);
return () => document.removeEventListener('focusin', update);
}, []);
const closeModal = () => {
setSelectedId(null);
if (returnFocus) openerRef.current?.focus();
// Focus on body does not fire focusin, so we check it a moment later
setTimeout(() => setFocused(describeFocus(document.activeElement)), 50);
};
return (
<div className="min-h-screen bg-slate-100 p-4 text-slate-900">
<h1 className="mb-3 text-2xl font-bold">Treasure Gallery</h1>
<label className="mb-2 flex items-center gap-2 text-sm">
<input
type="checkbox"
checked={returnFocus}
onChange={(event) => setReturnFocus(event.target.checked)}
/>
Return focus to the tile that opened the window
</label>
<p className="mb-3 rounded bg-white p-2 text-sm">
Focus is now on: <strong>{focused}</strong>
</p>
<ul className="grid grid-cols-2 gap-1 sm:grid-cols-4">
{photos.map((photo) => (
<li key={photo.id}>
<button
type="button"
data-caption={photo.caption}
onClick={(event) => {
openerRef.current = event.currentTarget;
setSelectedId(photo.id);
}}
className="relative block aspect-square w-full cursor-pointer focus-visible:outline-4 focus-visible:outline-amber-500"
>
<img
src={photo.src}
alt={photo.alt}
className="absolute inset-0 h-full w-full object-cover"
/>
</button>
</li>
))}
</ul>
{selected && <PhotoModal photo={selected} onClose={closeModal} />}
</div>
);
}Spotted a mistake in this lesson?
Check yourself
Answer the questions from this lesson. Pick an answer to see right away whether it is correct.
1. You send Claude a mockup and a screenshot of the current page. What else should be in the request?
2. Claude in Chrome uses the logged-in sessions of your browser. Where do you send it?
These are 2 of 4 questions for this lesson. Solve the rest in the game.
Hands-on tasks in the game
- Vertical ordering
Order the steps of the image loop:
Tasks after this lesson
- QuestionQuiz: What to add to a screenshot
- Put in orderSorting: The image loop
- QuestionQuiz: Claude in Chrome and logged-in sessions
- QuestionQuiz: When a screenshot instead of a description
- QuestionQuiz: Focus after closing the window
- Project to submitSend Treasure Gallery to the mentor
- VideoModule summary