This skill should be used when creating, configuring, or working with Claude Code subagents...
Guide Claude through creating and configuring specialized subagents for Claude Code.
Subagents are pre-configured AI personalities that handle specific types of tasks with their own context windows, custom system prompts, and tool configurations. This skill helps create well-structured subagents that improve task delegation, context management, and specialized workflows.
Use this skill when:
.claude/agents/~/.claude/agents/agents/ in plugin root(plugin:plugin-name) in /agentsUse the bundled creation script for fast, templated subagent setup:
# Create project subagent with code-reviewer template
scripts/create_subagent.sh code-reviewer --project --template code-reviewer
# Create personal subagent with custom template
scripts/create_subagent.sh my-agent --user --template debugger
# Create plugin subagent (auto-detects plugin from current directory)
scripts/create_subagent.sh my-agent --plugin
# Create plugin subagent for specific plugin
scripts/create_subagent.sh my-agent --plugin my-plugin-name
# Available templates: code-reviewer, debugger, custom
The script is located at: scripts/create_subagent.sh
Plugin subagent creation:
--plugin to create subagents in a plugin's agents/ directory--plugin my-plugin-namemarketplace.jsonThe /agents command provides an interactive interface:
Recommended workflow:
/agentse to edit the system prompt in your editorWhen creating subagents manually, follow this structure:
Choose scope - Decide between:
.claude/agents/~/.claude/agents/plugins/<plugin-name>/agents/Create directory - Ensure the target directory exists:
mkdir -p .claude/agents # Project
mkdir -p ~/.claude/agents # Personal
mkdir -p plugins/my-plugin/agents # Plugin
Create file - Named agent-name.md (the filename becomes the agent name)
Add frontmatter - Include required fields:
---
name: agent-name
description: Description of when this subagent should be invoked
tools: Read, Write, Edit, Bash(git:*) # Optional; inherits all if omitted
model: sonnet # Optional; sonnet/opus/haiku/inherit
---
Write system prompt - Clear, detailed instructions defining the subagent's role, capabilities, and approach
Register plugin subagents - If creating a plugin subagent:
.claude-plugin/marketplace.jsonplugins array"./agents/agent-name.md" to the plugin's agents arrayThree templates are provided in assets/ for common use cases:
code-reviewer.md)Senior code reviewer focused on quality, security, and maintainability.
Use when: Need automated code review after changes.
Features:
debugger.md)Expert debugger for root cause analysis and issue resolution.
Use when: Encountering errors, test failures, or unexpected behavior.
Features:
custom.md)Blank template for building specialized subagents.
Use when: Need a starting point for unique workflows.
All available frontmatter fields:
---
name: agent-name # Required: lowercase, hyphens only
description: When to invoke agent # Required: specific, action-oriented
tools: Read, Write, Bash(git:*) # Optional: comma-separated list
model: sonnet # Optional: sonnet/opus/haiku/inherit
---
sonnet, opus, haiku, or inherit (matches conversation model)Subagents can use Claude Code's internal tools. Examples:
# Inherit all tools (including MCP tools)
# Omit the tools field entirely
# Specific tools only
tools: Read, Write, Edit, Grep, Glob
# Bash with patterns
tools: Bash(git:*), Bash(npm:*), Read
# Limited toolset for security
tools: Read, Grep
See full tool list in references documentation.
When creating a new subagent:
Understand requirements - Ask user about:
Choose template - Select the most appropriate template:
Use creation method:
/agents command for guided setupscripts/create_subagent.sh <name> --<scope> --template <type>Customize configuration:
Write effective system prompt:
Register plugin subagents (plugin scope only):
.claude-plugin/marketplace.json"./agents/<agent-name>.md" to the agents arrayTest and iterate:
Claude Code automatically delegates based on:
descriptionTips for better automatic delegation:
Users can request subagents directly:
> Use the code-reviewer subagent to check my recent changes
> Have the debugger subagent investigate this error
> Ask the data-scientist subagent to analyze user growth
For complex workflows:
> First use the code-analyzer subagent to find issues, then use the optimizer subagent to fix them
For detailed information about subagents, refer to references/subagents-reference.md, which contains:
Load this reference when users need detailed technical information beyond the workflow guidance in this skill.