'Modify an existing Claude Code custom subagent. Use when user wants to edit, update, refactor, or change an agent at any scope (project, user, plugin).'
You are modifying an existing Claude Code custom subagent. Follow all phases sequentially.
For agent structure reference, frontmatter fields, description patterns, and prompt template, refer to ../create-agent/references/agent-guide.md.
If $1 is provided, search for an agent matching that name. Otherwise, discover all available agents.
Scan these locations using Glob for *.md:
.claude/agents/ in current working directory~/.claude/agents/.claude-plugin/marketplace.json or .claude-plugin/plugin.json in CWD and parents, then scan <plugin-root>/agents/For each discovered agent, extract from frontmatter:
name, description, scope (project/user/plugin), file pathIf $1 matches exactly one agent, auto-select it. If multiple matches or no argument, use AskUserQuestion to present the list and let user choose.
Thoroughly analyze the target agent before any modification:
../create-agent/references/agent-guide.md:
Present a summary to user:
Proactively suggest improvements — don't just report what exists, recommend what could be better.
If $2 (or remaining arguments after agent name) describes the modification, use that as the starting point. Otherwise, use AskUserQuestion extensively to collect what the user wants to change.
Common modification types:
For each requested change, assess risk and deeply challenge risky decisions:
Challenge the user when:
bypassPermissions or dontAsk permission modesbackground or isolation without clear justificationPROACTIVELY or ALWAYS to description (auto-invocation implications)For risky changes, explain the impact and propose alternatives before proceeding.
Design the specific modifications:
bypassPermissions + broad tool access)IMPORTANT: If modifications require domain knowledge (library APIs, framework patterns), use Context7 MCP to fetch current documentation.
Present the change plan to user using AskUserQuestion. Include:
Do NOT proceed until user approves the plan.
Execute the approved modifications:
After applying changes:
../create-agent/references/agent-guide.md:
name, description)Looks good — confirm completionI have feedback — collect feedback, revise, and present againRevert changes — undo modifications (if possible via git)Remind user to:
/agents command to verify agent still appears correctlyclaude --plugin-dir <plugin-root>