Creates new subagent definitions with YAML frontmatter grounded in the docs corpus. Includes model selection heuristics and tool restriction patterns. Use when creating a new Claude Code subagent from scratch.
Generates a new subagent definition with correct YAML frontmatter, minimal tool restrictions, and a structured system prompt grounded in the docs corpus.
Check if a subagent with the same name already exists at:
.claude/agents/{requested-name}.mdplugins/*/agents/{requested-name}.mdIf a subagent already exists with that name:
{requested-name} already exists."/agent-customizer:improve-subagent to evaluate and optimize it instead.If no subagent exists with that name: Proceed to Phase 1 below.
Delegate to the artifact-analyzer agent with this task:
Analyze the project to understand existing subagents. Focus on: agent names and roles in
.claude/agents/andplugins/*/agents/, tool restrictions in use, model choices,maxTurnsvalues, which skills delegate to which agents, and naming conventions. Flag any agents similar in purpose to{requested-name}. Also identify the project layout: whether this is a monorepo (multiple plugin directories, workspace files likepnpm-workspace.yaml) or a single-package project.
The agent runs on Sonnet with read-only tools (Read, Grep, Glob, Bash) in an isolated context. Wait for it to complete and parse its structured output.
Before generating, read these reference documents:
${CLAUDE_SKILL_DIR}/references/subagent-authoring-guide.md — when to use subagents, system prompt structure, model selection heuristics, tool restriction patterns, anti-patterns${CLAUDE_SKILL_DIR}/references/subagent-config-reference.md — YAML frontmatter fields, valid model IDs, tool allowlist/denylist, orchestration patterns, plugin restrictions${CLAUDE_SKILL_DIR}/references/prompt-engineering-strategies.md — subagent-specific prompting (role prompting, structured output, confidence filtering)Read ${CLAUDE_SKILL_DIR}/assets/templates/subagent-definition.md and fill its placeholders using:
Apply model selection heuristic:
haiku — fast read-only exploration agents (simple lookups, no reasoning required)sonnet — standard analysis and review agents (default for most subagents)opus — complex multi-step reasoning only (requires explicit justification)Determine target location:
.claude/agents/{name}.md — project-level agent (accessible everywhere)plugins/{plugin}/agents/{name}.md — plugin-scoped agent (restricted to plugin context)Read ${CLAUDE_SKILL_DIR}/references/subagent-validation-criteria.md and execute its Validation Loop Instructions against the generated subagent definition.
The loop evaluates all hard limits and quality checks, fixes any failures, and re-evaluates — maximum 3 iterations. Do not proceed to Phase 4 until ALL criteria pass.
hooks, mcpServers, permissionMode), warn that these fields are ignored in plugin context