Writing Prompts That Work
Plan Before You Prompt turned the task into a few small steps. This page is about the prompt you write for each one. Interviewers don't grade clever wording. They grade whether the prompt carried what the AI needed to know and kept it inside the step you chose, because that decides whether you get back a diff you can review or one you have to throw away. Some companies also log your prompts and read them afterwards.
The example is step 2 of the toolshed plan: a reserve_tool service, with two rules and a test for each.
Give It the Context You Already Have
The AI only knows what's in the prompt and what it reads, so put in what you've learned. By now you've read the repo, written acceptance criteria and made a plan. The AI has done none of that. A prompt that leaves it out forces the AI to guess, and its guesses come from typical codebases, not this one. The four things worth including every time are the goal, the files, the constraints and the check.
Weak: "Add reservations."
Better: "Add
reserve_tool(member_id, tool_id)inapp/services/loans.py, following the style ofcreate_loanin the same file. Rules: the tool must currently be on loan, and a member can hold at most 2 active reservations. RaiseLoanErrorfor both, ascreate_loandoes. Add one test per rule intests/test_loans.pyusing the existingmemberandtoolfixtures."
The second prompt is longer, but every clause does work. Naming create_loan makes it copy the repo's patterns
instead of inventing new ones. Naming LoanError stops it creating a new exception type. Naming the fixtures stops
it writing its own setup code. Errors need the same care: paste the full message and the last lines of the stack
trace, not "it's broken".
How much you paste depends on the tool. An agent like Claude Code, Cursor or Codex can open files itself, so naming them is enough. A company panel that only sees what you give it needs the relevant code pasted in. Paste the function you're changing and the one you want copied, not the whole repo.
Limit the Scope of Each Prompt
Each prompt should ask for one step of the plan, name the files it may change and say what it must not touch. Left unbounded, the AI tends to be helpful in ways you didn't ask for. It adds a route while it's there, renames a variable, or "fixes" a test that was failing for another reason. Each of those is a line you have to review, and reviewing lines you didn't plan is how the session slips.
Limits are cheap to write and save minutes each:
- Name the files. "Change only
app/services/loans.pyandtests/test_loans.py." - Name what's off limits. "Don't change existing tests. Don't touch the route yet; that's the next step."
- Name the size. "Keep it to the two rules; no cancellation or expiry."
- For agents, name the stop. "Run
pytest tests/test_loans.py, and stop when it passes or after two tries. Show me the diff."
At work you might hand an agent a whole ticket and come back later. In the interview, a prompt that covers three plan steps produces one diff covering three steps, and you've lost the checkpoint between them. Keep a rule: one plan step per prompt, and run the tests before the next prompt.
Ask It to Explain Before It Edits
When you aren't sure how a change should be made, ask for the approach first and the code second. A proposal in three sentences takes ten seconds to read and costs nothing to reject. A wrong 40-line diff takes two minutes to read and a revert to undo. Asking first also gives you something to say out loud, which keeps the interviewer in the loop.
"Before writing code: how would you count a member's active reservations? Which file and query would you use, and does the repo already have something similar? Two or three sentences, no edits."
If the answer matches what you'd do, reply "Go ahead, as described." If it doesn't, correct it now: "Use the
status column rather than checking created_at, since cancelled ones keep their date." This works especially
well for anything touching existing behaviour, such as step 4 of the plan, where the AI has to change code that
already has tests.
You don't need this for every prompt. If the step is clear and you've given it a pattern to copy, ask for the code directly. A good rule: explain first when you couldn't describe the change in one sentence yourself.
Iterate Instead of Re-rolling
When the output is wrong, say what's wrong and send a correction; don't send the same prompt again. Re-rolling treats the AI like a slot machine and tells the interviewer you don't know what the problem was. A correction names the problem, which shows you read the diff, and usually gives the AI the fact it was missing.
Suppose the diff counts every reservation the member has ever made, including cancelled and finished ones. The follow-up should name the line and the rule:
Weak: "That's wrong, try again."
Better: "The count in
reserve_toolincludes cancelled and fulfilled reservations. Only count ones with statuswaitingorready. Add a test where a member has one cancelled and two waiting reservations, and the third reservation is rejected."
Notice that the correction also asks for a test that would have caught the mistake. That locks in the fix and proves to the interviewer that you understood it. Then follow one rule for stuck loops: rephrase once with the missing fact, and if the second answer is still wrong, write the change yourself. For anything under about five lines, typing it is often faster than any prompt. Typing it also shows you can make the change without the AI.
Prompts for the Moves You'll Repeat
A handful of prompt shapes cover most of a round, and having them ready saves you composing each one under pressure. They all follow the same pattern: a clear goal, the files, the limits and the check.
Map: "List the files involved in <flow>, from <entry> to <storage>. One line each. No edits."
Test: "Write a failing test in <file> for <behaviour>: <input> should give <result>. Use <fixture>.
Don't change non-test files."
Build: "Implement <step> in <file>, following <existing function>. Rules: <criteria>.
Change only <files>. Run <test command> and show the diff."
Fix: "<exact error and failing test>. The cause is <one sentence>. Fix that, don't change the test."
Check: "List other places that <pattern>, with file and line. Don't fix them."
These are shapes, not scripts. Fill them with the real names from the repo, and drop the parts that don't apply. The map prompt comes from The First Five Minutes, the fix prompt from Fixing a Bug. The common thread is that every prompt can be checked: it says what to change and what result to look for.
A good prompt gets you a diff worth reading, but you still have to read it. The next page, Reviewing the AI's Diff, covers what to look for line by line and when to reject a diff and start over.
Key Takeaways
- Every prompt carries the goal, the files, the constraints and the check; name an existing function to copy.
- One plan step per prompt: name the files it may change and what it must not touch, and give agents a stop.
- Ask for the approach before the code when you couldn't describe the change in one sentence yourself.
- Correct instead of re-rolling: name the wrong line and the rule, and ask for a test that catches it.
- Rephrase once with the missing fact; if it's still wrong, or under five lines, write it yourself.
Practice it in a real repo: AI coding rounds.