What if instead of one Claude doing everything, you could have specialists? One Claude researches, another writes code, another reviews for bugs, another writes documentation. That's subagents: separate Claude instances with specific roles.
Subagent Role Templates
Pre-configured instructions for common subagent roles
📄 Preview PDF
🤔 What Are Subagents?
A subagent is simply another instance of Claude (usually via claude.ai web interface) that you give specialized instructions to.
Main Claude Code session: Building your project
Subagent 1 (claude.ai): Researching best practices
Subagent 2 (claude.ai): Reviewing code for bugs
Subagent 3 (claude.ai): Writing documentation
✨ Why This Works
Each Claude instance has its own conversation context and can focus on ONE thing without getting confused by multiple responsibilities. It's like having a team instead of one overworked person.
🎯 When to Use Subagents
Don't use subagents for simple projects. The overhead isn't worth it.
Do use subagents when:
- You need deep research separate from implementation
- You want fresh eyes reviewing your code
- You need documentation written from user perspective
- You're coordinating multiple features in parallel
- One task needs deep context that would overwhelm the main session
📋 Common Subagent Roles
Job: Deep-dive into unfamiliar technology or approaches
Instructions: "You are a technical researcher. Your job is to explore [topic] thoroughly and provide comprehensive summaries of: what it is, how it works, available options, tradeoffs, and recommendations. Use web search extensively."
Use when: Starting a complex feature you don't understand
Job: Review code for bugs, performance issues, security problems
Instructions: "You are a senior code reviewer. Review this code critically for: bugs, security issues, performance problems, edge cases, and code smells. Be thorough and specific."
Use when: You've built something and want fresh perspective
Job: Write documentation from user perspective
Instructions: "You are a technical writer. Given this code/feature, write clear documentation for users who don't know the implementation details. Focus on: what it does, how to use it, common scenarios."
Use when: You need docs or README written
Job: Design system architecture and data models
Instructions: "You are a software architect. Design the architecture for [project]. Consider: data flow, component structure, scalability, maintainability. Provide diagrams and explanations."
Use when: Planning large features or refactors
📖 Complete Example: Using Subagents
Let's watch a multi-agent workflow:
Task: Add real-time collaboration to a note-taking app
Challenge: Complex feature, unfamiliar technology
Instruction: "You are a technical researcher specializing in real-time collaboration systems."
Task: "Research real-time collaboration options for a static web app note-taking tool. Compare: WebSockets, Firebase, Y.js, Supabase real-time. Provide pros/cons and recommendation."
Output: Comprehensive comparison → Recommends Firebase (easiest for static site)
Copy recommendation to notes
Instruction: "You are a software architect."
Task: "Given we're using Firebase for real-time sync, design the data model and sync strategy for collaborative notes. Consider: conflict resolution, offline support, user permissions."
Output: Data structure design, sync flow diagram, conflict resolution strategy
Save architecture doc
Context: Has research summary and architecture design
Task: "Implement real-time collaboration using Firebase. [Paste architecture]. Create implementation plan."
Output: Builds feature following architecture
Implementation proceeds smoothly with clear direction
Instruction: "You are a senior code reviewer focusing on real-time systems."
Task: "Review this Firebase sync implementation. Check for: race conditions, memory leaks, security rules, error handling."
Output: Found 2 issues: missing cleanup on unmount, security rules too permissive
Fixes implemented
✅ Why This Worked
Each agent focused on its specialty without getting confused. Research happened independently of implementation. Review caught issues the builder missed. Total time saved: 2-3 hours of backtracking.
🔧 Setting Up Subagents
🎯 Create Your First Subagent
Keep your Claude Code session separate
First message: "You are a [role]. Your job is [specific responsibility]. [Any specific instructions or constraints]."
Give it ONE focused task. Don't try to have it do multiple things.
Take the research, review, or documentation and use it in your Claude Code session.
"Researcher", "Reviewer", "Main Build" so you don't get confused
⚠️ Subagent Anti-Patterns
❌ Too many agents
Using 5+ agents for a simple feature. Coordination overhead exceeds benefit. Stick to 2-3 max.
❌ Vague roles
"You're a helper" doesn't give useful specialization. Be specific: "You review code for security issues."
❌ Overlapping responsibilities
Two agents doing similar jobs creates confusion. Each should have distinct focus.
⚡ Pro Tip: Name Your Agents
Instead of "Subagent 2", use "Security Reviewer" or "API Researcher". Helps you remember what each one does and keeps them focused.
🔄 Coordination Strategies
Managing multiple agents:
Multi-Agent Workflow
💡 When NOT to Use Subagents
Don't overcomplicate. Skip subagents for:
- Simple features you understand well
- Quick prototypes or experiments
- Projects under 500 lines of code
- When you're just learning the basics
- Time-sensitive tasks (coordination takes time)
📚 Resources & Further Learning
- Claude Code Camp (Every.to) Advanced multi-agent workflows
- Anthropic Documentation System prompts and agent design
💭 Pause & Reflect
Before moving on, take a moment to consider:
- What tasks would you delegate to a subagent if you had specialized help?
- How would having a dedicated reviewer change your code quality?
- What's the most complex project you've built where subagents would have helped?
🎯 Subagent Skills Acquired
You can now coordinate multiple AI specialists. Next: Connecting Claude to external tools.
Topic 5.3 Complete • Up Next: 5.4 – MCP: Extending Claude's Capabilities