Chain-of-Thought Prompting
3 CoT templates that improve AI reasoning accuracy — zero-shot, self-consistency, and scratchpad. Copy-paste ready for Claude and ChatGPT.
When to Use Chain-of-Thought vs When to Skip It
| Task type | Use CoT? | Why |
|---|
| Multi-step math / logic | ✓ Yes | Model checks work before committing to answer |
| Legal / policy analysis | ✓ Yes | Explicit reasoning catches overlooked exceptions |
| Complex technical decisions | ✓ Yes | Trade-off analysis benefits from explicit steps |
| Simple factual lookup | ✗ No | Adds tokens, no accuracy gain |
| Short creative writing | ✗ No | Disrupts natural tone; use style examples instead |
| Structured data extraction | ✗ No | Schema + few-shot examples work better |
Zero-Shot CoT — Add One Phrase
The simplest CoT technique. Adding "Think step by step before answering" improves accuracy on multi-step problems without any examples.
Without CoT
A server processes 150 requests/minute. It can handle a maximum of 10,000 requests before needing a restart. If traffic doubles every hour starting from 9am, when will the server need its first restart?
With CoT — optimized
A server processes 150 requests/minute at 9am. Traffic doubles every hour. The server handles a maximum of 10,000 requests before restart.
Think step by step:
1. Calculate total requests per hour at each doubling interval.
2. Sum cumulative requests until the total exceeds 10,000.
3. State the exact hour when the restart is needed.
Show all calculations, then give your final answer on the last line as: "First restart needed at: [time]"
💡 Adding the explicit step structure and final-line format spec turns a math problem Claude might rush into one it reasons through carefully — and formats predictably.
Self-Consistency CoT — Force Multiple Paths
For ambiguous or high-stakes decisions, ask the model to reason via 3 independent approaches and reconcile them. Catches reasoning errors that a single path misses.
Without CoT
Should we migrate our database from PostgreSQL to MongoDB for our e-commerce site?
With CoT — optimized
We're deciding whether to migrate our e-commerce PostgreSQL database to MongoDB. Our site has: 2M products, complex relational queries (orders → items → inventory), a 5-person engineering team, and a 6-month roadmap freeze after migration.
Evaluate this decision using 3 independent frameworks:
Framework 1 — Technical fit: What does each database do better for our specific data model?
Framework 2 — Risk analysis: What are the top 3 migration risks and their likelihood?
Framework 3 — Team capacity: Given a 5-person team and 6-month freeze, what's the realistic execution cost?
After completing all 3 frameworks independently, synthesize: do the frameworks agree or conflict? Then give a final recommendation with a one-sentence rationale.
💡 Three independent analysis paths catch blind spots. If frameworks 1 and 2 say "migrate" but framework 3 says "team can't execute it safely," that conflict is the real answer.
CoT with Explicit Scratchpad
Label the reasoning section separately from the final answer. This is especially useful when you only want the conclusion, not the full reasoning chain, in your app output.
Without CoT
Is this contract clause legally enforceable? "Employee agrees to never work in the software industry for 5 years after leaving the company, anywhere in the world."
With CoT — optimized
Analyze whether the following non-compete clause is enforceable. Use the format below.
Clause: "Employee agrees to never work in the software industry for 5 years after leaving the company, anywhere in the world."
<scratchpad>
Reason through each enforceability factor:
- Geographic scope: is "anywhere in the world" reasonable?
- Duration: is 5 years reasonable for software?
- Scope of restriction: is "software industry" narrowly defined?
- Applicable law: how do courts in California, New York, and UK typically treat these?
- Consideration: what does the employee receive in exchange?
</scratchpad>
After your scratchpad analysis, provide:
Verdict: [Likely enforceable / Likely unenforceable / Jurisdiction-dependent]
Rationale: [2 sentences max]
Highest risk jurisdiction for enforcer: [Name]
💡 The <scratchpad> tag tells the model to reason freely without constraining itself to a polished answer. The final structured output is then clean and parseable — the two concerns stay separate.
Quick CoT Phrases That Work
Add any of these to an existing prompt to activate chain-of-thought reasoning — no restructuring needed.
"Think step by step before answering." — universal zero-shot CoT trigger"Show your reasoning, then give your final answer." — makes reasoning visible"Before concluding, check your work." — triggers self-correction"List all assumptions you're making." — surfaces hidden premises"Consider 3 possible interpretations, then pick the most likely one." — self-consistency lite"Break this into sub-problems, solve each, then combine." — divide-and-conquer for complex tasks
→ Auto-apply CoT to my promptFrequently Asked Questions
- What is chain-of-thought prompting?
- Chain-of-thought (CoT) prompting is a technique that instructs an AI model to show its reasoning step by step before giving a final answer. Instead of asking "What is the answer?", you ask "Think through this step by step, then give your answer." This dramatically improves accuracy on multi-step reasoning tasks — math problems, logic puzzles, legal analysis, and anything that requires intermediate deductions — because the model catches its own errors during the reasoning process before committing to a conclusion.
- When should I use chain-of-thought prompting?
- Use chain-of-thought when: (1) The task requires multiple reasoning steps (arithmetic, logic, deduction). (2) You need the model to check its own work before answering. (3) Accuracy matters more than brevity — CoT produces longer outputs. (4) The task involves ambiguous inputs where explicit assumptions help. Avoid CoT for simple lookup tasks (e.g., "What is the capital of France?") — it adds tokens without improving accuracy and makes outputs unnecessarily verbose.
- What is zero-shot chain-of-thought prompting?
- Zero-shot CoT is the simplest form: you just add "Think step by step before answering" (or "Let's think through this") to any prompt, without providing any examples. This works surprisingly well across a wide range of reasoning tasks. It was popularized by the 2022 paper "Large Language Models are Zero-Shot Reasoners" and is now standard practice. Zero-shot CoT requires no examples, so it costs fewer tokens than few-shot CoT while still significantly improving accuracy on multi-step tasks.
- Does chain-of-thought prompting work with Claude?
- Yes — Claude is specifically designed to excel at step-by-step reasoning. Claude Sonnet and Opus models have extended thinking modes (activated via API) that perform even deeper CoT internally before producing a response. For the standard API without extended thinking, simply including "Think step by step" or "Show your reasoning" in the prompt activates CoT behavior. Claude also benefits from explicitly labeling reasoning sections: "Step 1:", "Step 2:", etc. — this structure helps the model organize its logic before concluding.
- How is chain-of-thought different from extended thinking in Claude?
- Standard CoT prompting makes the model's reasoning visible in the response itself — you see the steps in the output. Claude's extended thinking (available via the API with thinking: {type: "enabled"}) performs deeper reasoning in a separate internal "thinking block" before the final response. Extended thinking is more powerful for hard reasoning tasks but costs more tokens. For most production use cases, standard CoT prompting ("think step by step") is the right starting point — reserve extended thinking for tasks that genuinely require deep multi-step deduction.
Add chain-of-thought to any prompt automatically.
The Prompt Improver identifies when CoT would help and injects the right reasoning structure. Free, BYO Anthropic API key.
→ Improve My PromptRelated Prompt Engineering Guides