Skip to content
groundworkv0.2

Prompting patterns that work

Reusable moves for steering an agent, such as plan first, show diverse examples, ask for pushback and work in small verified steps.

9 min read · Last reviewed November 20, 2026

Prompting patterns that work

Anatomy of a good prompt tells you what a prompt contains. This page is about how you run the conversation: a handful of patterns that improve results on almost any task.

You'll be able to#

  • Get a plan you can correct before any code is written
  • Use examples that teach the pattern instead of causing the to overfit
  • Invite pushback so you hear about problems early
  • Break a big task into small steps that each end with proof

The mental model#

A prompt is the start of a loop, not a single throw. The agent proposes, you check, you steer. The patterns below are ways to make each pass of that loop cheaper and more informative: cheaper to correct (plans before code), clearer to steer (examples, reasons), and easier to trust (verification built in).

Key concepts#

  • Explain the why: A rule with a reason generalizes better than a bare rule. "Store prices as integer cents because we sum them and floats drift" lets the agent handle cases you never mentioned. Anthropic's prompting guidance gives this advice directly.
  • Plan, then act: Ask for a short plan first and approve it. OpenAI's guidance for agentic work likewise suggests having the agent plan before tool calls and keep going until the task is resolved.
  • Few-shot examples: Show a few input and output examples. Anthropic suggests roughly three to five, and both Anthropic and OpenAI stress variety so the model doesn't latch onto an accidental pattern.
  • Separate instructions from data: Use headings or tags (like <data>...</data>) to mark what is instruction and what is material to work on. Put long documents before the question, and consider asking the model to quote the relevant parts first.
  • Action versus advice: "Suggest changes" gets suggestions. "Make this change" gets edits. Say which you want.
  • Pushback on request: Ask the agent to question your approach and raise ambiguities before it builds.
  • Verification built in: Give a way to check the result (tests, a command, an expected output) and ask the agent to run it. This is the most reliable lever you have.
  • Small steps with checkpoints: For long tasks, work in stages, keep progress notes in a file, and commit to git at each good state so you can step back.

Decisions you make (not the agent)#

Your call, not the agent's

DecisionSensible defaultChoose otherwise when…
Plan first or build directlyPlan first for anything touching more than a file or twoThe change is tiny and obvious
How many examplesThree to five that differ from each other, including edge casesOne example is enough only when the format is trivial
Rule wordingSay what to do, with a reasonA hard safety rule: state it plainly once, don't shout it repeatedly
Advice or editsSay explicitly: "make the change" or "propose only"You are exploring: ask for options and no edits
Step sizeOne reviewable step per prompt, each ending with a checkThe work is mechanical and well covered by tests
Ask for questions firstYes when requirements are fuzzyThe spec is fully nailed down
Reasoning depthAsk for a plan or explanation where the choice is non-obviousSimple, well-defined edits

What good output looks like#

  • A plan you can approve or correct before code exists
  • Questions about real ambiguities, not filler
  • Behavior that matches your examples and also handles inputs you didn't show
  • Small diffs, each with its checks run and reported
  • Honest status: what was done, what wasn't, what was assumed

Red flags#

  • Aggressive wording everywhere ("MUST", "NEVER", all caps) → Anthropic's guidance notes that forceful wording (for example, "MUST use this tool") can make newer models over-trigger. Use calm, specific instructions with reasons.
  • Examples that are all alike → the agent copies the pattern, not the rule. Add edge cases.
  • "Suggest" when you wanted edits (or the reverse) → you get the wrong kind of output. State which you want.
  • Code that special-cases your test or example → ask for a general solution, and add different test inputs.
  • Giant prompts that bundle five tasks → split them. Review is easier, and so is .
  • No checkpoint → one bad step buries a good one. Commit after each verified stage.
  • The agent just agrees with everything → explicitly ask it to challenge the approach.

Worked example#

Task: Add a "download bookings as CSV" feature to a Next.js app with Postgres and Drizzle.

