Skip to main content

Prompt Patterns Library

All levels

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.

What you'll learn
  • 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

Guided walkthrough1 of 5
  1. Assign the persona or standard you want — e.g. a meticulous senior copy editor — to prime relevant behaviour.
Pattern recall
Press Enter or Space to flip the card. Use the left and right arrow keys to move between cards.Term shown.
1 / 6

Check yourself

0/3
  1. Which pattern is the single biggest lever against hallucinations?
  2. You need output that feeds directly into another tool. Which card fits best?
  3. According to the page, a strong real prompt often layers which combination?
Key takeaways
  • 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

Next