The precision prompting cheat sheet: files, lines, symbols
"The login page is broken" is a search query, not a bug report, and search queries sometimes find the wrong login-looking code. I build Settl, an expense-splitting app, solo with Claude, and the biggest jump in its output quality came from a change in my input: name the file, name the function, name the line.
What vague actually costs
Give a vague description and the model has to guess where the problem lives. So it searches.
Sometimes the search lands on the right code. Sometimes it lands on LoginForm.tsx when the
bug is in src/auth/login.ts, and you get a confident, well-written fix to code that was never
broken. You review it, it looks reasonable, you merge it, and the bug is still there.
The model did not fail. The prompt made it gamble. Every piece of location you leave out is a die roll you are asking it to win.
The anatomy of a precise ask
Three parts, every time. Location, behavior, expectation:
In src/auth/login.ts, validateToken, around line 40: it rejects tokens that
should pass. A token issued 2 seconds ago fails with TOKEN_EXPIRED.
Expected: freshly issued tokens validate. I suspect the expiry comparison
doesn't allow for clock skew.
- Location: file, symbol, rough line. "Around line 40" is plenty; it anchors the search even if the file drifted since you last looked.
- Behavior: what actually happens, observed, with the real error string if there is one.
- Expectation: what should happen instead. This is the part people skip, and it is the part that stops the model from "fixing" behavior that was intentional.
The suspicion at the end is optional but free. You are allowed to be wrong in it; a wrong hypothesis with a right location still beats no hypothesis and no location.
The rewrite table
Five vague asks and their precise versions:
| Vague | Precise |
|---|---|
| "The login page is broken" | "In src/auth/login.ts, validateToken around line 40 rejects fresh tokens with TOKEN_EXPIRED. A token issued 2 seconds ago should pass." |
| "Make the API faster" | "GET /api/orders takes 4s. In src/routes/orders.ts, listOrders runs one query per order for line items. Batch it; target under 300ms." |
| "The form doesn't work on mobile" | "In src/components/CheckoutForm.tsx, below 700px viewport height the keyboard covers the submit button and the container doesn't scroll. It should stay reachable." |
| "Add better error handling" | "In src/lib/api-client.ts, request() throws raw fetch errors. Wrap them in an ApiError carrying status and url, and retry 5xx responses twice with backoff." |
| "Clean up the utils file" | "In src/utils/date.ts, formatDate and formatDateTime share most of their body. Extract the shared logic. Keep both public signatures unchanged." |
Read the left column out loud and you can hear the gamble in each one. Which API? Faster how? Better by whose definition? The right column removes every die roll.
Don't know where the code lives? Ask for that first
Precision does not require you to know your codebase by heart. It requires you to split one vague request into two precise ones. First, locate:
Where does the password reset flow live? List the files and main functions
involved, in order. Don't change anything yet.
Then aim, using what came back:
In src/auth/reset.ts, sendResetEmail: the token in the email link expires in
10 minutes. Make it 60, and reject reuse of a token after a successful reset.
Two small prompts beat one big vague one every single time. The locate step costs thirty seconds and converts you from someone guessing about their codebase into someone pointing at it.
Referencing code Claude hasn't read yet
You can see your editor. Claude cannot. Two fixes:
- Name the path and say read it first. "Read src/hooks/useCart.ts, then tell me why totals recompute on every render." In Claude Code this is one file read, and now you are both looking at the same thing.
- Paste the snippet with its address. If it is a few lines, paste them, but keep the location attached: "this is from src/hooks/useCart.ts around line 25". A floating snippet with no address puts you right back in search-and-guess territory when it is time to write the fix.
The failure mode to avoid is describing code from memory. "There's a useEffect that fetches the cart, I think it has the wrong deps" makes the model debug your recollection instead of your code.
Error traces are free precision
A stack trace is location, behavior, and call path, pre-formatted by the runtime. It is the most precise prompt you will ever get without writing one. So:
- Paste the whole trace, not the one line you think matters. The frame below the obvious one is where the answer lives surprisingly often.
- Never paraphrase. "It says something about undefined in the cart thing" discards every file:line the runtime handed you for free.
- Add the one thing the trace lacks: what you were doing when it fired. Trace plus reproduction step is a complete bug report.
Run this on your codebase
Precision needs a map. Paste this into a Claude session in your repo and pin what comes back:
Build me a pointing map of this codebase so I can write precise prompts:
1. List the 15 files where the real work happens, one line each on what
they own.
2. For each, name the 2-3 functions I'm most likely to mention when
reporting a bug.
3. Write one example of a precise bug report for THIS codebase in the
format: location (file, function, line), observed behavior, expected
behavior.
Keep the whole thing under 60 lines so I can pin it in a note.