The Sub-Agents skill enables the creation and management of specialized AI agents within the Claude Code environment. It allows developers to orchestrate complex workflows by defining custom personas with specific system prompts, restricted toolsets (Read, Write, Bash), and optimized model selections. This modular approach improves task accuracy through context isolation and allows for sophisticated agent-chaining patterns to solve high-level engineering challenges.
Use Cases
Automated Code Review: Create a dedicated 'reviewer' agent with read-only access to audit code changes for security vulnerabilities and style consistency without risking accidental edits.
Autonomous Debugging: Configure a 'debugger' agent equipped with bash and grep tools to systematically investigate logs, reproduce test failures, and implement verified fixes.
Specialized Implementation: Deploy an 'implementer' agent with full write permissions to execute specific architectural refactors or feature additions based on a provided plan.
Performance-Optimized Research: Use a fast 'explorer' agent powered by Claude 3 Haiku for rapid codebase searches and discovery, reserving more powerful models for complex reasoning tasks.
Agent Chaining for Complex Workflows: Orchestrate a multi-step process where an 'analyzer' agent identifies technical debt and an 'optimizer' agent subsequently applies performance improvements.
name
sub-agents
description
Create and configure Claude Code sub-agents with custom prompts, tools, and models
allowed-tools
[Read, Write, Bash]
user-invocable
false
Sub-Agents Reference
Create specialized AI agents with isolated contexts for specific tasks.
When to Use
"How do I create a sub-agent?"
"Configure agent tools"
"What built-in agents exist?"
"Agent model selection"
"Agent chaining patterns"
Quick Start
Interactive (Recommended)
/agents
Opens menu to create, edit, and manage agents.
Manual Creation
mkdir -p .claude/agents
cat > .claude/agents/reviewer.md << 'EOF'
---
name: reviewer
description: Code review specialist. Use proactively after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a senior code reviewer focusing on quality and security.
## Review Checklist
- Code clarity and naming
- Error handling
- Security vulnerabilities
- Test coverage
EOF
CLI-Based
claude --agents '{
"reviewer": {
"description": "Code reviewer",
"prompt": "Review for quality and security",
"tools": ["Read", "Bash"],
"model": "sonnet"
}
}'
Agent File Format
---
name: agent-name
description: When/why to use this agent
tools: Read, Edit, Bash # Optional, inherits all if omitted
model: sonnet # sonnet, haiku, claude-opus-4-5-20251101, inherit
---
System prompt content here...