Prompt Patterns

The dozen prompting techniques that actually move quality, with the one-line version of when to use each.

Structure

Role + task + constraints
who the model is, what to produce, what must never happen — in that order
Few-shot examples
2-5 input→output pairs beat a paragraph of description; match format exactly
Output schema
ask for JSON against a schema (or use structured output mode) — parse, don’t regex
Delimiters
fence retrieved/user content (<doc>…</doc>) and say it is data, not instructions
Prefill the start
begin the assistant turn ("{") to lock format and skip preamble

Reasoning

Chain-of-thought
"think step by step" / worked examples — for math, logic, multi-step
Self-consistency
sample N answers, majority-vote — reliability on discrete answers
Decompose
split into subtasks across calls; each prompt does ONE job well
Critique-then-revise
second pass: "find errors in this answer, then fix them"
Reasoning models
o1/R1-class: skip CoT prompting — state the problem, set effort, stay out of the way

Reliability

Grounding
"answer ONLY from the sources; cite; say not-found otherwise" — kills most hallucination
Escape hatch
always give an out ("if unsure, say so") — forced answers are invented answers
Position matters
models recall start + end best — instructions up top, key facts near the question
Temperature
0-0.3 for tools/extraction · 0.7+ for ideation; seeds for reproducibility
Cache-aware order
stable content (system, tools, examples) first; volatile (query) last