# Chain-of-Thought and Task Decomposition

> Give the model room to reason, and split big jobs into a chain of focused prompts that are easier to control and debug. Free notes, key concepts, resources and...

Canonical: https://www.internhack.in/roadmaps/tracks/ai-engineer/chain-of-thought
Last updated: 2026-11-28

Give the model room to reason, and split big jobs into a chain of focused prompts that are easier to control and debug.

Intermediate · about 3 hours · difficulty 3/5

Learn first: [Few-Shot Examples](https://www.internhack.in/roadmaps/tracks/ai-engineer/few-shot-prompting), [Reasoning Models and Thinking Budgets](https://www.internhack.in/roadmaps/tracks/ai-engineer/reasoning-models)

Models reason better when they can work through a problem in text before committing to an answer. **Chain-of-thought (CoT)** prompting asks for that explicitly.

### Techniques

- **Think then answer**: ask the model to reason inside a `<thinking>` section and give the final answer in an `<answer>` section, so your code can extract just the answer.
- **Guided steps**: list the steps you want ("first identify the entities, then check each against the policy...").
- **Use reasoning models** where available instead of hand-built CoT; they do this natively and you mostly need clear goals.

### Prompt chaining

A single giant prompt that researches, drafts, critiques and formats is hard to debug. Split it:

1. Extract relevant facts.
2. Draft an answer from those facts.
3. Check the draft against rules or sources.
4. Format for output.

Each step has a narrow prompt, a testable output and can use a different (cheaper) model. This is the simplest form of a **workflow**, which you will build on in the agents section.

### Pitfalls

CoT adds output tokens and latency; skip it for easy tasks. The written reasoning is not a faithful explanation of what the model "really" computed, so do not rely on it as an audit trail.

### Good enough to move on

You can show a task where CoT or chaining measurably improves accuracy, and you can parse the final answer out reliably.

## Key concepts

- **Think-then-answer prompting**
- **Guided step-by-step instructions**
- **Prompt chaining**
- **Self-critique and revision steps**
- **Self-consistency (majority vote)**

## Mini project

Turn a one-shot 'write a cover letter from this resume and job post' prompt into a three-step chain (extract matching skills, draft, critique and revise), and compare outputs side by side.

## Check yourself

When is splitting a task into a chain of prompts better than a single prompt with chain-of-thought?

## Free resources

- [Prompting Guide: chain-of-thought](https://www.promptingguide.ai/techniques/cot) (DAIR.AI)
- [Chain-of-Thought Prompting paper](https://arxiv.org/abs/2201.11903) (arXiv)

Previous: [Few-Shot Examples](https://www.internhack.in/roadmaps/tracks/ai-engineer/few-shot-prompting) · Next: [Structured Prompts and Long Context](https://www.internhack.in/roadmaps/tracks/ai-engineer/structured-prompts)

## More in Prompt Design That Holds Up

- [Clear Instructions and System Prompts](https://www.internhack.in/roadmaps/tracks/ai-engineer/prompt-fundamentals)
- [Few-Shot Examples](https://www.internhack.in/roadmaps/tracks/ai-engineer/few-shot-prompting)
- [Chain-of-Thought and Task Decomposition](https://www.internhack.in/roadmaps/tracks/ai-engineer/chain-of-thought)
- [Structured Prompts and Long Context](https://www.internhack.in/roadmaps/tracks/ai-engineer/structured-prompts)
- [Prompt Templates, Versioning and Iteration](https://www.internhack.in/roadmaps/tracks/ai-engineer/prompt-management)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [AI Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/ai-engineer)
