$npx -y skills add luongnv89/skills --skill subagent-creatorCreate, evaluate, or improve Claude Code subagent files (.claude/agents/*.md) — the frontmatter + system prompt defining a delegatable specialist. Don't use for skills (skill-creator), CLAUDE.md/AGENTS.md (agent-config), or running an agent.
| 1 | # Subagent Creator |
| 2 | |
| 3 | Create, evaluate, and improve **Claude Code subagents** — the `.md` files (in `.claude/agents/` for a project or `~/.claude/agents/` for personal use) whose YAML frontmatter plus system prompt define a specialist the main agent can delegate to with an isolated context window and restricted tools. |
| 4 | |
| 5 | This is **not** about skills (`skill-creator` owns those) or `CLAUDE.md`/`AGENTS.md` (`agent-config` owns those). A subagent is one file: frontmatter (`name`, `description`, `tools`, `model`, …) + a system-prompt body. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | Use when the user asks to create, review, or fix a Claude Code subagent definition file (`.claude/agents/*.md` or personal `~/.claude/agents/*.md`). Do not use for skills or for editing CLAUDE.md/AGENTS.md. |
| 10 | |
| 11 | ## Pick the branch first |
| 12 | |
| 13 | Three branches. Identify which one the user is on before doing anything else — they don't share a starting step. |
| 14 | |
| 15 | | Branch | Trigger | Go to | |
| 16 | |--------|---------|-------| |
| 17 | | **Create** | "make a subagent that…", "I need an agent for X", no file exists yet | [Creating a subagent](#creating-a-subagent) | |
| 18 | | **Evaluate** | "review this agent", "is this subagent any good", "audit `.claude/agents/foo.md`" | [Evaluating a subagent](#evaluating-a-subagent) | |
| 19 | | **Improve** | "fix this agent", "this subagent isn't triggering / over-reaches", points at an existing file | [Improving a subagent](#improving-a-subagent) | |
| 20 | |
| 21 | If the request is ambiguous ("look at my agent"), assume **Evaluate** and confirm before editing anything. |
| 22 | |
| 23 | ## Mandatory rules (all branches) |
| 24 | |
| 25 | These apply on every write, regardless of branch. |
| 26 | |
| 27 | ### Repo Sync Before Edits (when target is a project repo) |
| 28 | |
| 29 | A subagent written to `.claude/agents/` lives in a version-controlled repo. **Before creating or editing a file there**, sync to avoid clobbering remote work: |
| 30 | |
| 31 | ```bash |
| 32 | branch="$(git rev-parse --abbrev-ref HEAD)" |
| 33 | git fetch origin |
| 34 | git pull --rebase origin "$branch" |
| 35 | ``` |
| 36 | |
| 37 | If the working tree is dirty: stash → sync → pop. If `origin` is missing or a conflict occurs: **stop and ask the user.** Skip this section only when the target is `~/.claude/agents/` (personal, not a repo) — confirm the scope with the user before assuming. |
| 38 | |
| 39 | ### Frontmatter safety + version |
| 40 | |
| 41 | - **Subagent file** `name` must be lowercase letters/digits/hyphens, no consecutive hyphens. Identity comes from `name`, not the filename — they need not match, but keeping `name` == filename stem (`code-reviewer` → `code-reviewer.md`) is a recommended convention. |
| 42 | - Quote any frontmatter string value containing `:` `#` `-` `<` `>` `|` `,` `&` `?` `!` `[` `]` `{` `}` `*` to keep YAML valid. `description` almost always needs quotes. |
| 43 | - This **SKILL.md** itself follows the catalog's own rule: bump `metadata.version` on every edit. |
| 44 | |
| 45 | ### Scope check (one question, not an interview) |
| 46 | |
| 47 | Confirm **where the file goes** — `.claude/agents/<name>.md` (project, team-shared, version-controlled) or `~/.claude/agents/<name>.md` (personal, cross-project). This decides Repo Sync above and nothing else. The source guideline encodes the rest of the intent, so don't over-interview. |
| 48 | |
| 49 | --- |
| 50 | |
| 51 | ## Creating a subagent |
| 52 | |
| 53 | Goal: one well-formed `<name>.md` file that triggers reliably, stays in its lane, and holds only the tools it needs. |
| 54 | |
| 55 | ### 1. Capture the specialist in one sentence |
| 56 | |
| 57 | A good subagent has a **single responsibility**. Force the purpose into one sentence: *"A read-only security auditor that flags auth and data-exposure bugs in changed files."* If you need "and" to join two unrelated jobs, that's two subagents. Read `references/system-prompt-guide.md` → *Single responsibility* if the scope feels fuzzy. |
| 58 | |
| 59 | ### 2. Choose frontmatter |
| 60 | |
| 61 | Start from the **minimal set** and add only what the job demands. Read `references/frontmatter-schema.md` for every field, which are safe-and-common vs. advanced-and-rot-prone, and the tool-restriction syntax. |
| 62 | |
| 63 | Minimal viable frontmatter: |
| 64 | |
| 65 | ```yaml |
| 66 | --- |
| 67 | name: <kebab-name> |
| 68 | description: "<when to invoke + what it does. Add 'Use PROACTIVELY' to encourage auto-delegation.>" |
| 69 | tools: Read, Grep, Bash # omit entirely to inherit ALL tools |
| 70 | model: inherit # inherit | sonnet | opus | haiku |
| 71 | --- |
| 72 | ``` |
| 73 | |
| 74 | Decisions, in order: |
| 75 | - **`description`** — the primary trigger. Say *when* to invoke and *what* it does. Add `Use PROACTIVELY` (or `MUST BE USED`) when the agent should auto-delegate. This is the single highest-leverage field; see the description guidance in `references/system-prompt-guide.md`. |
| 76 | - **`tools`** — least privilege. Prefer read-only (`Read, Grep, Glob`) for analysis/review agents; add `Edit`/`Write` only for agents that change code; scope ` |