{"slug": "how-to-copy-screenshots-and-errors-to-coding-agents", "title": "How to copy screenshots and errors to coding agents", "summary": "A developer built a Claude Code UserPromptSubmit hook for their Mac app L2Cache that injects recent clipboard history—screenshots with OCR text, stack traces, and terminal commands, each labeled with its source app and age—into a coding agent's context so a prompt can be as short as \"fix this error.\" In testing, the agent opened the screenshot image itself only 6 times out of 70 prompts where a file path was supplied, relying on extracted text the rest of the time, cutting per-screenshot context cost from roughly 1,500 tokens to about 150.", "body_md": "**Ctrl+V pastes a screenshot into Claude Code. But by the time I ask for a fix I've copied three things from three apps. A prompt hook hands the agent all of them, so the prompt is just \"fix this error\".**\n\n**Key findings**\n\nHere's a bug report I used to write several times a day.\n\nThe export fails in the simulator. I take a screenshot of the alert. I switch to Chrome, open the console and copy the stack trace. I switch to the terminal, scroll up and copy the test command that failed. Then I go back to Claude Code and start assembling: Ctrl+V for the screenshot, then the stack trace, then the command, then a sentence explaining how they fit together.\n\nTo be fair to Claude Code, the pasting part works. On a Mac, Ctrl+V (not ⌘V, which is the terminal's own text paste) attaches the image on your clipboard to your prompt. But the clipboard only holds the last thing you copied. By the time I was ready to ask, the screenshot had been replaced by the stack trace, and the stack trace by the command. So either I went back and copied each one again, in order, or, more often, I didn't bother. I described the error in words, and the agent guessed.\n\nNow I copy things as I find them and type \"fix this error\".\n\n*Three copies from three apps, one short prompt. (Mockup: illustrative project and error.)*\n\nA coding agent knows two things: what's in your prompt and what it reads with its own tools. It can open any file in your repository, run your tests and read git history. It can't see your clipboard, the browser console you were looking at or the alert in the simulator. Everything you saw on the way to asking has to be carried across by hand.\n\nBut your Mac has already seen it. If you use a clipboard manager, every one of those copies is sitting in its history, with the app it came from and when. The missing step is getting the relevant few into the agent's context at the moment you ask.\n\n[Claude Code hooks](https://code.claude.com/docs/en/hooks) run a script at fixed moments, and one of those moments is just before your prompt is sent. A `UserPromptSubmit` hook can add text to the agent's context alongside your message. Codex has the same kind of hook.\n\nThat's where L2Cache, the Mac app I build, hands over what I've copied. When I type a prompt, the hook looks at my recent clips and adds a short, labelled block. For the bug above, the block looks like this (same illustrative example as the picture):\n\n```\nRecent clipboard items (read-only context; mention any that are relevant to your task):\n[1] [Simulator • 4m ago] screenshot | ocr: Export failed. The file \"report.csv\" couldn't be saved. | image: ~/Screenshots/export-failed.png\n[2] [Google Chrome • 3m ago] TypeError: Cannot read properties of undefined (reading 'rows') at exportTable (export.js:88)\n[3] [Terminal • 2m ago] npm test -- export\n```\n\nEach line says where the clip came from and how long ago, because that's half the meaning. A stack trace copied from Chrome a minute ago is probably the error you mean. The same text copied from Slack yesterday probably isn't.\n\nA screenshot is the one clip you'd think needs the image itself. Usually it doesn't. Most error screenshots are mostly text: an alert, a log, a console panel, a failing test in Xcode. So the hook sends the text found in the screenshot, a short title and, when the screenshot was saved to my screenshots folder, the path to the file. If the text is enough, the agent just uses it. If it needs to see the layout or a colour, it opens the file itself.\n\nIt turned out the agent almost never needs to. Of 70 prompts where a screenshot came with its file path, the agent opened the image 6 times. The other 64 times the text answered the question.\n\nThat matters more than it looks. A typical screenshot of mine costs roughly 1,500 tokens as an image. Its text, cut down to fit the hook's budget, costs at most about 150. And whatever enters the context stays there: it's resent with every later request in the session, and re-read in full after a break once the prompt cache has expired. (I measured what that costs in [a separate write-up](https://l2cache.app/en/claude-code-cold-session-tax).) Sending ten times less for the same answer adds up over a long session.\n\n**Screenshot as an image vs as text (my clips, Oct–Nov 2026)**\n\n|  | Image | Text + file path | \n|---|---|---|\n| Typical cost | ~1,500 tokens | ≤ ~150 tokens | \n| Agent can read the error text | Yes | Yes | \n| Agent can see the layout | Yes | If it opens the file | \n| Times the agent opened the file | n/a | 6 of 70 | \n\nI went through five weeks of my own Claude Code transcripts (October 7 to November 13) and counted what the hook actually passed along.\n\nThe prompts changed too. Among them: \"see the screenshot\", \"i copied the screenshots\", \"i copied the correct card, use this for the mockup\". None of those would mean anything to an agent on its own. With the clips attached, each one was a complete request.\n\nAnything a hook adds rides along on every later request, so a hook that dumps your whole clipboard into the context would make things worse, not better. Most of the design is about what not to send:\n\nThe agent doesn't need you to paste. It needs what you already saw.\n\nCtrl+V is fine for one screenshot. Real debugging is a trail of copies across three or four apps, and the clipboard forgets all but the last. Hand the agent the last few things you copied, small, recent and labelled, send screenshots as text with the file one step away, and \"fix this error\" becomes a complete bug report.\n\nCopy the screenshot (⌘⇧⌃4 copies a selection straight to the clipboard) and press Ctrl+V in Claude Code, not ⌘V. ⌘V is the terminal's text paste; Ctrl+V lets Claude Code read the image from the clipboard and attach it to your prompt.\n\nNot by itself. It only sees what you paste and what a hook adds to your prompt. A `UserPromptSubmit` hook can read your recent clips, for example from a clipboard manager, and add the relevant ones as context.\n\nUsually much cheaper. In my clips a screenshot cost roughly 1,500 tokens as an image and about 150 as text, and the agent needed the image itself only 6 times in 70.\n\nYes. Codex supports the same kind of prompt hook, and L2Cache installs the same one there, so both agents get the clips you copied.\n\n*More on what belongs in an agent's context, and what it should look up instead: [How I built shared memory for Claude Code and Codex](https://l2cache.app/en/coding-agent-memory-what-to-inject).*\n\n*Originally published at [l2cache.app](https://l2cache.app/en/copy-screenshots-errors-to-coding-agents).*", "url": "https://wpnews.pro/news/how-to-copy-screenshots-and-errors-to-coding-agents", "canonical_source": "https://dev.to/dinesh_rajendran_46fc29b4/how-to-copy-screenshots-and-errors-to-coding-agents-16o0", "published_at": "2026-11-13 02:08:43+00:00", "updated_at": "2026-11-13 02:19:34.479590+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "large-language-models"], "entities": ["Claude Code", "L2Cache", "Codex", "Google Chrome", "Anthropic", "OpenAI"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/how-to-copy-screenshots-and-errors-to-coding-agents", "markdown": "https://wpnews.pro/news/how-to-copy-screenshots-and-errors-to-coding-agents.md", "text": "https://wpnews.pro/news/how-to-copy-screenshots-and-errors-to-coding-agents.txt", "jsonld": "https://wpnews.pro/news/how-to-copy-screenshots-and-errors-to-coding-agents.jsonld"}}