intermediateChapter 6 of 12
Precognition (Thinking Step by Step)
Chain-of-thought prompting · Thinking tags · Reasoning before answering
Let Claude Think Before Answering
For complex tasks — classification, math, analysis — Claude performs better when it reasons through the problem before giving a final answer. This is called chain-of-thought prompting.
The Scratchpad Pattern
Ask Claude to work through its reasoning in <thinking> tags, then give the final answer in <answer> tags:
Classify this support email. First, think through the reasoning
in <thinking> tags. Then give your final classification in <answer> tags.
This separation has two benefits:
- Better accuracy — reasoning first leads to better conclusions.
- Inspectable logic — you can see why Claude made a decision.
When to Use It
- Classification tasks with ambiguous cases
- Math or logic problems
- Multi-step analysis
- Any task where you want to audit the reasoning
Key Takeaways
- Ask Claude to think step-by-step in
<thinking>tags before answering. - Put the final answer in
<answer>tags for clean extraction. - This pattern dramatically improves accuracy on complex or ambiguous tasks.
Exercises
12
Email Classification
Write a prompt that classifies customer support emails into categories. Claude should output the correct classification including the letter (A-D) and category name, and ONLY that.
Exact Classification Formatting
Refine the output of the email classifier so the answer is wrapped in <answer> tags containing only the letter. For example: <answer>B</answer>.