Skip to content

Prompts4 min readBy Startpacks

Prompt techniques with a worked example: the free Code review prompt

Take apart a prompt that works: inputs, output format, evidence rules and an honest 'what I could not check' section. Then run it on a small diff and see what a good answer looks like.

A prompt template with input slots flowing into a structured review with blocker, should-fix and nit groups

Most "bad AI answers" come from prompts that leave the important decisions to the model: what to look at, how long to go on, how sure to sound. A good single prompt makes those decisions up front. Startpacks sells and gives away single prompts written that way, and this guide takes one apart so you can reuse the techniques in your own prompts. The example is the free Code review of a diff.

The prompt

This is the prompt text from the pack (MIT licensed). Everything in double curly braces is an input you fill in.

Review this change as a senior engineer.
Intent: {{intent}}
Risk areas to focus on: {{risk_areas}}
Diff:
{{diff}}

Output:
- Summary (2-3 sentences) of what the change does.
- Findings, max 10, each as "[blocker|should-fix|nit] file:line - problem (evidence) - suggested fix". Blockers must show why it fails (input -> wrong result) or the security impact.
- Missing: tests, error handling, migration/rollback, docs, logging.
- Verified vs not verified (you only see the diff: say what you could not check).
- Verdict as advice: ready / needs changes / needs discussion.
Rules: don't invent code you can't see, prefer questions when intent is unclear, skip anything a formatter would fix, no more than 3 nits.

Six techniques hiding in it

Six technique cards: role and standard, intent and material, risk areas, fixed output format, evidence for blockers, say what you could not check
Anatomy of a reliable prompt: each line removes one decision from the model

1. Give a role and a standard. "As a senior engineer" sets the bar. It is short, and it works best when paired with the concrete rules below rather than used alone.

2. State the intent separately from the material. {{intent}} lets the reviewer judge the change against what it was supposed to do. Without it, a model can only review style. If you cannot write the intent in one sentence, the change is probably too big.

3. Name the risk areas. {{risk_areas}} ("auth, money, data, concurrency") points effort where it matters. Leave it as "none" if you do not know; do not leave it out.

4. Fix the output format. A numbered shape (summary, findings, missing, verified, verdict) makes answers comparable across runs and easy to scan. The finding format [severity] file:line - problem (evidence) - suggested fix forces every comment to be specific and locatable.

5. Demand evidence for the serious claims. "Blockers must show why it fails (input -> wrong result)" stops vague alarm. A blocker the model cannot demonstrate is downgraded to a question.

6. Make it say what it could not check. "Verified vs not verified" is the most underrated line. A model that only sees a diff cannot know whether the tests pass or whether a function is called elsewhere. Asking it to say so turns false confidence into a to-do list.

Caps help too: "max 10 findings" and "no more than 3 nits" fight padding, and "skip anything a formatter would fix" keeps the review on substance.

A worked example

Here is a small, made-up change to try it on (an illustration, not code from a real project):

--- a/api/orders.ts
+++ b/api/orders.ts
@@ -40,6 +40,12 @@ export async function createOrder(req: Request) {
-  const price = await getPrice(body.productId);
+  const price = body.price ?? (await getPrice(body.productId));
   const order = await db.insert("orders", { productId: body.productId, price });
+  if (price === 0) {
+    await grantAccess(order.id);
+  }
   return json(order);
 }

Fill in intent ("let partners override the price for special deals") and risk_areas ("money, auth"). A good answer has this shape. The exact wording will differ between models, so check the structure and the reasoning, not the phrasing:

Summary: The change lets the request body set the order price and grants access
when the price is 0.

Findings:
- [blocker] api/orders.ts:43 - price is taken from the request body, so any client
  can send price: 0 (input -> free order plus access granted). Fix: only accept
  overrides from an authenticated partner role, or look the price up server-side.
- [should-fix] api/orders.ts:45 - access is granted inside the request handler;
  a failure between insert and grant leaves a paid order without access.
  Fix: grant in the same transaction or from a verified payment event.

Missing: a test for the override path and for price 0; no audit log of overrides.
Verified vs not verified: I only saw this diff. I could not check how
authentication works or whether getPrice validates productId.
Verdict (advice): needs changes.

Notice what the prompt bought you: a concrete failing input for the blocker, a clear list of unknowns, and a verdict you can disagree with. Treat it as advice and verify blockers yourself, as the prompt's own how-to line says.

Using it with an agent or in chat

In plain chat, paste the prompt with the three inputs filled in. In a coding agent, give it the branch name and let it read the diff itself, and keep the output rules. If you use the Pull Request Reviewer starter agent, the same ideas are baked into its instructions.

Reuse the techniques in your own prompts

A checklist you can paste into any prompt you write:

  • What is the goal, in one sentence?
  • What material am I giving, and what is missing?
  • What should the output look like, exactly?
  • What counts as evidence for a strong claim?
  • What must the model say it could not verify?
  • What should it never do, and how long may it go on?

Two more free prompts built the same way

Write the failing test first is a stepwise prompt: restate the behaviour, ask one question if ambiguous, write one test, say what the failure should look like, then the smallest implementation and the commands to run. It ends with "stop after step 5", which is a technique of its own: a clear stopping point.

Refactor safely asks for characterization tests first, then three to eight tiny steps with a verification command each, and flags any step that would change behaviour. Both are included in the Single prompt library bundle with 28 more.

  • #prompts
  • #code review
  • #how-to
  • #prompt engineering

The packs, agents and prompts used in this guide.

Browse all packs

More guides