How to create and use specialized subagents in Claude Code for task delegation. Use when user asks about creating specialized agents, delegating tasks, agent configuration, or subagent features.
Create specialized AI assistants with custom tools and prompts for task delegation. Use when users ask about building subagents, configuring tools, or delegating work to specialized agents.
/plugin marketplace add reggiechan74/claude-plugins/plugin install claude-code-metaskill@claude-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Subagents are specialized AI assistants that Claude Code can delegate tasks to. Each operates with its own context window, custom system prompt, and configurable tool access.
Context Management: Each subagent operates in its own context, preventing pollution of the main conversation
Specialization: Task-specific configurations enable higher success rates on designated work
Reusability: Once created, subagents work across different projects and teams
Flexible Permissions: Individual tool access control per subagent
/agents command.claude/agents/~/.claude/agents/Markdown with YAML frontmatter containing:
name: Unique identifierdescription: Purpose and invocation guidancetools: Optional comma-separated listmodel: Optional model alias (sonnet/opus/haiku) or 'inherit'---
name: code-reviewer
description: Expert code review specialist. Use proactively after code changes.
tools: Read, Grep, Glob, Bash
model: inherit
---
Your system prompt explaining the subagent's role and approach...
When configuring subagents, you can grant access to these tools via the tools field in frontmatter:
Bash - Executes shell commands in your environment
BashEdit - Makes targeted edits to specific files
EditNotebookEdit - Modifies Jupyter notebook cells
NotebookEditSlashCommand - Runs a custom slash command
SlashCommandWebFetch - Fetches content from a specified URL
WebFetchWebSearch - Performs web searches with domain filtering
WebSearchWrite - Creates or overwrites files
WriteGlob - Finds files based on pattern matching
GlobGrep - Searches for patterns in file contents
GrepNotebookRead - Reads and displays Jupyter notebook contents
NotebookReadRead - Reads the contents of files
ReadTask - Runs a sub-agent to handle complex, multi-step tasks
TaskTodoWrite - Creates and manages structured task lists
TodoWriteGrant all tools:
tools: Bash, Edit, Read, Write, Glob, Grep, WebFetch, WebSearch
Grant minimal tools (read-only):
tools: Read, Glob, Grep
Grant specific tools for specialized tasks:
tools: Read, Bash, TodoWrite # For a test runner agent
Omit tools field to inherit from parent:
# No tools field - uses same tools as main Claude instance
Automatic Delegation: Claude recognizes matching tasks and invokes appropriate subagents
Explicit Invocation: Request specific subagents via natural language commands like "Use the debugger subagent to investigate this error"
Reviews code for quality, security, and maintainability. Provides feedback categorized by priority (critical/warnings/suggestions).
Specializes in root cause analysis. Captures error messages, isolates failures, and implements minimal fixes.
Handles SQL queries and data analysis. Writes optimized queries and provides data-driven recommendations.
Chaining: Combine multiple subagents for complex workflows
Dynamic Selection: Claude intelligently chooses subagents based on task context and description fields
Performance: Subagents preserve main context but may add latency during initial context gathering
Define subagents dynamically with --agents flag accepting JSON objects for session-specific or automation-based configurations.