Precognition: Thinking Step by Step
Asking Claude to reason before answering is one of the most reliable ways to improve accuracy on complex tasks. Learn Chain-of-Thought prompting, the <thinking> tag pattern, and extended thinking mode.
What Chain-of-Thought Prompting Is
Chain-of-Thought (CoT) prompting is the practice of instructing Claude to work through its reasoning explicitly before delivering a final answer. Instead of jumping to a conclusion, Claude narrates its thought process โ each step informing the next โ like showing its work on a math exam.
The term "precognition" captures the intuition: think before you speak. By generating intermediate reasoning steps, Claude dramatically reduces errors on tasks that require multi-step logic, mathematical calculation, nuanced analysis, or careful inference.
Zero-Shot CoT: The Simplest Trigger
The most basic CoT technique requires no examples โ just a simple instruction appended to your prompt:
The <thinking> Tag Pattern
For applications where you want Claude's reasoning to be separable from its answer โ so you can display or hide it, log it, or evaluate it independently โ use the <thinking> tag pattern:
Analyze the following business scenario and recommend a course of action.
First, use <thinking> tags to work through the problem:
- What are the key factors at play?
- What are the trade-offs of each option?
- What assumptions am I making?
After your thinking, provide your recommendation in plain prose.
<scenario>
A Series B SaaS startup (ARR: $8M, burn rate: $600K/month, runway: 14 months)
has two offers: (1) strategic acquisition at 4x ARR from a larger competitor,
or (2) a new funding round at a 20% down round valuation. The founding team
wants to remain independent. Three key engineers have competing offers.
</scenario>
Claude responds with explicit <thinking> XML wrapped around its reasoning, followed by the clean recommendation. Your code can then parse and separate the two sections.
import re
def parse_cot_response(response_text: str) -> dict:
"""Separate thinking from final answer."""
thinking_match = re.search(
r'<thinking>(.*?)</thinking>',
response_text,
re.DOTALL
)
thinking = thinking_match.group(1).strip() if thinking_match else ""
answer = re.sub(r'<thinking>.*?</thinking>', '', response_text, flags=re.DOTALL).strip()
return {"reasoning": thinking, "answer": answer}
Before / After: Direct vs. CoT โ Math Word Problem
CoT for Financial Analysis
You are a financial analyst. Evaluate whether this company is worth
acquiring at the proposed valuation.
Before reaching your conclusion:
1. Calculate the key valuation multiples (EV/Revenue, EV/EBITDA)
2. Compare them to industry benchmarks (note your benchmarks)
3. Assess the qualitative risks
4. Weigh the strategic value
Then provide a final recommendation: Proceed / Negotiate / Pass.
<company_data>
Revenue: $12M ARR (35% YoY growth)
EBITDA: -$2M (investing in growth)
Proposed acquisition price: $60M
Industry: B2B HR tech SaaS
Comparable transactions: typically 5-8x ARR for this growth rate
Strategic fit: fills gap in enterprise product suite
Key risk: 2 of 4 engineers are contractors
</company_data>
Self-Consistency: Asking Claude to Verify Its Own Answer
Self-consistency is a technique where you ask Claude to check its own work โ either by re-solving the problem from scratch, or by explicitly asking it to verify each step of its reasoning:
# Pattern 1: Solve then verify
Solve this logic puzzle step by step.
After reaching your answer, verify it by checking if it satisfies
all the stated constraints. If it doesn't, revise your solution.
# Pattern 2: Independent re-solve
First, solve this problem using approach A.
Then, solve the same problem using a completely different approach.
If both approaches agree, report that answer. If they disagree,
identify which approach has an error and correct it.
# Pattern 3: Confidence-gated verification
Solve this problem step by step.
Rate your confidence in the answer from 1-10.
If confidence is below 8, re-examine your reasoning and identify
the weakest step.
Extended Thinking Mode (Claude 3.7+)
Claude 3.7 Sonnet and later models support extended thinking โ a native API-level feature where Claude generates an internal reasoning trace before producing its response. This is more powerful than prompt-level CoT because the thinking happens in a dedicated scratchpad that isn't constrained by the response format.
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-3-7-sonnet-20250219",
max_tokens=16000,
thinking={
"type": "enabled",
"budget_tokens": 10000 # tokens allocated for internal reasoning
},
messages=[{
"role": "user",
"content": "Design the optimal database schema for a multi-tenant SaaS application that needs row-level security, audit logging, and soft deletes. Consider performance implications."
}]
)
# Response contains two content blocks:
for block in response.content:
if block.type == "thinking":
print("Internal reasoning:", block.thinking)
elif block.type == "text":
print("Final answer:", block.text)
When NOT to Use CoT
CoT increases token usage and latency. It's valuable for complex reasoning but wasteful for: