preloader
blog post

Prompting Best Practices: Chain-of-Thought Reasoning

author image

Make the AI Show Its Work

When you ask a human expert to solve a complex problem, they think through it step by step. AI models are the same—but only if you ask them to.

Chain-of-thought prompting makes AI reason explicitly, improving accuracy on complex tasks.

What Is Chain-of-Thought?

Chain-of-thought (CoT) prompting asks the AI to work through a problem step by step before giving the final answer.

Without CoT: “What’s 17 × 24?” Response: “408” (might be wrong, no verification possible)

With CoT: “What’s 17 × 24? Show your reasoning step by step.” Response: “Let me work through this:

  • 17 × 24 = 17 × (20 + 4)
  • 17 × 20 = 340
  • 17 × 4 = 68
  • 340 + 68 = 408 The answer is 408.”

The explicit reasoning catches errors and builds confidence.

Why It Works

Chain-of-thought improves accuracy because:

  1. Breaks complex problems into simple steps
  2. Each step can be verified
  3. Errors are visible and correctable
  4. Forces logical progression

Research shows 10-40% accuracy improvement on complex reasoning tasks with CoT prompting.

Simple CoT Triggers

Add these phrases to activate chain-of-thought reasoning:

  • “Think through this step by step”
  • “Show your reasoning”
  • “Walk me through your thought process”
  • “Let’s work through this together”
  • “Explain your logic”

Example: “Should we build or buy this feature? Think through the key factors step by step before making a recommendation.”

Structured CoT

For complex decisions, provide a reasoning structure:

“Evaluate whether we should migrate to Kubernetes.

Work through these steps:

  1. Current state: What’s our existing infrastructure?
  2. Requirements: What do we need that we don’t have?
  3. Kubernetes benefits: How would K8s address those needs?
  4. Kubernetes costs: What’s the migration effort and ongoing overhead?
  5. Alternatives: What else could solve our requirements?
  6. Recommendation: Based on this analysis, what should we do?”

The structure ensures comprehensive analysis.

CoT for Code

Chain-of-thought is powerful for debugging and code analysis:

“This function is returning incorrect results.

def calculate_discount(price, discount_pct):
    discount = price * discount_pct
    return price - discount

Walk through what happens when calculate_discount(100, 20) is called. Show each step and identify where it goes wrong.”

The step-by-step trace reveals the bug (expecting 20% but getting 20 × 100 = 2000 discount).

CoT for Analysis

Business analysis benefits from explicit reasoning:

“Our trial conversion rate dropped from 25% to 18% last quarter.

Analyze this step by step:

  1. What factors typically affect trial conversion?
  2. What changed in our product last quarter?
  3. What changed in our market/competition?
  4. What does the data suggest about which factor is primary?
  5. What experiments would validate or invalidate each hypothesis?”

When to Use Chain-of-Thought

Best for:

  • Math and calculations
  • Multi-step reasoning
  • Code debugging
  • Business analysis
  • Decision making
  • Root cause analysis

Not necessary for:

  • Simple factual questions
  • Creative writing
  • Translation
  • Summarization

Use CoT when getting the reasoning right matters.

Verifying CoT Reasoning

The explicit reasoning lets you verify:

  1. Are the steps logical?
  2. Are there gaps in the reasoning?
  3. Are assumptions stated?
  4. Is the conclusion supported by the steps?

If you spot an error mid-chain, point it out:

“In step 3, you assumed X, but actually Y is true. Re-analyze from step 3 with this correction.”

Zero-Shot vs. Few-Shot CoT

Zero-shot CoT: Just ask for step-by-step reasoning “Solve this problem. Think step by step.”

Few-shot CoT: Provide examples of step-by-step reasoning “Here’s how to approach this type of problem:

Example: [Problem] Step 1: [Reasoning] Step 2: [Reasoning] Answer: [Solution]

Now solve this problem using the same approach: [New Problem]”

Few-shot CoT is more powerful but requires more setup.

Common CoT Patterns

Problem-solving: “1. Understand the problem 2. Identify constraints 3. Generate options 4. Evaluate each option 5. Select best approach 6. Verify solution”

Debugging: “1. Reproduce the issue 2. Identify expected vs actual behavior 3. Trace execution flow 4. Locate divergence point 5. Identify root cause 6. Propose fix”

Decision-making: “1. Define the decision 2. List options 3. Identify criteria 4. Evaluate options against criteria 5. Make recommendation 6. State assumptions”

The CoT Checklist

When using chain-of-thought:

  • Is this task complex enough to benefit from CoT?
  • Did I ask for explicit reasoning?
  • Did I provide structure (if helpful)?
  • Am I verifying the reasoning, not just the answer?
  • Can I point out errors mid-chain if needed?

Think step by step. Get better answers.

Practice chain-of-thought prompting in Calliope →

Related Articles