Intermediate

Types of Sub Agents

Not all sub agents are the same. Each type is designed for a specific kind of work, with tailored tools, instructions, and constraints. Learn the five main types and when to use each.

1. Research / Exploration Agents

Research agents are read-only investigators. They explore codebases, search documentation, read files, and return structured findings to the parent agent. They never modify anything.

Research Agent Task
// Typical research agent prompt
"Explore the project and find:
- All API route definitions
- Authentication middleware
- Database connection setup
- Environment variable usage

Return file paths and brief descriptions."

// Tools: Read, Glob, Grep (read-only)

Best for: Understanding unfamiliar codebases, gathering information before making changes, mapping dependencies, finding specific patterns across many files.

2. Code Writing Agents

Code writing agents have full write access and are responsible for implementing features, fixing bugs, and refactoring code. They can create files, edit existing ones, and run build commands.

Coding Agent Task
// Typical coding agent prompt
"Implement a rate limiter middleware for the
Express API. Requirements:
- 100 requests per minute per IP
- Return 429 status with retry-after header
- Use sliding window algorithm
- Add to src/middleware/rate-limiter.ts
- Register in src/app.ts"

// Tools: Read, Write, Edit, Bash, Glob, Grep

Best for: Implementing new features, fixing bugs, refactoring modules, adding tests, updating configurations.

3. Testing Agents

Testing agents focus on verifying correctness. They run existing test suites, write new tests, check for regressions, and report failures with diagnostic information.

Testing Agent Task
// Typical testing agent prompt
"Run the test suite for the auth module.
- Execute: npm test -- --testPathPattern=auth
- Report any failures with error messages
- Check test coverage
- Suggest missing test cases"

// Tools: Read, Bash, Glob, Grep

Best for: Running test suites after code changes, writing unit and integration tests, checking coverage, validating edge cases.

4. Review Agents

Review agents act as automated code reviewers. They analyze code changes, check for best practices, identify potential bugs, and suggest improvements — similar to a human code review.

Review Agent Task
// Typical review agent prompt
"Review the changes in src/auth/ directory.
Check for:
- Security vulnerabilities
- Error handling gaps
- Performance concerns
- Code style consistency
- Missing input validation

Provide specific feedback with file:line references."

// Tools: Read, Glob, Grep (read-only)

Best for: Pre-commit code reviews, security audits, style enforcement, identifying anti-patterns, documentation gaps.

5. Planning Agents

Planning agents are strategists. They analyze the task at hand, break it into steps, identify dependencies, and create an implementation plan that other agents can follow.

Planning Agent Task
// Typical planning agent prompt
"Analyze the request to add OAuth2 support.
Create a step-by-step implementation plan:
- What files need to change?
- What new files are needed?
- What dependencies must be installed?
- What is the correct order of implementation?
- What are the risks and edge cases?"

// Tools: Read, Glob, Grep (read-only)

Best for: Breaking down complex features, creating implementation roadmaps, risk assessment, dependency analysis, effort estimation.

Agent Type Comparison

Type Access Level Output Risk Cost
Research Read-only Information, summaries Low Low-Medium
Coding Full read/write Code changes High High
Testing Read + Execute Test results, coverage Low Medium
Review Read-only Feedback, suggestions Low Medium
Planning Read-only Plans, steps, analysis Low Medium

Custom Agent Definitions

Beyond the standard types, you can define custom agent roles tailored to your specific workflow. Custom agents are created by combining a specific system prompt with a curated set of tools.

Python - Custom Agent Definition
class DocumentationAgent:
    """Custom agent that generates documentation."""

    name = "documentation-agent"
    tools = ["Read", "Write", "Glob", "Grep"]
    system_prompt = """You are a documentation specialist.
    Read source code and generate clear, accurate
    documentation. Follow JSDoc/docstring conventions.
    Include examples for all public functions."""

class MigrationAgent:
    """Custom agent for database migrations."""

    name = "migration-agent"
    tools = ["Read", "Write", "Bash", "Glob"]
    system_prompt = """You are a database migration specialist.
    Generate migration files, verify schema changes,
    and ensure backward compatibility."""

When to Use Which Type

Decision guide:
  • Need to understand something? Use a Research agent.
  • Need to plan before acting? Use a Planning agent.
  • Need to build something? Use a Coding agent.
  • Need to verify something? Use a Testing agent.
  • Need to check quality? Use a Review agent.
💡
Common pattern: Many workflows chain agents in sequence: Research → Plan → Code → Test → Review. The output of each stage feeds into the next, creating a reliable development pipeline.