Chain-of-Thought Reasoning
Reviewed & published by Brayan K
Chain-of-thought prompting means asking the AI to show its work — to reason through a problem step by step instead of jumping straight to an answer. For anything that takes more than one mental hop (math, logic, planning), this simple habit dramatically improves accuracy.
Part of the free Prompt Engineering course at LearnCodingFast — hands-on lessons with worked examples and the output they print, plus practice exercises and a quick quiz.
Tools like ChatGPT, Claude, and Gemini are far more reliable when you let them think out loud. This lesson teaches you the magic phrases — and when to use them.
What You'll Learn in This Lesson
- What 'chain-of-thought' really means in plain English
- The phrase 'let's think step by step' and why it works
- Breaking big problems into smaller, ordered steps
- Getting reasoning AND a short final answer
- When step-by-step helps — and when to skip it
- Spotting where the logic went wrong and fixing it
1 Ask the AI to show its work
When a problem has several steps, an instant answer is a guess. Asking the model to reason step by step lets it build on each intermediate result. Same question, two prompts:
If a shirt costs $40 with a 25% discount
and 8% tax, what's the final price?
Just give me the number.Demanding only the number invites a careless slip on a multi-step calculation.
A shirt costs $40 with a 25% discount,
then 8% tax. Work through it step by step,
showing each calculation, then give the
final price on the last line.Reasoning first, answer last — easy to check, far less likely to be wrong.
2 Break big problems into ordered steps
You don’t have to leave the decomposition to the AI. Listing the sub-tasks yourself produces more complete, better-organised answers:
| Instead of | Try |
|---|---|
| “Plan my launch.” | “Plan my launch in steps: 1) audience 2) message 3) channels 4) schedule. Do each in order.” |
| “Write me an essay.” | “First outline the essay, then write it section by section.” |
| “Solve this puzzle.” | “List the clues, deduce one fact at a time, then state the solution.” |
Naming the steps gives the model a checklist — and gives you a structure you can correct one piece at a time.
3 Reasoning AND a tidy final answer
Worried that step-by-step answers are too long? Ask for both. You get the accuracy of reasoning plus a clean conclusion you can copy:
Reason through this step by step.
Then, on the final line, write:
FINAL ANSWER: <your concise answer>This pattern is perfect when you want to trust the answer but also paste it somewhere clean.
📋 Copy-paste chain-of-thought template
Here's the problem: <describe it>.
Work through it step by step, showing each
step of your reasoning. Check your work as
you go. Then give the final answer clearly
on the last line.Try it for real
The reason to ask for steps is not that the model thinks harder — it is that each step becomes a claim you can test. Run this: four labelled steps, four chances to catch an error. A single number at the end is unfalsifiable, which is the whole problem with asking for one.
# "Let's think step by step" helps because it makes the steps INSPECTABLE.
# A hidden answer you cannot check is worth less than a shown one you can.
# A model's shown working on: "A shop sells 3 packs of 12 for £4.50 each.
# There is 20% off the total. What is the final price?"
steps = [
("packs x per pack", 3 * 12, 36),
("total before discount", 3 * 4.50, 13.50),
("discount amount", 13.50 * 0.20, 2.70),
("final price", 13.50 - 2.70, 10.80),
]
print("Checking each step against arithmetic:\n")
all_ok = True
for label, computed, claimed in steps:
ok = abs(computed - claimed) < 0.005
all_ok &= ok
print(f" {'OK ' if ok else 'BAD'} {label:<22} model said {claimed:>6} actually {round(computed, 2):>6}")
print()
print("all steps check out:", all_ok)
print()
print("This is the real value of chain of thought: not that the model 'thinks",
"harder',\nbut that each step becomes a claim you can test. A single number",
"at the end\nis unfalsifiable; four labelled steps are four chances to catch",
"an error.")# 🎯 YOUR TURN — check the working, find the bad step.
# The model's shown steps for: "A train travels 240 km in 3 hours,
# then 150 km in 2 hours. What is the average speed for the whole trip?"
steps = [
("total distance", 240 + 150, 390),
("total time", 3 + 2, 5),
("average speed", 390 / 5, 80), # the model wrote 80
]
bad = []
for label, computed, claimed in steps:
# 1) A step is wrong when the arithmetic disagrees with what was claimed.
if abs(computed - claimed) ___ 0.005:
# 👉 replace ___ with >
bad.append(label)
print(f"{label:<16} claimed {claimed:<6} actual {round(computed, 2)}")
# 2) Report how many steps failed.
print()
print("bad steps:", ___)
# 👉 replace ___ with bad
# ✅ Expected output:
# total distance claimed 390 actual 390
# total time claimed 5 actual 5
# average speed claimed 80 actual 78.0
#
# bad steps: ['average speed']Common Mistakes (and the fix)
- Demanding only the answer on a multi-step problem. — Let it reason first; ask for the number last.
- Using step-by-step on trivial lookups. — For a single fact, a direct answer is better.
- Leaving all the structure to the AI. — Name the sub-steps yourself for big tasks.
- Not reading the reasoning. — The visible steps are where you catch and fix mistakes.
⏱ Test Yourself — Timed Quiz
10 quick questions, 12 seconds each. Instant feedback — beat the clock!
🎉 Lesson Complete
- ✅ Ask the AI to reason step by step on multi-step problems
- ✅ “Let’s think step by step” switches the model from guessing to reasoning
- ✅ Break big tasks into ordered sub-steps yourself
- ✅ Ask for reasoning AND a tidy final answer on the last line
- ✅ Skip step-by-step for simple, single-fact questions
Practice quiz
What does 'chain-of-thought' prompting ask the AI to do?
- Answer faster
- Use shorter words
- Show its reasoning step by step
- Skip the explanation
Answer: Show its reasoning step by step. Chain-of-thought means asking the model to reason through the steps, not just blurt an answer.
Which phrase triggers step-by-step reasoning most reliably?
- 'let's think step by step'
- 'be quick'
- 'just the answer'
- 'use big words'
Answer: 'let's think step by step'. Phrases like 'think step by step' nudge the model to lay out intermediate steps.
Why does showing the steps often improve accuracy on hard problems?
- It makes the model run twice
- It uses a different model
- It is always slower so more careful
- Breaking the problem into smaller steps reduces leaps and catches errors
Answer: Breaking the problem into smaller steps reduces leaps and catches errors. Working in small steps lets the model build on intermediate results instead of guessing the final answer.
For a tricky math word problem, the best instruction is…
- 'give me the number only'
- 'work through it step by step, then give the final answer'
- 'guess'
- 'use a calculator emoji'
Answer: 'work through it step by step, then give the final answer'. Reasoning first, then the final answer, tends to be more reliable on multi-step problems.
When is chain-of-thought LEAST necessary?
- A simple lookup like 'what is the capital of France'
- Multi-step logic puzzles
- Planning a project
- Debugging tangled logic
Answer: A simple lookup like 'what is the capital of France'. Trivial single-step facts don't need step-by-step reasoning; reserve it for multi-step problems.
What is a good way to break a big request into steps?
- Ask for everything at once with no structure
- Use only one word
- List the sub-tasks and ask the AI to handle them in order
- Forbid any explanation
Answer: List the sub-tasks and ask the AI to handle them in order. Decomposing into ordered sub-tasks helps the model and you follow the logic.
If you want reasoning but a short final answer, you can…
- Not possible
- Say 'reason step by step, then give just the final answer on the last line'
- Only get one or the other
- Use all caps
Answer: Say 'reason step by step, then give just the final answer on the last line'. You can ask for visible reasoning plus a clearly separated final answer.
Asking 'explain your reasoning' is useful because…
- It wastes tokens
- It changes the model
- It hides mistakes
- You can spot where the logic went wrong and correct it
Answer: You can spot where the logic went wrong and correct it. Visible reasoning makes errors easy to catch and correct in a follow-up.
Which prompt best decomposes a planning task?
- 'plan my trip'
- 'Plan my trip in steps: 1) pick dates 2) budget 3) flights 4) hotels — do each in order'
- 'trip???'
- 'make it good'
Answer: 'Plan my trip in steps: 1) pick dates 2) budget 3) flights 4) hotels — do each in order'. Naming the ordered steps guides a structured, complete response.
A risk of forcing long reasoning on a simple question is…
- Always better
- It breaks the AI
- Slower, wordier answers when a direct reply would do
- Nothing ever
Answer: Slower, wordier answers when a direct reply would do. Use step-by-step reasoning where it helps; for simple facts it just adds noise.
Continue this course
- Previous: Few-Shot Prompting with Examples
- Next: Controlling the Output Format — Get JSON, tables, bullet lists or a set length — exactly as you need it
Frequently asked questions
What is chain-of-thought prompting in plain English?
It's simply asking the AI to show its work. Instead of demanding an instant answer, you tell it to reason through the problem step by step. Like a student showing each line of a math problem, this often leads to more accurate results on anything that takes more than one mental hop.
Does telling the AI to 'think step by step' really help?
Yes, especially for multi-step problems — math, logic puzzles, planning, or tangled reasoning. Walking through intermediate steps reduces the chance the model jumps to a wrong conclusion. For a simple fact lookup it's unnecessary and just makes the answer longer.
Can I get the reasoning but still a short final answer?
Absolutely. Ask for both: 'Reason through it step by step, then give just the final answer on the last line.' You get the benefit of careful reasoning plus a tidy, easy-to-copy conclusion.
How do I break a big task into steps for the AI?
List the sub-tasks yourself and ask the AI to do them in order. For example: 'Plan this in steps: 1) outline 2) draft 3) edit. Do each before moving on.' Decomposing the work makes long answers more complete and easier to follow.