Custom Subagents
Table of Contents
1. Introduction
Custom subagents are specialized AI agents for specific workflows and domains. This feature is under active development in Claude Code and documentation will be expanded when it becomes fully available.
1.1. What Are Subagents?
Subagents are specialized instances of Claude with:
- Specific expertise or focus area
- Custom system prompts and instructions
- Defined tool access and permissions
- Ability to handle complex, multi-step workflows
1.2. Difference from Skills
| Feature | Skills | Subagents |
|---|---|---|
| Activation | Context-based, automatic | Explicit invocation |
| Scope | Single task or check | Multi-step workflows |
| Complexity | Simple, focused | Complex, stateful |
| Duration | Brief, immediate | Extended conversations |
| State | Stateless | Can maintain state |
1.3. Expected Structure
Based on early documentation, custom subagents will likely be configured in:
- Location:
.claude/agents/(project) or~/.claude/agents/(user) - Format: Configuration files (format TBD)
- Purpose: Specialized workflows, domain expertise, complex tasks
2. Planned Use Cases
While the exact implementation is pending, here are potential use cases for custom subagents:
2.1. Code Review Agent
A specialized agent focused entirely on code review with:
- Deep knowledge of code review best practices
- Security vulnerability detection expertise
- Performance optimization experience
- Access to static analysis tools
- Checklist-driven review process
Potential workflow:
- Analyze changed files
- Run security scanners
- Check performance implications
- Review test coverage
- Generate comprehensive review report
2.2. Documentation Agent
An agent specialized in creating and maintaining documentation:
- Technical writing expertise
- Documentation structure knowledge
- API reference generation
- Tutorial and guide creation
- Keeping docs in sync with code
Potential workflow:
- Analyze code structure
- Identify undocumented APIs
- Generate draft documentation
- Create usage examples
- Suggest improvements to existing docs
2.3. Test Generation Agent
Focused on comprehensive test creation:
- Testing framework expertise
- Coverage analysis
- Edge case identification
- Mock and fixture creation
- Test refactoring
Potential workflow:
- Analyze code to be tested
- Identify test scenarios
- Generate unit tests
- Generate integration tests
- Create test fixtures
- Verify coverage
2.4. Refactoring Agent
Specialized in code quality improvement:
- Design pattern knowledge
- Code smell detection
- Refactoring techniques
- Safe transformation steps
- Impact analysis
Potential workflow:
- Analyze code structure
- Identify improvement opportunities
- Propose refactoring plan
- Execute transformations incrementally
- Verify tests still pass
2.5. Database Migration Agent
Expert in database schema evolution:
- SQL knowledge
- Migration strategies
- Data preservation
- Rollback planning
- Performance considerations
Potential workflow:
- Analyze schema changes needed
- Generate migration scripts
- Create rollback scripts
- Test on sample data
- Document breaking changes
3. Configuration Concepts
While the exact format is TBD, configuration might include:
3.1. Agent Definition
name: Code Review Agent description: Specialized agent for comprehensive code reviews expertise: - security analysis - performance optimization - code quality tools: - Read - Grep - Bash(security-scanner:*) system_prompt: | You are a code review expert focused on security, performance, and code quality. Always check for: - Security vulnerabilities - Performance bottlenecks - Best practice violations - Test coverage
3.2. Workflow Definition
workflow:
- step: analyze_changes
description: Review all changed files
- step: security_scan
description: Run security analysis
- step: performance_check
description: Check for performance issues
- step: generate_report
description: Create comprehensive review
3.3. Tool Restrictions
allowed_tools: - Read - Grep - Bash(git:*) - Bash(security-scanner:*) denied_tools: - Write # Review agent shouldn't modify code - Bash(rm:*)
4. Future Updates
This file will be updated when:
- Custom subagent functionality is released
- Configuration format is documented
- API and structure are finalized
- Examples become available
4.1. Tracking Progress
Follow Claude Code development:
- Claude Code GitHub
- Official Documentation
- Anthropic Blog
- Release notes and changelogs
5. Current Alternatives
While waiting for custom subagents, use:
5.1. Built-in Subagents
Claude Code has built-in subagents accessible via the Task tool:
general-purpose- Research and multi-step tasksExplore- Codebase exploration and searchPlan- Implementation planning
Usage:
Claude, use the Explore agent to find all authentication code
5.2. Skills (Automatic)
Create skills for automatic activation:
- Agent Skills - Configure in
.claude/skills/ - Context-based activation
- Single-purpose, focused tasks
5.3. Slash Commands (Manual)
Create commands for explicit invocation:
- Slash Commands - Configure in
.claude/commands/ - User-invoked workflows
- Parameterized prompts
5.4. MCP Servers (External Tools)
Extend capabilities with MCP:
- MCP Servers - Configure in
.mcp.json - External service integration
- Language-specific tooling
6. Design Considerations
If/when designing custom subagents, consider:
6.1. Specialization Depth
- Narrow focus: Expert in one specific domain
- Complementary: Works alongside other agents
- Non-overlapping: Doesn't duplicate built-in functionality
6.2. Workflow Clarity
- Clear entry point: When should this agent be used?
- Defined steps: What's the agent's process?
- Clear exit: How does the agent finish?
6.3. Tool Access
- Minimum necessary: Only tools needed for the task
- Safety: Can't perform dangerous operations
- Audit trail: Actions are logged and reviewable
6.4. Integration
- Composable: Can work with other agents
- Stateful: Maintains context across steps
- Resumable: Can pause and resume workflows
7. Examples from Community
While official custom subagents are pending, the community has explored similar concepts:
7.1. Agentic Workflows
Using the Task tool to create multi-step workflows:
Task( subagent_type="general-purpose", prompt="First, analyze the codebase. Then, identify issues. Finally, propose fixes." )
7.2. Chain of Thought Prompts
Embedding complex workflows in slash commands:
--- description: Multi-step code analysis --- # Analysis Workflow 1. **Understand**: Read and comprehend the code 2. **Identify**: Find issues and opportunities 3. **Analyze**: Deep dive into each issue 4. **Propose**: Suggest specific improvements 5. **Prioritize**: Rank by impact [Detailed instructions for each step...]
7.3. Specialized Skills
Creating highly focused skills:
- One skill per specific task
- Clear activation triggers
- Defined tool access
- Single responsibility
8. Related Configuration
- Slash Commands - User-invoked alternatives
- Agent Skills - Automatic alternatives
- Settings - Tool permissions and configuration
- MCP Servers - External tool integration
9. Resources
9.1. Official Sources
9.2. Community
9.3. Similar Concepts
—
Note: This file serves as a placeholder and will be significantly expanded when custom subagent functionality becomes available in Claude Code. Check back for updates.