Subagents & Delegation
Imagine you're sitting at your desk working on a complex feature. Suddenly you need a piece of information: How is authentication structured in this project? You could search through hundreds of files yourself -- or you send a colleague who researches it for you and tells you the result in two sentences.
That's exactly how Subagents work in Claude Code. A Subagent is a specialized assistant with its own desk -- its own context, its own tools, and a clearly defined task. It works in isolation so your main context stays clean, and delivers only the result at the end.
Why Subagents?
The context window is the most valuable resource in Claude Code. Every file that's read, every search, every tool result -- everything takes up space. Subagents solve this problem elegantly:
- Isolated context: The Subagent reads 50 files, but only the summary enters your main context
- Specialization: Each Subagent can have its own tools, its own model, and specific instructions
- Parallelism: Multiple Subagents can work simultaneously on different tasks
- Cost efficiency: Simple tasks run on cheaper models like Haiku
iAnalogy: The Office Team
Your main agent is the project manager. It delegates tasks to specialists (Subagents), each working at their own desk. The project manager only gets the finished results -- not all the notes and intermediate steps. This keeps the project manager's desk tidy.
Built-in vs. Custom Agents
Claude Code comes with three built-in Subagents that are automatically available:
- Explore -- a fast, lean agent for codebase research
- Plan -- a planning agent for complex task decomposition
- General-purpose -- a full-featured agent for demanding subtasks
Beyond that, you can create Custom Agents: specialized agents with their own system prompt, restricted tools, and dedicated model. They are defined as Markdown files in .claude/agents/ and are immediately usable.
What to Expect
- Agent Types & Configuration -- The three built-in agents and how to create your own Custom Agents
- Context Management & Worktrees -- How Subagents work in isolation, use Git Worktrees, and run in the background
- Delegation Strategies -- When to use which agent type and how to optimize costs
*Learning Objective
After this module, you'll be able to deploy Subagents strategically, configure Custom Agents for recurring tasks, and choose the right delegation strategy for different scenarios.
Reflect
Subagents are the key to efficient work with Claude Code on larger projects. They keep your context clean, enable parallel work, and reduce costs. In the next section, we'll look at the different agent types in detail.