The quality of what a coding agent produces is mostly a function of how you ask. The same model can feel brilliant or useless depending on the prompt. Prompting is a learnable skill, and a handful of habits cover most of the gains.
Be specific, not polite
Vague: "make this better." Specific: "extract the duplicated validation in createUser and updateUser into a shared validateUserInput helper, and keep the error messages identical." The agent cannot read your mind. Every unstated assumption is a place it will guess.
Before and after
A weak prompt and a strong one for the same bug:
"The date filter is broken, fix it."
versus:
"In
src/lib/filter.ts,filterByDate()returns items on the boundary date twice whenfromequalsto. Expected: a single day range returns each item at most once. Add a test infilter.test.tsthat reproduces it, then fix it. Do not change the function signature."
The second names the file and symbol, states expected vs actual, asks for a failing test first, and fences off the API. It goes straight to work; the first sends the agent hunting.
Give examples
Examples are the highest-leverage thing you can add. If you want a function shaped a certain way, paste an existing one and say "follow this pattern." If you want a specific output format, show a sample. AgentsAgent systemsAI systems that take actions, use tools, and complete multi-step tasks by reasoning through a sequence of decisions. pattern-match extremely well, so one concrete example beats a paragraph of description.
Point at the right context
Reference exact files and symbols. In Cursor, use @file and @symbol; in Claude Code, name the paths (tab-completion helps) or let it grep. "Fix the bug" makes the agent hunt; "Fix the off-by-one in paginate() in src/lib/list.ts" lets it go straight to work. Precise context is faster and cheaper.
Iterate in small steps
Do not ask for the whole feature in one prompt. Ask for a piece, review the diff, then ask for the next. If the agent goes wrong, it is easier to correct a small step than to untangle a large one. Treat it as a conversation, not a vending machine.
When it goes wrong, redirect early
If the first response is off, do not pile more instructions on top of a bad state. Often the cleanest move is to reject the change, refine the prompt, and try again from a clean slate. Sunk-cost prompting (adding "no, also fix this" five times) tends to compound the confusion.
Chat vs inline: pick the right surface
Both Cursor and Claude Code offer more than one way to invoke the model. Match the tool to the task:
- Inline edit (highlight code,
Cmd+Kin Cursor): best for a small, local, well-defined change in one spot. Fast, low ceremony. - Chat or agent mode: best for multi-file work, exploration, planning, debugging, or anything where the agent needs to read around the codebase first.
- Autocomplete or tab: best for the next line or two while you are actively typing. You stay the author; it just speeds you up.
Reaching for chat to rename one variable is overkill; reaching for inline edit to refactor across five files will fail.
Tell it what "done" looks like
End prompts with the acceptance bar: "It should compile, pass npm test, and not change the public API." Better yet, ask it to run the tests. AgentsAgent systemsAI systems that take actions, use tools, and complete multi-step tasks by reasoning through a sequence of decisions. that can verify their own work are far more reliable than ones that just assert success.
Give it a role and standing rules
A short framing sharpens output: "You are careful about backwards compatibility. Prefer the smallest change that works. Ask before adding dependencies." Put these in CLAUDE.md or Cursor rules so they apply to every prompt without you repeating yourself.
Common failure modes
- It claims success without checking. The reply says "done, tests pass" but nothing ran. Require it to actually run the command and paste the output.
- It over-delivers. You asked to rename a variable; it also "improved" three unrelated functions. Add "change only what I asked" and review the full diff.
- It invents an API. It calls a helper or flag that does not exist. Point it at the real module so it reads before it writes.
- It loops on the same wrong fix. If two attempts fail the same way, stop, give it the actual error output, and reconsider the approach instead of asking again.
Rules of thumb
- Name the file and symbol in almost every prompt.
- State expected vs actual behavior for bugs; a reproduction beats a description.
- Ask for a failing test before the fix when the behavior is subtle.
- Always read the diff. If you would not merge a human's version of it, do not accept the agent's.
- Bank repeated instructions in
CLAUDE.mdor Cursor rules instead of retyping them.