Task Decomposition and Session Management in Claude Code
👋 In plain words: Big tasks go better when you break them into steps, but there are two ways to do it: a fixed checklist, or a plan you adjust as you learn. This lesson also covers how to continue yesterday's work in Claude Code without starting from zero.
How you split work determines whether Claude stays focused or drowns in context. The exam asks you to choose the right decomposition pattern and the right way to continue work across sessions.
🔑 Key terms
- Decomposition: Splitting a big task into smaller steps.
- Prompt chaining: A fixed sequence of steps decided in advance, where each step's output feeds the next.
- Dynamic decomposition: Planning the next step based on what you just discovered.
- Session: One Claude Code conversation, with its history. It can be resumed later.
- Fork: Copying a session into two independent branches, to try two approaches from the same starting point.
📖 The story in this lesson
Ravi has two jobs this week. He needs to review a 9-file pull request, which is predictable, and to add tests to ShopNest's old, untested payment service, which is not.
💡 Think of it like this
Prompt chaining is following a recipe: you know every step before you start. Dynamic decomposition is cooking with whatever is in the fridge: you open it, see what's there, and decide the next step.
✍️ Prompt chaining vs dynamic decomposition
| Prompt chaining (fixed pipeline) | Dynamic decomposition |
|---|---|
| Steps are known in advance | Next steps depend on what you discover |
| e.g. review each file against a checklist, then an integration pass | e.g. “add tests to this legacy codebase”, “find why billing is slow” |
| Predictable, cheap, testable | Adaptive; plan → investigate → re-plan |
🌍 Real-world example: Recipe or fridge?
Checking 9 changed files against the same checklist is a recipe, so Ravi uses a fixed chain. 'Add tests to the payment service' is a fridge job: he doesn't know what's inside until Claude explores the code, so the plan has to adapt.
🔍 Large code reviews: per-file plus integration
Reviewing many files in one pass dilutes attention: some files get deep feedback, others shallow, and identical code can get contradictory verdicts. Split the review into per-file passes for local issues plus a separate integration pass for cross-file data flow. A bigger context window doesn’t fix this — attention quality is the problem, not space.
🌍 Real-world example: The review that missed file 7
Reviewing all 9 files in one go, Claude gave detailed notes on the first files and only a line each on the rest. Ravi switches to one pass per file plus a final pass that checks how data moves between the files. Every file now gets the same attention.
📘 Open-ended tasks
For “add comprehensive tests to a legacy service”: map the structure, identify high-impact or high-risk areas, create a prioritised plan, then adapt it as dependencies are discovered.
🌍 Real-world example: Testing the legacy payment service
Claude first maps the service and finds the refund calculation handles money but has no tests. It plans: refunds first, then currency conversion, then logging. When it discovers a hidden dependency on a tax module, it updates the plan instead of following the old one blindly.
💾 Resume, fork or start fresh?
| Situation | Use |
|---|---|
| Continue yesterday’s named investigation; context still mostly valid | --resume <session-name> — and tell the agent which files changed |
| Compare two approaches from the same analysis | fork_session |
| Earlier tool results are largely stale | Start fresh and inject a structured summary |
🌍 Real-world example: Back to work after the weekend
On Monday, Ravi resumes Friday's named session and says: 'Since Friday, refund.py and tax.py changed.' Claude re-checks only those two files. To compare two refactoring ideas, he forks the session. After a major rewrite he starts fresh with a short summary instead.
claude --resume payment-tests🛠️ Try it yourself (about 8 minutes)
- List five tasks from your current work.
- Label each one 'recipe' (fixed chain) or 'fridge' (dynamic).
- For one recipe task, write the fixed steps.
- For one fridge task, write only the first exploration step.
✅ You are done when: every task is labelled, with a one-line reason why.
🧪 Exam-Style Practice Questions
Try these before opening the answers. They use the same scenario style as the real exam.
Question 1. "Review this PR": each of 9 files should get the same checklist, followed by a cross-file data-flow check. Which decomposition fits?
- A. Three random full-PR passes with voting
- B. Dynamic adaptive decomposition
- C. A single pass with a larger context
- D. Prompt chaining: per-file passes, then an integration pass
Show answer
Answer: D. Predictable, multi-aspect work suits a fixed chain. B suits open-ended investigation. C: attention gets diluted. A: voting suppresses real but intermittent findings.
Question 2. Yesterday you analysed a module in a named session. Overnight, teammates changed 3 of its 40 files. What's the best way to continue?
- A. Use the Batches API
- B. Start over and re-read all 40 files
- C.
--resume <name>and tell the agent which 3 files changed so it re-analyses them - D. Resume without mentioning the changes
Show answer
Answer: C. Most of the prior context is still valid, so resume and point at what changed. B is wasteful. D risks stale conclusions. A is irrelevant.
Question 3. You want to compare two refactoring strategies starting from the same codebase analysis. Which feature fits?
- A.
fork_session - B.
/memory - C.
/compact - D.
--print
Show answer
Answer: A. Forking creates independent branches from a shared baseline. C shrinks context. D is non-interactive mode. B inspects memory files.
📝 Assignment
Do these tasks in order. Each one has a Done when check, so you know when it is complete. The stretch task is optional but close to what the exam expects from an architect. Keep your answers in one notes file or Git repository, and revisit them in your final week of revision together with the cheat sheet in the last lesson of this course.
- Task 1: Classify five tasks from your own work as prompt chaining or dynamic decomposition.
✅ Done when: Each of your five tasks is labelled, with a one-line reason that mentions whether its steps are known in advance. - Task 2: Plan a review of a 12-file pull request as per-file passes plus an integration pass.
✅ Done when: Your plan lists every file pass plus a separate integration pass, and says what the integration pass checks. - Stretch: in Claude Code, resume a named session after changing two files and tell it exactly which files changed.
✅ Done when: Claude re-analyses only the two changed files and does not re-read the whole codebase.
❓ Frequently Asked Questions
🤔 What is prompt chaining?
A fixed sequence of focused steps, such as reviewing each file and then running an integration pass. It suits predictable work.
🤔 When should I use dynamic decomposition?
For open-ended tasks where the next steps depend on what you discover, such as adding tests to a legacy codebase.
🤔 Does a bigger context window fix inconsistent reviews?
No. The problem is attention dilution, so split the review into focused passes.
🤔 When should I fork a session?
When you want to compare two approaches starting from the same analysis.
🏁 Summary
- Predictable multi-aspect work → prompt chaining; open-ended work → dynamic decomposition.
- Big reviews → per-file passes plus an integration pass.
- Resume when context is valid, fork to compare approaches, start fresh with a summary when it is stale.
Next, continue with Claude Tool Design: Descriptions, Tool Distribution and tool_choice.
Independent study material by SQA Tools. Not affiliated with, endorsed by or sponsored by Anthropic. Claude is a trademark of Anthropic. Mock questions are original practice items, not real exam content. Exam facts checked against Anthropic's official exam guides and certification FAQ on 11 November 2026.