Writing effective prompts for LLMs
State the task and success criteria, give context and reasons, show examples, enforce the format with a schema and test every change. Prompting for 2026 models.
State the task and success criteria, give context and reasons, show examples, enforce the format with a schema and test every change. Prompting for 2026 models.
Test AI like software: real cases, code checks for what must hold, a calibrated LLM judge for the rest, human audits, and a release gate on every change.
Prompt caching reuses the processed start of a repeated prompt, so it bills at a tenth or less of the input price. How Claude, OpenAI and Gemini differ.
A recurring report. A slow review. A prototype that needs to work in the real world.
Writing prompts in 2026 looks far less like hunting for clever phrasing and far more like ordinary engineering: clear specs, schemas, test sets and version control. State the task and what a good reply looks like, give the context and the reason behind each rule, include two to four examples, lock down the shape with the API's structured outputs, and test every edit against real cases before shipping. On reasoning models, set the effort level and leave the thinking steps to the model.
Remember that the prompt is everything the model sees before replying (system instructions, documents, tool results, examples and the user's request), so small structural changes often beat another paragraph of wording.
Key takeaways
Five things, roughly in order of impact. The annotated request below packs the first few into a single turn.
A role ("you are a contracts lawyer") sits dead last. A one-line persona still helps set tone and framing (Anthropic recommends one), yet on current models it adds very little that a sharp task and solid context haven't already done.
Summarise this contract.<contract>[CONTRACT TEXT]</contract> Our legal team reviews supplier agreements for a mid-sized manufacturer.They need the key obligations quickly, before a renewal decision, andwill check anything you flag against the full text. From the contract above, extract:1. Payment terms and late-payment penalties2. Termination rights and notice periods3. Liability caps and indemnities4. Anything unusual compared with a standard UK supply agreement Quote the clause number for every point. If the contract is silent onan item, say so rather than inferring it. Keep the whole summary under400 words, as bullet points under the four headings.The second version states who's reading it, why it matters, what to pull out, how to handle silence and what the reply should look like. It also puts the document first and the instructions last, which pays off on longer inputs.
Reasoning models think before replying, and most providers give you a dial for how hard: OpenAI's reasoning.effort and Anthropic's effort, from low to high or above. That dial is now your primary lever on hard tasks: turn it up for multi-step analysis, dial it down for routine classification where latency and cost count.
Both OpenAI and Anthropic advise against scripting every intermediate step on these models. A hand-written reasoning checklist usually underperforms the model's own plan. Give it the goal, the constraints and the output shape, and stay out of the middle.
The older trick still works on non-reasoning models and small fast models with thinking off: asking for working before the final answer boosts multi-step accuracy (Wei et al., 2022) and makes slips obvious. Better yet, don't ask any model to do arithmetic code can do. Hand it a calculator or database query as a tool and let it decide what to run.
When code reads the result, use the API's structured outputs instead of begging for JSON in prose. Older "JSON mode" only guaranteed syntactically valid JSON; schema-constrained output forces the reply to match your JSON Schema, so a missing key or wrong type can't leak into downstream code:
json_schema format with strict: true.output_config.format for responses, and strict: true on tool definitions when the model fills tool arguments.{ "type": "object", "properties": { "supplier_name": { "type": "string" }, "invoice_number": { "type": "string" }, "date_issued": { "type": "string", "description": "ISO date, YYYY-MM-DD" }, "total_amount": { "type": "number", "description": "Total including VAT, in pounds" }, "vat_amount": { "type": ["number", "null"], "description": "Null if not shown" }, "status": { "type": "string", "enum": ["complete", "needs_review"] } }, "required": ["supplier_name", "invoice_number", "date_issued", "total_amount", "vat_amount", "status"], "additionalProperties": false}Three habits make schemas pull their weight:
needs_review status lets it report missing data instead of making up a number to satisfy the schema.Order affects both answer quality and cost. One layout works cleanly across every major model:
Anthropic's guidance puts long documents near the top, above the query and task instructions, reporting noticeably better answers on complex multi-document prompts when the question lands last. Wrap each source in a labelled tag (<policy>, <email>) so the model can separate material from instructions cleanly.
Prompt caching rewards that exact same order. Caches match from the start of the prompt, so putting stable text first and per-request input last drops the repeated prefix to a fraction of full price. Our guide to prompt caching walks through the numbers.
Examples are still the surest way to pin down a taxonomy or output style. Pick cases that sit on the awkward boundaries between labels rather than textbook easy ones, and vary the phrasing so the model doesn't echo one template verbatim.
Classify each enquiry to a council contact centre. <example>Enquiry: The streetlight outside 42 Oak Road has been flickering for weeks.Category: Highways | Priority: Low | Team: Street lighting</example> <example>Enquiry: Raw sewage is coming up through the drain into my garden.Category: Environmental health | Priority: Urgent | Team: Drainage</example> <example>Enquiry: My neighbour's tree has dropped a branch across the pavement.Category: Highways | Priority: High | Team: Trees and verges</example> Enquiry: {enquiry}Put standing rules that apply to every turn in the system prompt, and keep the user message for the specific request. Write escalation triggers as concrete conditions the model can check against the thread rather than a confidence score. A model's stated confidence isn't calibrated, so "escalate when you're less than 70% sure" won't behave the way you expect.
You answer customers of a building supplies company about their orders,deliveries and invoices. You do not quote prices that are not on thecustomer's account and you do not promise delivery dates. Tell the customer to ring their branch now if they report a damaged orunsafe delivery on site. Hand the conversation to a person if any of these apply:- the customer disputes an invoice or asks for a refund or a credit- the order would take the account over its credit limit- the customer asks to speak to a person- you cannot match the question to an order or invoice on the account Record the reason for every handover in one sentence.Any system reading emails, web pages, uploads or tool output can be steered by hidden instructions inside them. That's prompt injection, sitting at the top of OWASP's risk list for LLM apps. Better wording reduces the risk and can't eliminate it, so the real defences sit outside the prompt:
You measure it. The loop we use is straightforward:
Exact-match checks handle structured output. For free text, a second model can grade against a rubric once you've checked its scores against human marks. Our guide to evaluating AI systems walks through that setup.
Suppose a policy team wants a searchable register of obligations across published UK government documents. Putting every habit above into one prompt gives something short and legible: standing rules, two examples, an API-enforced schema and an explicit way to say "unclear".
1 SYSTEM 2 You extract structured facts from UK government policy documents for a 3 searchable register used by policy analysts. Analysts rely on the 4 register without re-reading every source, so accuracy matters more 5 than coverage: if a value is not stated, return "unclear". 6 7 EXAMPLES 8 <document>The Carbon Budget Order 2021 sets the UK's sixth carbon 9 budget at 965 MtCO2e for 2033-2037.</document> 10 -> policy_area: Climate 11 key_figures: carbon budget, 965 MtCO2e, 2033-2037 12 departments: DESNZ 13 compliance_deadline: null 14 15 <document>Local authorities must publish an updated Local Plan within 16 30 months of the framework update.</document> 17 -> policy_area: Planning 18 key_figures: publication deadline, 30 months, from framework update 19 departments: MHCLG, local authorities 20 compliance_deadline: unclear 21 22 USER 23 <document>{document_text}</document> 24 Extract the policy facts from the document above.
To verify it, have analysts label a held-out batch of documents and track both field-level accuracy and the share of fields coming back "unclear". A slightly higher "unclear" rate after a prompt edit is usually a better trade than dropping accuracy: you can spot a gap, whereas a wrong value slips past.
| Option | When to use | Trade-offs |
|---|---|---|
| Clear task and context | Always | None worth naming; this is where most quality comes from |
| Few-shot examples | Classification, extraction, house style and formatting | Longer prompts; poorly chosen examples get copied too literally |
| Structured outputs | Code, a database or another system reads the result | Schemas need maintaining; they guarantee shape, not correctness |
| Effort setting | Reasoning models on hard or multi-step tasks | Higher effort means more tokens and latency; lower it for routine work |
| Requested working | Non-reasoning models on multi-step problems | More output tokens; unnecessary on reasoning models |
Production prompt checklist
Before writing a line of prompt, write down what a good reply looks like for twenty real inputs. That list gives you both your few-shot examples and the seed of your test set. Then draft the prompt like a spec (task, audience, reasons, schema-enforced output and an explicit way to flag a gap) and commit it alongside the test set.
Only then compare models and effort levels against those cases. The cheapest setup that passes is usually cheaper than teams expect, and whatever still fails almost always points to missing context rather than missing model capability.
We build versioned prompts, eval suites and release checks with client teams, then hand over a practice you can run yourselves. Work with our engineering team →