You send a short prompt with one example row: 2026-03-01,Jane Doe,Haircut,45. The agent produces an endpoint that joins values with commas, matching your example exactly. Tests pass on that example.

What a good result contains: correct quoting and escaping of fields, a header row, a stable column order, or pagination for large exports, and tests with awkward inputs.

The wrong turn: a customer named Smith, Jane or a service note containing a quote or a newline breaks the file. The agent matched your single example and never saw the edge cases, so it had no reason to handle them.

How review catches it: ask the agent to generate five awkward rows (commas, quotes, a newline, accented characters, an empty field) and show the output for each. Then add those rows as tests and ask for a general solution that handles them, not a patch for the one that failed. Next time, put the diverse examples in the original prompt.

Sample prompts#

Weak vs strong#

Strong prompt
Goal: add GET /api/bookings/export that downloads the current user's bookings as CSV.
Stack: Next.js (App Router), TypeScript, Postgres via Drizzle.
Columns, in order: date (ISO), customer name, service, price in dollars.
Constraints: use standard CSV quoting (quote fields containing commas, quotes or newlines; double any inner quotes); header row first; only the signed-in user's rows; stream the response so large exports don't load everything into memory.
Examples (all must work):
- 2026-03-01,Jane Doe,Haircut,45.00
- 2026-03-02,"Smith, Jane",Colour,120.50
- 2026-03-03,"O""Neil",Trim,30.00
- 2026-03-04,Zoë Müller,"Cut
and style",60.00
Non-goals: no UI changes, no new dependencies.
Verify: add tests for each example plus an empty field; run lint, typecheck and tests and show the output.

Why it works: Diverse examples teach the rule (quoting), the constraints say how, and the verify step proves it.

What changed

  • Columns and format are specified, instead of left to the agent
  • Diverse examples include a comma, a quote, an accented name and a newline
  • Constraints name standard CSV quoting and streaming for large exports
  • Verify requires a test for each example, plus an empty field

Plan first#

Prompt
Don't write code yet. Propose a plan for this task in 6 steps or fewer: the files you will touch, the order, and how you will verify each step. Flag anything you are unsure about. I will approve or change the plan before you start.

Why it works: A wrong plan costs a minute to fix. Wrong code costs a review.

Ask for pushback and questions#

Prompt
Before you build anything, tell me (1) what is ambiguous or missing in this request, as a short list of questions, and (2) any part of my approach you would do differently and why. Wait for my answers.

Why it works: It surfaces assumptions while they are cheap to fix, and it gives the agent permission to disagree.

Generate the edge cases#

Prompt
Here are 3 example inputs and outputs: <paste>. Generate 5 more inputs that are different from these and likely to break a naive implementation (empty values, special characters, very long values, unusual formats). Show the expected output for each, and tell me which expectations you are unsure of.

Why it works: Asking for diversity on purpose fixes the "all examples alike" problem. Check the expected outputs yourself.

Work in a checkpointed step#

Prompt
Do only step 1 of the plan. Run the tests, then show me the diff and the test output. If everything passes, commit with a clear message and stop. Do not start step 2 until I say so.

Why it works: Each step is small enough to review and leaves a safe commit to return to.

Explain the reason, then ask for edits#

Prompt
Make the change directly (don't just suggest it): store money as integer cents in the database and convert to dollars only when displaying. Reason: we sum amounts across many rows and floating-point rounding errors add up. Apply this to the bookings table and every place that reads or writes price.

Why it works: It says "make the change", and the reason lets the agent handle places you didn't list.

Check your understanding#

Check your understanding

1/3You want the agent to edit a file. Which wording is better?
2/3Why should few-shot examples differ from each other?
3/3What is the main benefit of asking for a plan before any code?

Checklist#

  • Planned before building anything non-trivial
  • Examples differ from each other and include edge cases
  • Each important rule has a reason
  • Stated whether I want edits or suggestions
  • Each step ends with a check and a commit
  • Asked the agent for questions and pushback at least once

Go deeper#