5.3

Working with Subagents

Specialized AI instances for different tasks

🤖 Technique ⏱️ ~20 minutes ⚡ Advanced

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
Download 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

The Researcher

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

The Code Reviewer

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

The Technical Writer

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

The Architect

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

Subagent 1: The Researcher (claude.ai tab 1)

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

Subagent 2: The Architect (claude.ai tab 2)

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

Main Agent: The Builder (Claude Code)

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

Subagent 3: The Reviewer (claude.ai tab 3)

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

Open claude.ai in a new tab/window
Keep your Claude Code session separate
Give it a specialized role:
First message: "You are a [role]. Your job is [specific responsibility]. [Any specific instructions or constraints]."
Assign it a task:
Give it ONE focused task. Don't try to have it do multiple things.
Copy useful output back to main session:
Take the research, review, or documentation and use it in your Claude Code session.
Label your tabs:
"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

Sequential: Researcher → Architect → Builder → Reviewer (one after another)
Parallel: Researcher + Architect work simultaneously on different aspects
Iterative: Builder creates → Reviewer finds issues → Builder fixes → repeat
Consultative: Main agent asks specialists for input as needed

💡 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

💭 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