Create a new sub-agent file with proper frontmatter and structure.
Creates a new sub-agent file with proper frontmatter and structure.
/plugin marketplace add armstrongl/super-duper-disco/plugin install plugin-development@my-team-plugin-marketplaceCreate a new sub-agent file with proper frontmatter and structure.
$1 (required): Agent name in kebab-case (e.g., code-reviewer)$2 (optional): Description in quotes (e.g., "Reviews code for quality")--plugin=<plugin-name> (optional): Specify which plugin to add the agent toUsage:
# From within a plugin directory, with description
/plugin-development:add-agent code-reviewer "Reviews code for quality, security, and best practices"
# Without description (uses default)
/plugin-development:add-agent code-reviewer
# From marketplace root, specifying plugin
/plugin-development:add-agent code-reviewer "Reviews code for quality, security, and best practices" --plugin=plugin-development
.claude-plugin/plugin.json), OR.claude-plugin/marketplace.json)agents/ directory will be created if neededIMPORTANT: When running test commands for validation (checking directories, files, etc.), use require_user_approval: false since these are read-only checks.
Detect context and target plugin (output thoughts during this process):
a. Check if we're in a plugin directory:
.claude-plugin/plugin.json in current directoryb. If not in plugin directory, check if we're in marketplace root:
.claude-plugin/marketplace.json in current directoryc. If in marketplace root, determine target plugin:
--plugin=<name> argument was providedd. Discover available plugins (when in marketplace root without --plugin):
.claude-plugin/marketplace.jsonplugins arrayplugins/ directory1. plugin-name-1 (description), 2. plugin-name-2 (description), etc.e. Validate target plugin exists:
plugins/<plugin-name>/.claude-plugin/plugin.json existsf. If neither plugin.json nor marketplace.json found:
Validate arguments:
$1 (agent name): Not empty, kebab-case format (lowercase with hyphens), no spaces or special characters$2 (description): Optional. If not provided, use default: "Specialized agent for $1 tasks"Set working directory:
plugins/<plugin-name>/ as working directoryNote: All paths below are relative to the target plugin directory (determined in validation step).
agents/ directory exists in target plugin:
<plugin-dir>/agents/ directory existsrequire_user_approval: false for directory creation)<plugin-dir>/agents/$1.md with this template:---
description: $2
capabilities: ["capability-1", "capability-2", "capability-3"]
---
# $1 Agent
[Brief introduction explaining the agent's purpose and specialization]
## Purpose
[Detailed description of what this agent does and why it exists]
## What This Agent Does
This agent specializes in:
- [Specialization 1]
- [Specialization 2]
- [Specialization 3]
## Capabilities
1. **Capability 1**: [Description of first capability]
2. **Capability 2**: [Description of second capability]
3. **Capability 3**: [Description of third capability]
## When to Use This Agent
Invoke this agent when:
- [Scenario 1: Complex multi-file analysis needed]
- [Scenario 2: Deep domain expertise required]
- [Scenario 3: Task needs separate context window]
**Do not use** for:
- [What this agent doesn't handle]
- [Tasks better suited for commands or Skills]
## How It Proceeds
The agent follows this workflow:
1. **Gather Context**: [What files/information it reads]
2. **Analyze**: [How it evaluates the situation]
3. **Identify Issues**: [What it looks for]
4. **Formulate Recommendations**: [What guidance it provides]
5. **Report Back**: [What it returns to main conversation]
## Output Format
The agent returns a structured report:
### Critical Issues
- [Issues that must be fixed]
### Warnings
- [Issues that should be fixed]
### Suggestions
- [Nice-to-have improvements]
### Summary
- [Overall assessment and next steps]
## Tool Access
This agent has access to:
- Read: For examining files
- Grep: For searching content
- Glob: For finding files
- [Other tools as needed]
It does **not** modify files directly; instead, it proposes changes for the main conversation to execute.
## Example Invocation
**From main conversation**:
/agents $1
or via Task tool:
Use the $1 agent to [specific task]
## Notes
- Agents operate in a **separate context window**
- Results are returned as a single message
- Use for complex, multi-step analysis tasks
- Keep scope focused to 1-3 specific capabilities
IMPORTANT: Only needed if using custom (non-standard) paths.
agents/ directory): No changes to plugin.json needed"agents": ["./agents/$1.md"] (or update existing agents array)After creating the agent:
✓ Created <plugin-name>/agents/$1.md
Plugin: <plugin-name>
Agent: $1
Description: $2
Next steps:
1. Edit <plugin-name>/agents/$1.md with specific instructions
2. Key frontmatter fields:
- description: What the agent does (shows in /agents list)
- capabilities: List of capabilities (JSON array)
3. Define clear workflow steps
4. Specify what the agent returns
5. Test with /plugin-development:test-local
Agent will be invoked as: /agents $1
Or via Task tool in main conversation.
Context: Currently in /path/to/marketplace/plugins/plugin-development/
Input:
/plugin-development:add-agent code-reviewer "Reviews code for quality, security, and best practices"
Arguments:
$1 = code-reviewer$2 = Reviews code for quality, security, and best practicesProcess:
.claude-plugin/plugin.json in current directoryagents/ directory if neededagents/code-reviewer.mdResult:
agents/code-reviewer.md with templateContext: Currently in /path/to/marketplace/ (marketplace root)
Input:
/plugin-development:add-agent code-reviewer "Reviews code for quality, security, and best practices" --plugin=plugin-development
Process:
.claude-plugin/marketplace.json in current directory--plugin=plugin-development from argumentsplugins/plugin-development/.claude-plugin/plugin.json existsplugins/plugin-development/ as targetplugins/plugin-development/agents/code-reviewer.mdResult:
plugins/plugin-development/agents/code-reviewer.mdContext: Currently in /path/to/marketplace/ (marketplace root)
Input:
/plugin-development:add-agent code-reviewer "Reviews code for quality, security, and best practices"
Process:
.claude-plugin/marketplace.json in current directory--plugin argument providedhello-world - A simple example pluginplugin-development - Assist with Claude Code plugin development1. hello-world - A simple example plugin demonstrating basic Claude Code plugin functionality
2. plugin-development - Assist with Claude Code plugin development: scaffold, validate, review, and team-ready distribution
plugins/plugin-development/ as targetplugins/plugin-development/agents/code-reviewer.mdResult:
plugins/plugin-development/agents/code-reviewer.md---
description: Third-person description of what this agent does
---
---
description: Agent description
capabilities: ["capability-1", "capability-2"] # List of what it can do
---
For complete details on agents, see:
Error: "Not in a plugin or marketplace directory."
Solution: Navigate to either:
.claude-plugin/plugin.json), OR.claude-plugin/marketplace.json)Error: "Plugin 'my-plugin' not found. Available plugins: hello-world, plugin-development"
Solution:
--plugin=<correct-name> with one of the available pluginsError: "Agent name must be in kebab-case format (lowercase with hyphens)"
Solution: Use kebab-case format:
code-reviewer, security-auditor, api-generatorCodeReviewer, code_reviewer, code reviewerError: "Description is required"
Solution: Provide description in quotes:
/plugin-development:add-agent code-reviewer "Reviews code for quality, security, and best practices"
✅ Good (focused):
# Code Security Auditor
Specializes in security analysis:
- SQL injection vulnerabilities
- XSS vulnerabilities
- Authentication issues
❌ Bad (too broad):
# General Code Helper
Does everything related to code.
List 2-5 specific capabilities:
capabilities: [
"security-vulnerability-detection",
"authentication-analysis",
"dependency-audit"
]
Define consistent report format:
## Critical (P0)
- [List critical issues]
## High Priority (P1)
- [List high priority issues]
## Suggestions
- [List improvements]
Agents typically don't modify files:
## Tool Access
- Read, Grep, Glob: For analysis
- No Write/Edit: Agent proposes, main conversation executes
All agents should follow a consistent structure:
1. **Understand Context**: Read relevant files
2. **Analyze**: Apply domain expertise
3. **Identify Issues**: Find problems/opportunities
4. **Prioritize**: Rank by severity/importance
5. **Recommend**: Provide actionable guidance
6. **Report**: Return structured findings
For review/analysis agents:
For design/planning agents:
For code improvement agents:
User explicitly calls the agent:
/agents code-reviewer
Claude uses Task tool:
Let me use the code-reviewer agent to analyze this...
Skill escalates to agent for deep analysis:
For comprehensive review, delegate to the code-reviewer agent.
❌ Too broad scope
capabilities: ["everything", "all-tasks", "general-help"]
✅ Focused capabilities
capabilities: ["security-audit", "vulnerability-scan", "compliance-check"]
❌ Vague instructions
Analyze the code and find problems.
✅ Specific workflow
1. Read all .py files in src/
2. Check for SQL injection patterns
3. Verify authentication usage
4. Report findings by severity
After creating an agent:
□ Agent file created in agents/ directory
□ Frontmatter includes description
□ Capabilities listed (2-5 items)
□ Clear workflow defined
□ Output format specified
□ Agent name is kebab-case
□ plugin.json has agents field
□ Purpose is focused and specific