Create a new sub-agent file with proper frontmatter and structure.
Creates a new sub-agent file with proper frontmatter and structure for your plugin. Use when you need to add specialized agents that handle complex analysis tasks in a separate context window.
/plugin marketplace add ArcBlock/agent-skills/plugin install plugin-development@arcblock-agent-skillsCreate 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:---
name: $1
description: $2
tools: Read, Grep, Glob, Bash
model: inherit
permissionMode: default
---
# $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:
- name: Unique agent identifier (lowercase with hyphens)
- description: What the agent does and when to invoke (shows in /agents list)
- tools: CSV list of tools (optional, inherits all if omitted)
- model: sonnet, opus, haiku, or inherit (optional)
- permissionMode: default, acceptEdits, bypassPermissions, or plan (optional)
- skills: CSV list of skills to auto-load (optional)
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---
name: agent-name
description: Third-person description of what this agent does and when to invoke it
---
| Field | Type | Description |
|---|---|---|
name | String | Required. Unique identifier using lowercase letters and hyphens (e.g., code-reviewer, test-runner) |
description | String | Required. Natural language description of when the agent should be invoked. Include "PROACTIVELY" for auto-delegation |
---
name: agent-name
description: Agent description. Use PROACTIVELY for auto-delegation.
tools: Read, Grep, Glob, Bash
model: sonnet
permissionMode: default
skills: skill1, skill2
---
| Field | Type | Default | Description |
|---|---|---|---|
tools | CSV String | Inherits all | Comma-separated list of tools (e.g., Read, Grep, Glob, Bash). If omitted, inherits all tools from main thread including MCP tools |
model | String | sonnet | Which AI model to use. Valid values: sonnet, opus, haiku, inherit. Use inherit to match main conversation's model |
permissionMode | String | default | How the agent handles permission requests. Valid values: default, acceptEdits, bypassPermissions, plan |
skills | CSV String | None | Comma-separated list of skills to auto-load. Note: Agents do NOT inherit skills from parent conversation |
| Mode | Behavior |
|---|---|
default | Standard permission handling - prompts for confirmation |
acceptEdits | Automatically accept file edits without prompting |
bypassPermissions | Skip permission requests entirely |
plan | Plan mode - research and planning without execution |
| Model | Description |
|---|---|
sonnet | Claude Sonnet (default for subagents) |
opus | Claude Opus |
haiku | Claude Haiku (faster, lighter) |
inherit | Use same model as main conversation |
The capabilities field is NOT in official Anthropic docs and may be deprecated. Use tools for agents (not allowed-tools which is for skills).
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.
Configure appropriate tools for the agent's purpose:
# For read-only analysis agents:
tools: Read, Grep, Glob
# For agents that can modify files:
tools: Read, Edit, Write, Bash, Grep, Glob
# Omit to inherit all tools from main thread
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 description
description: Does everything related to code
✅ Focused description with clear purpose
description: Security audit specialist. Scans for vulnerabilities, reviews authentication, and checks compliance. Use PROACTIVELY after code changes.
❌ 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 required 'name' field (lowercase with hyphens)
□ Frontmatter includes required 'description' field
□ Optional: 'tools' field configured (or inherits all)
□ Optional: 'model' field set (sonnet/opus/haiku/inherit)
□ Optional: 'permissionMode' configured if needed
□ Optional: 'skills' listed for auto-loading
□ Clear workflow defined in body
□ Output format specified
□ plugin.json has agents field (if using custom paths)
□ Purpose is focused and specific