Create a new Claude subagent - a specialized AI assistant with its own context window and custom configuration. Subagents are automatically invoked by Claude based on task context or can be explicitly requested.
Create specialized AI assistants with isolated context windows and custom configurations. Use when you need dedicated experts for code review, testing, architecture, or other complex workflows that benefit from focused, automatic delegation.
/plugin marketplace add yanmxa/cc-plugins/plugin install claude@cc-pluginsCreate a new Claude subagent - a specialized AI assistant with its own context window and custom configuration. Subagents are automatically invoked by Claude based on task context or can be explicitly requested.
code-reviewer - Create a code review specialist subagentapi-tester - Create an API testing subagentspec-analyst - Create a requirements analysis subagentDetermine Mode: If subagent name provided, use auto mode; otherwise, use interactive mode
Interactive Mode (no arguments):
Auto Mode (subagent name provided):
Generate Subagent File:
~/.claude/agents/$1.md (user-level) or ./.claude/agents/$1.md (project-level)Verify and Test:
User-Level: ~/.claude/agents/subagent-name.md
Project-Level: ./.claude/agents/subagent-name.md
Default: User-level unless project context detected or user specifies
---
name: subagent-identifier
description: Clear description of role AND when to invoke. Include specific keywords and scenarios for automatic activation.
tools: Read, Write, Bash, Grep, Glob # Optional: comma-separated list
model: sonnet # Optional: sonnet, opus, haiku, or inherit
---
# Role Definition
You are a [specific role] specializing in [domain/task]. When invoked, you [primary objective].
## Core Responsibilities
1. **[Responsibility 1]**: Detailed description of what you do
2. **[Responsibility 2]**: Another key responsibility
3. **[Responsibility 3]**: Additional responsibilities
## Workflow
When activated, follow these steps:
1. **Initial Analysis**:
- Analyze the current state/context
- Identify key issues or requirements
- Ask clarifying questions if needed
2. **Main Task Execution**:
- Perform primary task with specific approach
- Use appropriate tools and techniques
- Follow best practices and standards
3. **Quality Checks**:
- Verify work meets criteria
- Run tests/validations
- Document findings
4. **Deliverables**:
- Produce specific outputs
- Provide recommendations
- Update relevant documentation
## Best Practices
- [Best practice 1]
- [Best practice 2]
- [Common pitfall to avoid]
## Quality Criteria
- [Criterion 1]: [Standard/threshold]
- [Criterion 2]: [Standard/threshold]
- [Criterion 3]: [Standard/threshold]
## Output Format
[Template or structure for agent's deliverables]
## Example Scenarios
**Scenario 1**: [Description]
- Input: [What triggers this]
- Action: [What you do]
- Output: [What you produce]
**Scenario 2**: [Another scenario]
- Input: [Trigger]
- Action: [Process]
- Output: [Result]
| Field | Required | Description | Example |
|---|---|---|---|
| name | Yes | Lowercase identifier with hyphens | code-reviewer, api-tester |
| description | Yes | Role + activation triggers + keywords | See examples below |
| tools | No | Comma-separated tool list; inherits all if omitted | Read, Write, Bash |
| model | No | Model alias or inherit from parent | sonnet, opus, haiku, inherit |
Poor: "Helps review code" Good: "Expert code review specialist. Reviews code for quality, security, and maintainability. Use immediately after writing or modifying code, before commits, or when refactoring."
Poor: "API testing tool" Good: "API testing specialist. Validates REST endpoints, response schemas, error handling, and performance. Use when testing APIs, debugging HTTP requests, or validating backend services."
Poor: "Requirements analyst" Good: "Requirements analyst and project scoping expert. Elicits comprehensive requirements, creates user stories with acceptance criteria, and generates project briefs. Use when starting new projects, analyzing requirements, or creating specifications."
When in interactive mode, ask:
Role Question:
Activation Question:
Tools Question (multiSelect: true):
Model Question:
Scope Question:
When extracting from recent conversation:
Identify Domain Patterns:
Extract Tool Usage:
Detect Workflow Steps:
Generate System Prompt:
Set Activation Triggers:
Subagents can work together in workflows:
# Sequential workflow
"Use spec-analyst to analyze requirements, then spec-architect to design the system"
# Parallel tasks
"Have code-reviewer check quality while test-runner validates functionality"
# Handoff pattern
"spec-planner should create tasks, then spec-developer implements them"
Main agent coordinates multiple specialized subagents:
Sequential phases with quality gates:
Invoke domain experts as needed:
After creation, provide:
โ
Subagent created successfully: [name]
Location: ~/.claude/agents/[name].md (or project-level)
Role: [Role description]
Model: [sonnet/opus/haiku/inherit]
Tools: [tool list or "all tools"]
๐ Subagent Details:
- Activates on: [keywords, patterns, or scenarios]
- Primary responsibilities: [list]
- Key capabilities: [list]
๐ How to Use:
Automatic: Claude will invoke when context matches
Explicit: "Use the [name] subagent to [task]"
๐งช Test Command:
Try: "Use the [name] subagent to [example scenario]"
๐ Next Steps:
1. Test the subagent with a relevant task
2. Refine system prompt based on results
3. Add to project agents if team-relevant
4. Document use cases for team members
Before finalizing:
YAML Syntax:
Description Quality:
System Prompt:
Tool Restrictions:
tools field to inherit all available toolsmodel: inherit to match parent conversation's model# Interactive mode - guided creation with questions
/claude:create-subagent
# Auto mode - extract from recent code review work
/claude:create-subagent code-reviewer
# Create API testing specialist
/claude:create-subagent api-tester
# Create requirements analyst
/claude:create-subagent spec-analyst
# Create performance optimizer
/claude:create-subagent performance-optimizer
If Claude doesn't invoke your subagent:
Check file location:
ls -la ~/.claude/agents/[name].md
ls -la ./.claude/agents/[name].md
Verify YAML syntax:
head -10 ~/.claude/agents/[name].md
Test description clarity: Make it more specific with trigger keywords
Explicit invocation test: "Use the [name] subagent to [task]"
Check tool restrictions: Ensure required tools aren't blocked
Review logs: Run claude --debug for error messages
/agents - Built-in interactive agent manager/claude:create-skill - Create a skill (model-invoked instructions)/claude:create-command - Create a slash command (user-invoked)| Feature | Skill | Subagent | Slash Command |
|---|---|---|---|
| Invocation | Model-invoked | Model-invoked | User-invoked |
| Context | Main conversation | Isolated context | Main conversation |
| Use Case | Domain expertise | Complex workflows | Quick automation |
| Location | ~/.claude/skills/ | ~/.claude/agents/ | ~/.claude/commands/ |
| Format | Folder with SKILL.md | Single .md file | Single .md file |
| Best For | Adding capabilities | Task specialization | User shortcuts |
Choose subagents when: