Lesson 24
Subagents for Research
AI-generated
Subagents for Research
Understand what subagents are and when Claude spawns them
Recognize the different subagent types and their purposes
Configure subagent behavior through settings
Use subagents effectively in your workflows
Know when subagents help versus when they add overhead
Claude Code can spawn subagents to handle parts of a task. A subagent is a separate Claude instance that works on a specific piece of work, then reports back. This allows Claude to parallelize research, delegate exploration, or isolate risky operations.
You have already seen subagents in action if you have used /batch or /simplify. These skills spawn multiple subagents that work in parallel. But subagents also appear in regular conversations when Claude decides the task benefits from delegation.
This lesson explains how subagents work and how to use them effectively.
Subagents are independent Claude instances with their own context window. They receive a task, work on it using the same tools as the main session, and return results.
Why use subagents:
Parallelism - Multiple subagents can work simultaneously
Context isolation - A subagent's work does not fill your main context
Specialization - Different subagent types are optimized for different tasks
Safety - Subagents can work in isolated environments (worktrees)
When Claude spawns a subagent, you see a notification. The subagent works in the background, and when it finishes, Claude incorporates the results.
Claude Code has several built-in subagent types:
general-purpose - The default agent for complex, multi-step tasks. Has access to all tools. Use when you need broad capability.
Explore - Optimized for codebase exploration. Fast and efficient at finding files, searching code, and answering questions about structure. Cannot edit files.
Plan - Software architect agent. Designs implementation plans, identifies critical files, and considers tradeoffs. Cannot edit files.
bolt - Fast runner for mechanical tasks. Runs tests, performs git operations, handles low-reasoning work. Limited tool access but very fast.
forge - Implements changes against a referenced plan. Disciplined and incremental. Has edit access.
probe - Derives tests from acceptance criteria. Hunts edge cases. Has edit access.
sentinel - Reviews for correctness, security, and maintainability. Strict and specific. Has edit access.
echo - Writes documentation, READMEs, changelogs. Has edit access.
nova - Replanning agent. Verifies plans against actual implementation. Has edit access.
Claude decides to use subagents when:
The task is parallelizable:
Claude might spawn multiple Explore agents to search different parts of the codebase simultaneously.
Research would bloat context:
An Explore agent investigates and returns a summary, keeping your main context clean.
The skill requires it:
The batch skill spawns multiple forge agents, one per unit of work.
You explicitly request it:
You can influence when and how Claude uses subagents:
Request subagent use:
Request no subagents:
Sometimes you want Claude to do the work directly, keeping everything in your main context for visibility.
Background vs foreground:
Subagents can run in the background while you continue working:
Or in the foreground, where Claude waits for results before continuing.
Subagents can run in isolated git worktrees. A worktree is a separate checkout of your repository. Changes the subagent makes stay isolated until you merge them.
Why use worktrees:
Parallel changes that might conflict
Experimental work you might discard
Safety when testing risky modifications
When a skill like /batch spawns multiple forge agents, each works in its own worktree. This prevents conflicts and allows true parallel development.
You do not need to manage worktrees manually. Claude handles creation and cleanup. If the subagent makes no changes, the worktree is deleted. If it makes changes, you get the branch name and can merge it.
Each subagent has its own context window. This is both a feature and a limitation.
Benefits:
Research does not fill your main context
Subagents can explore deeply without context pressure
Failed subagent work does not pollute your session
Limitations:
Subagents do not see your full conversation history
They start fresh and need clear task descriptions
Results must be summarized to fit in your context
When Claude spawns a subagent, it writes a detailed prompt explaining the task, relevant context, and expected deliverable. The quality of this handoff matters.
When a subagent completes, Claude receives its output and incorporates it into your conversation. You see:
A summary of what the subagent found or did
File paths created or modified (if applicable)
Any errors or issues encountered
You can ask follow-up questions about subagent results:
Claude can often provide more detail since it has the full subagent output even if it summarized for you.
Large codebase exploration:
When you need to understand a complex system, subagents can explore different areas in parallel and synthesize findings.
Batch operations:
When the same change needs to happen across many files, multiple subagents can work simultaneously.
Research-heavy tasks:
When you need deep investigation but do not want context bloat.
Risky experiments:
When you want to try something without affecting your main work.
Simple, focused tasks:
If the task is straightforward, spawning a subagent adds overhead without benefit.
Tasks requiring your full history:
If Claude needs to reference your entire conversation, a subagent starting fresh may miss context.
When you want visibility:
If you want to see every step Claude takes, subagents hide that work.
Small codebases:
In small projects, the parallelization benefit is minimal.
Parallel code search:
Claude might spawn multiple Explore agents to search different directories simultaneously.
Multi-file refactor:
Each file gets its own forge subagent, working in parallel worktrees.
Deep research:
An Explore agent investigates deeply while you continue with other work.
Review in parallel:
Three sentinel subagents review for reuse, quality, and efficiency simultaneously.
Subagents are separate Claude instances that work on specific tasks
Different subagent types are optimized for different work
Claude spawns subagents for parallelization, context isolation, or specialization
Subagents can run in isolated worktrees for safe parallel changes
Each subagent has its own context window
Request or decline subagent use explicitly when you have a preference
Subagents help most with large, parallelizable, or research-heavy tasks
Simple tasks may not benefit from subagent overhead
Observe subagents in action:
Start Claude Code in a project with at least 10 source files.
Ask: use an explore agent to find all exported functions in this project
Watch the subagent notification appear as Claude delegates the research.
When complete, notice how the results are summarized.
Ask a follow-up: which of those functions are used in tests?
Observe whether Claude uses another subagent or answers directly.
Try: run /simplify if you have recent changes, and watch the three parallel reviewers.
This exercise shows how subagents work in practice.
https://code.claude.com/docs/en/subagents - Subagent documentation
https://code.claude.com/docs/en/agents - Agent types and capabilities
https://code.claude.com/docs/en/common-workflows - Subagents in common workflows