Issue 17 | Claude Cowork: Automatic Multi-step Task Decomposition
🎯 Learning Objectives
By the end of this issue, you will master:
- How Claude automatically decomposes complex tasks into multi-step execution plans
- The internal working mechanism of multi-turn tool call chains
- How to observe and guide Claude's task planning process
- Practical techniques for complex cross-file workflows
📖 Core Concepts Explained
17.1 What is "Task Decomposition"?
Human approach:
"Build a REST API with authentication"
→ Mentally list steps:
1. Design data models
2. Write routes
3. Add authentication middleware
4. Write tests
→ Execute sequentially
Claude Code's approach:
Receives the same instruction
→ Internally infers an execution plan (Agentic Reasoning)
→ Calls 40+ tools to execute automatically
→ Automatically adjusts the plan if issues arise midway
Key difference:
Human: Plan first → then execute (separate)
Claude: Plan while executing → execute while adjusting (integrated)
17.2 Claude's Internal Execution Loop
╭────────────── Agent Loop ──────────────────╮
│ │
│ Receive Instruction │
│ │ │
│ ▼ │
│ Infer what to do next (Think) │
│ │ │
│ ▼ │
│ Select and Execute Tool (Act) │
│ │ │
│ ▼ │
│ Observe Result (Observe) │
│ │ │
│ ├─ Success → Infer next step ──→ Back to Think │
│ │ │
│ └─ Failure → Adjust strategy ──→ Back to Think │
│ │
│ Until all steps complete → Output Summary│
│ │
╰────────────────────────────────────────────╯
This is the ReAct (Reasoning + Acting) pattern
17.3 Typical Decomposition of Complex Tasks
User Instruction:
"Add JWT user authentication to this Express project"
Claude's Internal Decomposition:
Step 1: Understand existing architecture
├─ Read package.json
├─ Glob src/**/*.ts
└─ Read src/index.ts, src/routes/...
Step 2: Install dependencies
└─ Bash: npm install jsonwebtoken bcrypt
Step 3: Create data model
└─ Write src/models/User.ts
Step 4: Create authentication service
└─ Write src/services/auth.ts
Step 5: Create authentication middleware
└─ Write src/middleware/auth.ts
Step 6: Create authentication routes
└─ Write src/routes/auth.ts
Step 7: Integrate into main application
└─ Edit src/index.ts
Step 8: Protect existing routes
└─ Edit src/routes/users.ts (add auth middleware)
Step 9: Verify
├─ Bash: npx tsc --noEmit
└─ Bash: npm test
Total: ~20 tool calls, fully automated
💻 Simulate Claude TUI Interaction
Scenario: Observing Claude's Multi-Step Execution Process
> Please add a complete JWT user authentication system to this project
╭─ Claude ─────────────────────────────────────────────╮
│ │
│ Let me first understand the current project architecture. │
│ │
│ 🔍 Tool: Read → package.json │
│ Framework: Express 4.18, TypeScript, Prisma ORM │
│ │
│ 🔍 Tool: Glob → src/**/*.ts │
│ 📁 Project structure: │
│ ├── src/index.ts │
│ ├── src/routes/users.ts │
│ ├── src/routes/products.ts │
│ └── src/db/prisma.ts │
│ │
│ 🔍 Tool: Read → prisma/schema.prisma │
│ No User model currently exists, needs to be created. │
│ │
│ Okay, my plan is: │
│ 1️⃣ Create User Model (Prisma) │
│ 2️⃣ Install JWT + bcrypt dependencies │
│ 3️⃣ Implement authentication service (register/login/verify) │
│ 4️⃣ Create auth middleware │
│ 5️⃣ Add auth routes │
│ 6️⃣ Protect existing routes │
│ 7️⃣ Run tests for verification │
│ │
│ Starting execution... │
│ │
│ ⚙️ Tool: Edit → prisma/schema.prisma │
│ Added User model with email, password, role fields │
│ │
│ ⚙️ Tool: Bash │
│ $ npm install jsonwebtoken bcrypt │
│ $ npm install -D @types/jsonwebtoken @types/bcrypt │
│ ✅ Dependencies installed │
│ │
│ ⚙️ Tool: Bash │
│ $ npx prisma migrate dev --name add-user │
│ ✅ Migration applied │
│ │
│ ⚙️ Tool: Write → src/services/auth.ts │
│ Created: register(), login(), verifyToken() │
│ │
│ ⚙️ Tool: Write → src/middleware/auth.ts │
│ Created: requireAuth middleware │
│ │
│ ⚙️ Tool: Write → src/routes/auth.ts │
│ POST /auth/register, POST /auth/login │
│ │
│ ⚙️ Tool: Edit → src/index.ts │
│ Added: import authRouter, app.use('/auth', ...) │
│ │
│ ⚙️ Tool: Edit → src/routes/users.ts │
│ Added: requireAuth middleware to all routes │
│ │
│ ⚙️ Tool: Bash │
│ $ npx tsc --noEmit │
│ ✅ No TypeScript errors │
│ │
│ ⚙️ Tool: Bash │
│ $ npm test │
│ ✅ 12 tests passed (3 new auth tests) │
│ │
│ 🎉 JWT authentication system completed! │
│ Created 3 files, modified 3 files. │
│ │
╰──────────────────────────────────────────────────────╯
💻 Code Demo
# ✅ Have Claude show the execution plan without executing
# Switch to Plan Mode (Shift+Tab)
> Describe how you would add payment system integration
# Claude will output a detailed plan, but not execute it
# ✅ Limit the complexity of a single task
claude "Only do steps 1-3: create data models and authentication services,
I'll ask you to do the routes and middleware next time"
# ✅ Observe tool call details
# Each of Claude's tool calls will be displayed in real-time in the terminal
# You can interrupt at any time by pressing Ctrl+C
# ✅ Guide Claude's execution order
claude "Execute in the following order:
1. First create test files (TDD approach)
2. Then write implementation code
3. Finally run tests"
🔧 Tools Involved
| Tool | Role in Task Decomposition | Description |
|---|---|---|
Read |
Understanding Phase | Reads existing code to understand architecture |
Glob |
Discovery Phase | Scans project structure |
Bash |
Execution Phase | Installs dependencies, runs migrations, tests |
Write |
Creation Phase | Generates new files |
Edit |
Integration Phase | Modifies existing files, connects new and old code |
📝 Key Takeaways from this Issue
- Claude Code uses the ReAct pattern: reasoning, executing, and observing simultaneously
- Complex tasks are automatically decomposed into multi-step tool call chains
- Plan Mode allows previewing the execution plan without actual execution
- Execution granularity can be controlled by limiting the scope of steps
- Upon failure, Claude automatically adjusts its strategy instead of directly throwing an error