Prompt Patterns Library
A toolbox of reusable prompting patterns. Each card tells you what it is, when to reach for it, and gives you a copy-paste template. They stack — combine them freely. New here? Start with Prompting Basics first.
- Recognize the 11 core prompting patterns and when each one applies
- Grab a copy-paste template for any task — zero-shot, few-shot, chain-of-thought, and more
- Combine patterns (role + example + output constraint + permission to abstain) into one strong prompt
- Use grounding to cut hallucinations and meta-prompting to fix weak prompts
Zero-shot (just ask, clearly)
When: simple, common tasks. Why: least effort, often enough.
Zero-shot summary
Summarize the text below in 5 bullets for a busy manager.
TEXT: """{paste}"""Few-shot (show examples)
When: you need a specific format or style. Why: examples teach faster than descriptions. See Few-Shot Done Right.
Few-shot sentiment classifier
Classify the sentiment as positive/negative/neutral.
Review: "Loved it, shipped fast" → positive
Review: "Broke on day one" → negative
Review: "{new review}" →Chain-of-thought (think step by step)
When: math, logic, multi-step reasoning. Why: reasoning before answering improves accuracy.
Chain-of-thought
Work through this step by step, then give the final answer on its own line.
PROBLEM: {problem}Decomposition (break it down)
When: big, fuzzy tasks. Why: smaller subtasks are easier and more reliable.
Decomposition
First, list the sub-tasks needed to {goal}. Then do them one at a time,
showing each result before moving on.Role prompting (assign a persona)
When: you want a specific lens or standard. Why: primes relevant behaviour.
Role prompting
You are a meticulous senior copy editor. Edit the text for clarity and concision without changing meaning. Show a bullet list of the changes you made.
Output-format constraint
When: the result feeds another tool, or you want consistency. Why: predictable shapes are usable.
Output-format constraint
Reply with ONLY valid JSON matching: {"title": string, "tags": string[]}.
No prose, no markdown fences.Self-consistency / self-critique
When: correctness matters. Why: a second pass catches first-pass errors.
Self-critique
Answer the question. Then, in a section called "Check", critique your own answer for errors or missing cases and revise if needed.
Grounding (answer only from provided context)
When: facts matter — Q&A over your docs, RAG, anything where a wrong answer is worse than no answer. Why: the single biggest lever against hallucinations is forbidding the model to invent and giving it explicit permission to abstain.
Grounded Q&A
Answer the QUESTION using ONLY the CONTEXT below. Quote the exact sentence(s)
you relied on. If the context does not contain the answer, reply exactly:
"Not found in the provided context." Do not use outside knowledge.
CONTEXT: """{paste your sources}"""
QUESTION: {question}Meta-prompting (let AI improve your prompt)
When: your prompt underperforms. Why: the model is good at spotting what it's missing.
Meta-prompting
Here's my prompt: "{prompt}". Ask me the 3 questions that would most improve it,
then rewrite it incorporating sensible defaults.Iterative refinement
When: almost always. Why: the first output is a draft, not the destination.
Iterative refinement
{after a result} Shorter and more concrete. Keep the second paragraph. Add one
example. Drop the marketing tone.:::tip Combine them A strong real prompt is often: a role + an example + an output constraint + permission to say "I don't know." Layer the cards. :::
How to layer the cards
- Assign the persona or standard you want — e.g. a meticulous senior copy editor — to prime relevant behaviour.
- Show one or two few-shot examples so the model learns your format or style faster than a description could teach it.
- Pin down the shape: ONLY valid JSON, 5 bullets, no markdown fences — whatever the next step needs.
- Let the model say I do not know or Not found in the provided context instead of inventing an answer.
- Treat the first output as a draft. Ask for shorter, more concrete, keep this paragraph, drop that tone — repeat until it lands.
Check yourself
0/3- Patterns are reusable building blocks — pick by task: zero-shot for simple, few-shot for format, chain-of-thought for reasoning, decomposition for big tasks
- Grounding (answer only from context + permission to abstain) is the strongest defense against hallucinations
- Output-format constraints make results predictable and tool-ready
- The cards stack: a strong prompt is usually role + example + output constraint + permission to say 'I don't know'
- First output is a draft — refine iteratively, and use meta-prompting when a prompt underperforms