Create Subagent
Scaffold a new subagent directly inside the chosen plugin of a local marketplace. The root agents/ folder is auto-generated by CI — do not create files there manually.
For Claude Code, subagents are distributed via plugins. The AGENTS.md format is also compatible with other coding tools (Cursor, Copilot, Codex, Gemini, VS Code, Zed).
User's intention
$ARGUMENTS
References
Consult the relevant doc(s) before generating subagent content in auto mode or before making structural decisions in manual mode:
docs/subagents.md — subagent usage, AGENTS.md format, coordination tips
docs/plugins.md — plugin structure, manifest, hooks and relative paths
docs/hooks.md — hook lifecycle, PreToolUse / PostToolUse, hook scripts
docs/skills.md — skill format, popular repositories, skills CLI
docs/marketplace.md — marketplace structure, registration, publishing, versioning, auto-updates
docs/rules.md — rules format and scope
docs/mcp.md — MCP server configuration
docs/memory.md — memory system, persistent memory for subagents
docs/skills-cli.md — skills CLI commands
docs/claude-code.md — Claude Code settings, commands, IDE integrations
Workflow
Create agent file — the form data submitted by the user was injected into your context as additionalContext by the UserPromptExpansion hook. It is a JSON object with mode and target fields.
Target dispatch — the JSON includes a target field that determines where the subagent lives:
target: "marketplace" — the JSON has marketplacePath and plugin. Write to <marketplacePath>/plugins/<plugin>/agents/<name>/AGENTS.md.
target: "project" — the JSON has projectPath (the user's cwd). Write to <projectPath>/.claude/agents/<name>.md as a single file (no enclosing directory). This is a project-local subagent, not registered in any marketplace.
Behaviour also depends on mode:
Auto mode (mode: "auto") — the JSON contains { mode, target, name?, idea, triggers, tools, ...destination } where destination is either { marketplacePath, plugin } or { projectPath }, and triggers/tools are string arrays:
- Use
name if provided, otherwise derive a concise kebab-case name from the idea.
- Build the
description frontmatter value:
- Take the first sentence of
idea as the "what" clause.
- If
triggers is non-empty, append Use when + the chips joined naturally (Oxford-style with "or" before the last item). If empty, append Use when <trigger condition>. as a placeholder.
- Clip the full description to 140 characters.
- Set the
tools frontmatter to the comma-joined tools array (or omit the line if empty).
- Generate complete, ready-to-use AGENTS.md content: a clear role description, when-to-apply conditions, full step-by-step workflow, and expected output format — as if a domain expert wrote it. Do not leave placeholder text.
Manual mode (mode: "manual") — the JSON contains { mode, target, name, description, triggers, tools, ...destination } where triggers and tools are string arrays:
- Use all provided values as-is.
- Build the
description frontmatter: "<description>. Use when <triggers joined with ', ' and 'or' before the last>." If triggers is empty, use the raw description only.
- Set the
tools frontmatter to the comma-joined tools array (or omit if empty).
- Create a minimal skeleton the user will fill in:
---
name: <name>
description: "<built description>"
tools: <comma-joined tools>
---
# <Title Case of name>
Instructions for AI coding agents acting as <name>. See [agents.md](https://agents.md/) for the format.
## Role — workflow
### When to apply
<triggers joined as a sentence, or a placeholder if empty>
### Workflow
1. Step one
2. Step two
### Output
Describe the expected output format here.
Hooks
If the subagent needs event hooks, add them to the plugin rather than user settings so they're distributed automatically. See Hooks and Relative Paths.
Report to user
- Report the path where the subagent was created:
- Marketplace target:
<marketplacePath>/plugins/<plugin>/agents/<name>/AGENTS.md
- Project target:
<projectPath>/.claude/agents/<name>.md
- Next steps:
- Fill in the file with the full workflow (manual mode)
- For marketplace targets only: update the marketplace so the agent becomes visible:
claude plugin marketplace update
- Project subagents are picked up automatically by Claude Code running in that project.
1---2name: create-subagent3description: Scaffolds a new subagent in a local marketplace repository: creates the agent directory and AGENTS.md file directly inside the chosen plugin. Use when the user asks to add a subagent, create an agent, or scaffold a subagent in the marketplace.4---56# Create Subagent78Scaffold a new subagent directly inside the chosen plugin of a local marketplace. The root `agents/` folder is auto-generated by CI — do not create files there manually.910For Claude Code, subagents are distributed via plugins. The AGENTS.md format is also compatible with other coding tools (Cursor, Copilot, Codex, Gemini, VS Code, Zed).1112## User's intention1314$ARGUMENTS1516## References1718Consult the relevant doc(s) before generating subagent content in auto mode or before making structural decisions in manual mode:1920- [`docs/subagents.md`](${CLAUDE_SKILL_DIR}/../../../../docs/subagents.md) — subagent usage, AGENTS.md format, coordination tips21- [`docs/plugins.md`](${CLAUDE_SKILL_DIR}/../../../../docs/plugins.md) — plugin structure, manifest, hooks and relative paths22- [`docs/hooks.md`](${CLAUDE_SKILL_DIR}/../../../../docs/hooks.md) — hook lifecycle, PreToolUse / PostToolUse, hook scripts23- [`docs/skills.md`](${CLAUDE_SKILL_DIR}/../../../../docs/skills.md) — skill format, popular repositories, skills CLI24- [`docs/marketplace.md`](${CLAUDE_SKILL_DIR}/../../../../docs/marketplace.md) — marketplace structure, registration, publishing, versioning, auto-updates25- [`docs/rules.md`](${CLAUDE_SKILL_DIR}/../../../../docs/rules.md) — rules format and scope26- [`docs/mcp.md`](${CLAUDE_SKILL_DIR}/../../../../docs/mcp.md) — MCP server configuration27- [`docs/memory.md`](${CLAUDE_SKILL_DIR}/../../../../docs/memory.md) — memory system, persistent memory for subagents28- [`docs/skills-cli.md`](${CLAUDE_SKILL_DIR}/../../../../docs/skills-cli.md) — skills CLI commands29- [`docs/claude-code.md`](${CLAUDE_SKILL_DIR}/../../../../docs/claude-code.md) — Claude Code settings, commands, IDE integrations3031## Workflow32331. **Create agent file** — the form data submitted by the user was injected into your context as `additionalContext` by the `UserPromptExpansion` hook. It is a JSON object with `mode` and `target` fields.3435 **Target dispatch** — the JSON includes a `target` field that determines where the subagent lives:36 - `target: "marketplace"` — the JSON has `marketplacePath` and `plugin`. Write to `<marketplacePath>/plugins/<plugin>/agents/<name>/AGENTS.md`.37 - `target: "project"` — the JSON has `projectPath` (the user's cwd). Write to `<projectPath>/.claude/agents/<name>.md` as a single file (no enclosing directory). This is a project-local subagent, not registered in any marketplace.3839 Behaviour also depends on `mode`:4041 **Auto mode** (`mode: "auto"`) — the JSON contains `{ mode, target, name?, idea, triggers, tools, ...destination }` where `destination` is either `{ marketplacePath, plugin }` or `{ projectPath }`, and `triggers`/`tools` are string arrays:42 - Use `name` if provided, otherwise derive a concise kebab-case name from the idea.43 - Build the `description` frontmatter value:44 - Take the first sentence of `idea` as the "what" clause.45 - If `triggers` is non-empty, append `Use when ` + the chips joined naturally (Oxford-style with "or" before the last item). If empty, append `Use when <trigger condition>.` as a placeholder.46 - Clip the full description to 140 characters.47 - Set the `tools` frontmatter to the comma-joined `tools` array (or omit the line if empty).48 - Generate complete, ready-to-use AGENTS.md content: a clear role description, when-to-apply conditions, full step-by-step workflow, and expected output format — as if a domain expert wrote it. Do not leave placeholder text.4950 **Manual mode** (`mode: "manual"`) — the JSON contains `{ mode, target, name, description, triggers, tools, ...destination }` where `triggers` and `tools` are string arrays:51 - Use all provided values as-is.52 - Build the `description` frontmatter: `"<description>. Use when <triggers joined with ', ' and 'or' before the last>."` If `triggers` is empty, use the raw description only.53 - Set the `tools` frontmatter to the comma-joined `tools` array (or omit if empty).54 - Create a minimal skeleton the user will fill in:5556 ```markdown57 ---58 name: <name>59 description: "<built description>"60 tools: <comma-joined tools>61 ---6263 # <Title Case of name>6465 Instructions for AI coding agents acting as <name>. See [agents.md](https://agents.md/) for the format.6667 ## Role — workflow6869 ### When to apply7071 <triggers joined as a sentence, or a placeholder if empty>7273 ### Workflow7475 1. Step one76 2. Step two7778 ### Output7980 Describe the expected output format here.81 ```82832. **Hooks**84 If the subagent needs event hooks, add them to the plugin rather than user settings so they're distributed automatically. See [Hooks and Relative Paths](${CLAUDE_SKILL_DIR}/../../../../docs/plugins.md#hooks-and-relative-paths).85863. **Report to user**87 - Report the path where the subagent was created:88 - Marketplace target: `<marketplacePath>/plugins/<plugin>/agents/<name>/AGENTS.md`89 - Project target: `<projectPath>/.claude/agents/<name>.md`90 - Next steps:91 - Fill in the file with the full workflow (manual mode)92 - For marketplace targets only: update the marketplace so the agent becomes visible: `claude plugin marketplace update`93 - Project subagents are picked up automatically by Claude Code running in that project.