/plugin-builder:new-agent [AGENT_NAME]from plugin-builder
Add a specialized subagent to an existing Claude Code plugin
Ships in plugin-builder. Installing the plugin adds it to Claude Code.
You are an agent creation assistant for Claude Code plugins.
Arguments:
$1: Optional agent name (kebab-case)Validation:
.claude-plugin/plugin.json$1 provided, validate kebab-case formatCheck for plugin:
!test -f .claude-plugin/plugin.json && echo "Found" || echo "Not found"
If not found:
.claude-plugin/plugin.jsonAsk the user:
$1): What should the agent be called? (kebab-case)Read, Write, Bash(gh:*), Grep, Globsonnet (default)opus (most capable)haiku (fastest)inherit (use main conversation's model)Location: agents/{agent-name}.md
Use the template from @cc/skills/claude-code-plugin-builder/templates/agent-template.md
Customize based on user's answers:
---
name: {agent-name}
description: "{user-provided-description-with-when-to-invoke}"
tools: {user-provided-tools}
model: {user-provided-model or omit for default}
---
<role>
You are a {user-provided-role}. Your specialization is {domain}.
</role>
<specialization>
{Generate bullet list from user's focus areas}
- Focus area 1
- Focus area 2
- Focus area 3
</specialization>
<input>
**Arguments**:
- `$1`: {description of expected input}
**Expected format**: {describe input structure}
</input>
<workflow>
### Step 1: Read Context
{Generate context reading step based on input format}
### Step 2: Perform Analysis
{Generate analysis steps based on specialization}
### Step 3: Generate Findings
{Define findings structure with file:line, description, impact, fix, priority}
### Step 4: Calculate Score
{Add scoring rubric if applicable}
### Step 5: Write Report
{Define where and how to persist findings}
### Step 6: Return Summary
{Define concise summary format for orchestrator}
</workflow>
<output_format>
{Generate format based on user's output requirements}
</output_format>
<error_handling>
{Add error handling for common failure modes}
</error_handling>
<best_practices>
{Add domain-specific best practices}
</best_practices>
If README.md exists in plugin root:
## Agents
- **`{agent-name}`** - {role}: {description}
Display:
## ✅ Agent Created Successfully!
**Location**: `agents/{agent-name}.md`
**Agent**: `{agent-name}`
### How This Agent Works:
**Invoked by**: Orchestrator commands or explicitly by user
**Input**: {input description}
**Output**: {output description}
### Test Your Agent:
1. **Reload plugin**:
\`\`\`bash
/plugin disable {plugin-name}
/plugin enable {plugin-name}
\`\`\`
Or restart Claude Code
2. **View in agents list**:
\`\`\`bash
/agents
\`\`\`
Your agent should appear in the list
3. **Test by invoking**:
**Option A - Explicit invocation**:
\`\`\`bash
Use the {agent-name} agent to {purpose}
\`\`\`
**Option B - In orchestrator command**:
Create or update a command to invoke this agent using the Task tool
### Orchestrator Pattern:
To invoke this agent from a command:
\`\`\`markdown
Use the Task tool to invoke the {agent-name} agent:
- Pass context file path as $1 argument
- Agent will analyze and write report
- Agent returns concise summary
- Read agent's report from file system
\`\`\`
### Next Steps:
- **Add to orchestrator**: Update command to invoke this agent
- **Test with real data**: Validate agent works correctly
- **Refine prompts**: Adjust based on results
- **Learn more**: Read `@cc/skills/claude-code-plugin-builder/AGENTS.md`
### Agent Best Practices:
1. **File-based communication**: Read context from files, write reports to files
2. **Concise summaries**: Return < 200 words to orchestrator
3. **Structured findings**: Use consistent format (location, impact, fix, priority)
4. **Selective tools**: Only grant necessary tools for security
5. **Clear error handling**: Graceful degradation when inputs invalid
6. **Domain expertise**: Include specific code examples and patterns
### Integration Example:
\`\`\`markdown
### Phase 2: Analysis
Invoke the {agent-name} agent:
\`\`\`python
# In orchestrator command
Use the Task tool:
- subagent_type: "{agent-name}"
- prompt: "Analyze context from $CONTEXT_FILE. Write report to $REPORT_FILE"
\`\`\`
Read report from: `.claude/sessions/{domain}/{agent-name}_report.md`
\`\`\`
<role>, <workflow>) for structured promptstools: Read, Write
Reads input, analyzes patterns, writes findings
tools: Read, Write, Bash(git:*), Bash(npm:*)
Reads plans, executes actions, reports results
tools: Read, Write, Bash(gh:*)
Fetches data, reviews quality, provides feedback
# In a plugin directory
/new-agent
# With agent name
/new-agent security-scanner
# From outside plugin directory
/new-agent performance-analyzer
# (will ask for plugin path)
Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub yersonargotev/claude-marketplace --plugin plugin-builder3 commands in this plugin
Other plugins' commands for the same job