Visual context for AI agents: screenshots vs. element-level
A screenshot says what a page looks like; element context says where the code lives. When each is enough, and four checks to run first.
An AI coding agent gets a front-end edit wrong for one reason: it cannot tell which element you meant. A screenshot narrows the gap. Element-level context closes it.
Element-level context adds the file, the line, the tag, the class string, and the component that rendered it.
The first answers what it should look like; the second answers where to change it.
Why the edit lands in the wrong file
You point at one card and ask for a 12px radius. The agent reads the screenshot, finds a file called Card.tsx, changes it, and now every card in the product has moved. Nothing in the request was wrong. The agent simply had no way to know that the page rendered PricingCard and FeatureCard from the same base component, and that you meant only the second one.
This is not a reasoning failure you can prompt your way out of. It is a missing input.
What a screenshot actually carries
Pixels. A screenshot is exact about appearance and silent about everything else: which component rendered the element, which file it lives in, whether the spacing comes from a Tailwind class or a shared layout. The agent has to infer all of it, and inference is where it goes wrong.
Inference also gets worse as the project grows. In a 30-file prototype a guessed file is usually close. In a 3000-file product the same guess lands in a shared component that forty screens depend on.
What element-level context adds
Four facts, each of which removes one guess: the source file and line, the tag and its class string exactly as the DOM has them, the component source around that line, and the visible text that distinguishes this element from its siblings.
{
tag: "button",
class: "rounded-lg bg-black px-4 py-2 text-sm",
source: "src/components/CtaButton.tsx:24",
text: "Get started",
component: "function CtaButton({ children }) { ... }"
}None of this is new information to the browser — it is all already in the DOM. What is new is that it travels with the request instead of being reconstructed from a picture.
Screenshots and element context do different jobs
A screenshot is still the only way to carry visual intent. "This gap feels too tight" has no file:line representation, and an arrow drawn across two elements communicates a relationship no selector can express. Sending only one of the two hands the agent half the job.
When a screenshot alone is enough
- The page is new and has no components to conflict with — nothing shared can break.
- The change is purely visual and provably touches one element.
- You genuinely do not care which file gets edited, only that the result looks right.
Those cases are real, and for them a screenshot is cheaper. The moment the element lives inside a component that appears twice, the calculus flips.
A checklist before you send the prompt
Four questions, in the order that usually catches the mistake:
- Does the message contain a file path? If not, the agent will guess one.
- Is the class string quoted exactly as the DOM has it, or paraphrased?
- Can the agent distinguish this element from its siblings from the message alone?
- Is the visual intent attached — a screenshot, a sketch, or a concrete before/after?
Any "no" is where the edit will go wrong. Three or more is usually a rewrite rather than a fix.
How Curxor handles it
Curxor opens your running project in a built-in browser on macOS. You select an element, it resolves the source file and line locally, and the message you send to your agent carries that context plus the annotated screenshot. Parsing runs on your machine — code never passes through our servers. Claude Code and Cursor work out of the box, any ACP-compatible agent can be added, and a bundled MCP server exposes the same contexts to MCP clients.
It does not write code. The agent still does the edit, and you still read the diff.
Agents each have their own page, since what they are missing differs: Claude Code, Cursor, GitHub Copilot. If you just want the steps, start there instead.
Download it for macOS and try the checklist above on the next edit.
Questions this raises
Why does the agent edit the wrong file even when I paste a screenshot?
A screenshot carries no file path. The agent can see which element looks wrong, but it has to guess which component rendered it — and when that component is reused, one wrong guess changes several screens at once.
Does element context make the agent slower or use more tokens?
It adds a few hundred tokens: one file path, one class string, one component's source. That costs less than the loop it prevents — a wrong edit, a revert, and a second attempt with the same missing information.
Is this the same as a browser extension that jumps from an element to its source?
The jump is only half of it. A locator tells a developer where the code is; an agent needs that location plus the visual intent, packed into the request it receives. An agent cannot open your DevTools, so the context has to arrive with the message.