Prompt Engineering Patterns
13 proven patterns with examples — from zero-shot to Tree of Thoughts and ReAct.
Prompts the model to reason step-by-step before giving a final answer. Dramatically improves performance on arithmetic, logic, and multi-step reasoning tasks.
Math problems, logic puzzles, legal/policy reasoning, multi-step code debugging, any task where intermediate reasoning matters.
Solve this step by step. A store sells apples for $1.20 each and oranges for $0.80 each. Sarah buys 5 apples and 3 oranges. She pays with a $10 bill. How much change does she receive? Let's think step by step:
- →"Let's think step by step" is the canonical zero-shot CoT trigger
- →For few-shot CoT: include solved examples that show the reasoning chain
- →Ask for reasoning before the final answer — not after
- →CoT is less useful for simple lookups; overhead not worth it
About
This reference documents 14 prompt engineering patterns used to get better results from LLMs. Reasoning patterns: Chain of Thought (step-by-step reasoning), Self-Consistency (generate multiple chains, pick majority), Tree of Thoughts (explore branching reasoning paths), ReAct (interleave reasoning and action). Output patterns: Structured Output (JSON/XML schema), Role Prompting (persona assignment), Constraint-Based Prompting. Context patterns: Few-Shot, Zero-Shot, Retrieval-Augmented. Decomposition patterns: Step-Back Prompting, Prompt Chaining, Task Decomposition, Metacognitive Prompting. Each pattern includes when to use it, a full copyable example, difficulty level, and practical tips.
How to use
- 1 Filter by category to browse a specific type of pattern.
- 2 Click any pattern card to expand its full explanation.
- 3 Click "Copy" to copy the example prompt directly to your clipboard.
- 4 Difficulty badges (Beginner / Intermediate / Advanced) help you pick patterns suited to your experience.
- What is Chain of Thought prompting?
- Chain of Thought (CoT) prompting asks the model to show its reasoning step by step before giving a final answer. Adding "Let's think step by step" or providing worked examples of multi-step reasoning dramatically improves accuracy on math, logic, and multi-step tasks. Introduced by Wei et al. (2022) at Google Brain.
- What is the ReAct pattern?
- ReAct (Reasoning + Acting) interleaves reasoning steps with tool calls or actions. The model alternates between Thought (what to do), Action (call a tool or search), and Observation (result). This pattern underlies most modern AI agents and tool-use frameworks like LangChain Agents and AutoGPT.
- What is few-shot vs zero-shot prompting?
- Zero-shot prompting gives the model only an instruction with no examples ("Translate to French: Hello"). Few-shot prompting includes 2-5 input/output examples before the real task, demonstrating the desired format or style. Few-shot is more reliable for novel tasks; zero-shot tests the model's generalization.
- What is Tree of Thoughts?
- Tree of Thoughts (ToT) extends Chain of Thought by exploring multiple reasoning branches in parallel and evaluating intermediate steps. Rather than committing to one reasoning path, the model considers alternatives and backtracks. Best for tasks requiring planning, search, or creative problem-solving. More expensive (multiple completions per step) but significantly more accurate on hard reasoning tasks.