Chain-of-Thought Prompting

Prompting

Definition

A prompting strategy that instructs Claude to reason step-by-step before providing a final answer. Improves accuracy on complex reasoning tasks by making intermediate steps explicit. Can be triggered by instructions like 'think step by step' or via extended thinking.

Example Usage

Add 'Think through this step by step before providing your final answer' to the system prompt for complex multi-step reasoning tasks.

Why It Matters for the CCA-F Exam

CCA-F questions on CoT focus on two things: (1) when to apply it (multi-step reasoning, not simple lookups), and (2) how it relates to extended thinking — they are complementary, not the same feature. Expect scenario questions asking you to choose between a CoT instruction and enabling extended thinking for a given task type.

In Depth

Chain-of-thought (CoT) prompting instructs the model to produce intermediate reasoning steps before committing to a final answer. Rather than jumping directly to a conclusion, the model works through the problem in visible increments — similar to showing work in a mathematics exam — which meaningfully improves accuracy on multi-step reasoning tasks.

Why it helps. Language models generate tokens sequentially; each token conditions the next. By generating a reasoning trace first, the model effectively primes its own context with correct partial conclusions before writing the answer. Tasks involving arithmetic, logic chains, classification with dependencies, or code debugging all benefit substantially. Tasks with single-step factual lookups benefit little.

Triggering CoT in the prompt. The simplest form is a natural-language instruction: *"Think through this step by step before giving your final answer."* More structured variants use XML tags to partition the reasoning from the answer:

Think through the problem inside <thinking> tags, then write
your final answer inside <answer> tags.

This partitioning makes it easy to strip the scratchpad from the final response programmatically, and it lets you inject reviewer checks on the reasoning trace independently.

CoT vs. extended thinking. Explicit CoT lives entirely in the visible output and is controlled through prompting. Extended thinking uses a separate internal reasoning mechanism (thinking: {type: "adaptive"}) where the model allocates reasoning compute before producing a response. The internal trace may be returned as a summarized block (thinking.display: "summarized") or omitted entirely. The two techniques are complementary — you can use XML-tagged CoT for visible, auditable reasoning while relying on extended thinking for problems that benefit from deeper computational search.

Cost-accuracy trade-off. CoT increases output token count, which increases cost and latency. For high-stakes, low-volume tasks this trade-off is almost always worth it. For high-volume, lower-stakes tasks, test whether a shorter prompt with few-shot examples achieves comparable accuracy at lower cost before enabling CoT across the board. See Few-Shot Prompting Techniques for a direct comparison of when each approach wins.

How It Compares

DimensionChain-of-Thought (prompt)Extended Thinking (API)
Where reasoning appearsIn the response contentIn a separate thinking block (optional display)
Control mechanismNatural language instructionthinking: {type: "adaptive"} + output_config.effort
Auditable by downstream codeYes — parse output contentPartial — only if thinking.display: "summarized"
Token costIncreases output tokensIncreases internal compute; some output overhead
Best forVisible, step-by-step walkthroughsDeep computational reasoning, hard search problems

Example

XML tags partition the visible reasoning trace from the final answer, making it easy to extract `<answer>` programmatically while retaining the scratchpad for debugging.

python
messages = [
    {
        "role": "user",
        "content": (
            "A pipeline has three stages. Stage A takes 4 minutes. "
            "Stage B takes 7 minutes but can run in parallel with A. "
            "Stage C takes 3 minutes and must wait for both A and B. "
            "What is the minimum total pipeline duration?\n\n"
            "Think through this step by step inside <thinking> tags, "
            "then give only the final number inside <answer> tags."
        )
    }
]
# Expected response structure:
# <thinking>
# A and B run in parallel: max(4, 7) = 7 min
# C starts after both: 7 + 3 = 10 min
# </thinking>
# <answer>10</answer>

Frequently Asked Questions

Does chain-of-thought always improve accuracy?

Not always. CoT adds value for tasks with multiple dependent steps, logical inference, or arithmetic. For single-step factual lookups or classification with clear criteria, CoT can actually introduce drift by over-thinking a simple answer. Reserve it for genuinely complex tasks.

What is the difference between chain-of-thought and extended thinking?

Chain-of-thought is a prompting technique — you ask the model to reason in its visible output. Extended thinking is an API feature where the model performs internal reasoning before generating its response, controlled via `thinking: {type: "adaptive"}`. The internal trace can be returned as a summarized block or omitted. They are complementary: CoT gives you auditable visible reasoning; extended thinking provides deeper computational search that may not be fully visible.