plugins/build/skills/build-subagent/SKILL.md
Scaffolds a Claude Code custom subagent definition — a `.md` file under `.claude/agents/` with a routing-oriented description, an explicit `tools` allowlist sized to the workflow, a bounded system prompt in the markdown body, and explicit failure behavior. Use when the user wants to "create a subagent", "scaffold an agent", or "make a custom agent". Not for skills (route to `/build:build-skill`), hooks (route to `/build:build-hook`), or rules (route to `/build:build-rule`).
npx skillsauth add bcbeidel/wos build-subagentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Scaffold a Claude Code custom subagent definition: a single .md file
in .claude/agents/ (project) or ~/.claude/agents/ (user) that the
routing agent can delegate to with confidence. The authoring rubric —
what a good subagent does, the file anatomy, the patterns that work —
lives in
subagent-best-practices.md.
This skill is the workflow; the principles doc is the rubric.
A subagent is a full context fork — high-cost compared to a skill (same-context execution) or an inline tool call. The first question every intake answers is whether a subagent is even the right primitive.
Workflow sequence: 1. Route → 2. Scope Gate → 3. Elicit → 4. Draft → 5. Safety Check → 6. Review Gate → 7. Save → 8. Test
Also fires when the user phrases the request as:
Confirm a subagent is the right primitive before asking scaffold questions.
Wrong primitive:
/build:build-skill.
Skills execute in the parent context; no fork cost./build:build-hook. Hooks have a settings.json registration and
a lifecycle a subagent does not express./build:build-rule./build:build-bash-script or
/build:build-python-script.The full primitive-selection decision lives in primitive-routing.md.
Right primitive — proceed to Scope Gate only when at least one subagent-specific justification holds:
permissionMode the parent should not hold.If none hold, recommend a skill instead and stop:
"A skill fits this better — same-context execution, no fork cost. Use
/build:build-skillinstead?"
Refuse to scaffold — and recommend an alternative — when the request signals subagent is the wrong choice. Probe for:
claude --agent <name> — a
different authoring surface than subagent delegation. The
tools / Agent(<type>) semantics differ; flag and confirm the
user wants the subagent (delegated) path, not the main-thread path.If a signal fires, state it, name the alternative, and stop.
If $ARGUMENTS is non-empty, seed the intake: first token is the
proposed name, remainder is the capability description. Confirm both
before moving on.
Gather inputs one at a time:
1. Name — kebab-case, lowercase, hyphen-separated, descriptive of
the primary role (typescript-linter, migration-reviewer). Not
generic (agent, helper). The filename stem must equal the name.
2. Description — the routing contract. Write it for the routing agent, not a human reader. Structure:
.ts
files", "when the user asks to check migration safety").Keep the total under 1,024 characters — descriptions exceeding this limit are silently truncated by Claude Code without warning.
3. Primary capability + workflow — what does the agent do, start to finish? What artifact does it produce? Every workflow has an explicit completion condition — "done" must be describable.
4. Tool requirements — what does the agent need to do its job? For each proposed tool, verify the workflow requires it. Apply least-privilege in step 3 of Draft; surface over-/under-requests now only to clarify scope.
5. Advanced fields — surface each only when the workflow signals it; do not present as a menu.
permissionMode — only when the agent's risk profile differs
from the parent. Six spec values: default, acceptEdits, auto,
dontAsk, bypassPermissions, plan.
bypassPermissions,
acceptEdits, or auto, the subagent's permissionMode is
overridden at runtime.plugins/<plugin>/agents/), permissionMode, hooks,
and mcpServers are silently ignored.maxTurns — multi-step or recursive workflows; safety net
against runaway loops. Add alongside (not instead of) a workflow
completion condition.background: true — only when parallelism was the Step 1
justification.isolation: worktree — required when background: true
AND effective tools include Write or Edit. Parallel writes on
shared files conflict without worktree isolation.skills — parent session skills are not inherited. List
explicitly if the workflow needs project-specific procedures.memory: user | project | local — enables a persistent memory
directory. Side effect: auto-grants Read, Write, Edit regardless
of the tools allowlist. Flag this to the user when tools is
narrow.mcpServers — scope MCP servers to this subagent only (keeps
server tool descriptions out of the parent's token budget). Ignored
for plugin-scoped subagents.Produce the subagent definition.
---
name: <kebab-case-slug>
description: <routing-rule: verb-phrase capability + trigger conditions + exclusion + returns>
tools:
- <Tool1>
- <Tool2>
---
# <Display Name>
<One-line role/goal statement: "You are a ...">
## Scope
In scope: <what the agent handles>.
Out of scope: <what the agent refuses or escalates>.
## Process
1. <First step — reads inputs, validates preconditions>
2. <…>
N. <Completion condition: what "done" looks like and what the
agent returns to the parent>
## Output
<Mandated format — JSON schema / markdown structure / named artifact
path. Downstream callers parse this; keep it machine-parsable.>
## Failure behavior
<How the agent reports blockers: bad input, missing access, ambiguous
request. Deterministic exits only — no workarounds, no flailing.>
Least-privilege filter — before locking the tools list:
Write, Edit, or Bash.Bash is the widest attack surface — grant only when shell
execution is the core job, and enumerate allowed commands in the
prompt body.WebFetch / WebSearch — internal-only workflows should not have
these.Agent in subagent scope — the Agent tool is filtered out at
the platform level for delegated subagents; listing it has no
effect and misleads readers. Exception: Agent(<worker>, ...) is
meaningful for definitions intended to run as main thread via
claude --agent <name>. Flag only for subagent-scope use.Add optional frontmatter fields only when intake surfaced them — no placeholder or commented-out keys.
Before presenting for review, run the rubric checks yourself:
Location & format. File will save to .claude/agents/<name>.md
(or ~/.claude/agents/<name>.md). Frontmatter is a ----delimited
YAML block. name and description are present and non-empty.
Naming. name is kebab-case. Filename stem equals name. Not
generic.
Description. Routing-rule form (verb-phrase + trigger + exclusion
.claude/agents/ (scan the directory).Tools. Effective set is declared explicitly, no wildcards.
Proportionate to the described workflow. Agent not listed (unless
main-thread use). When background: true + Write/Edit is set,
isolation: worktree is present. When memory: is set alongside a
narrow tools list, the user has been warned about the implicit
Read/Write/Edit grant.
Body. Prompt opens with a role/goal statement. Scope and out-of-scope are explicit. A completion condition exists in the workflow. Output format is mandated, not free-form. Failure behavior is explicit. Voice is imperative; no hedging ("try your best", "if possible"). Total body bounded — target ≤~1,500 tokens (~6,000 chars), hard cap ≈3,000 tokens (~12,000 chars).
Safety. No embedded secrets. No raw interpolation of untrusted user input.
If any check fails, revise before presenting. The Review Gate is for user approval, not correctness recovery.
Present the draft with a short narration — 3–6 bullets naming the design choices: which tools, why; which advanced fields, why; which considered patterns were skipped and why. A user unfamiliar with subagent authoring should be able to disagree with any structural choice from the narration alone.
Wait for explicit user approval before writing. If the user requests changes, revise and re-present. Proceed to Save only on explicit approval.
Write to .claude/agents/<name>.md (or the plugin path when
scaffolding inside a plugin). Confirm the save path and that the file
was written.
Offer the audit:
"Run
/build:check-subagent <path>to audit the scaffolded definition against the Tier-1 checks and judgment dimensions?"
The audit is the canonical follow-on — it catches anything the Safety Check missed and gives a baseline-clean starting point.
tools sets are flagged by
/build:check-subagent Tier-2.Agent in a subagent's tools list — always a no-op for
delegated subagents; drop it or flag the main-thread alternative.maxTurns for multi-step workflows.background: true with Write/Edit and no isolation: worktree
— parallel writes on shared files conflict. Scaffold the
worktree isolation when the combination appears.memory: tool expansion — when memory: is set
alongside a narrow tools list, surface the implicit
Read/Write/Edit grant to the user before Save.$ARGUMENTS alone.Agent in a subagent's tools — it's filtered at the
platform level for delegated agents.Chainable to: /build:check-subagent (audit the scaffolded
definition against the Tier-1 checks and judgment dimensions).
tools
Use when the user wants to "audit a help skill", "review my plugin index", or "verify my help-skill is up to date". Audits a plugins/<plugin>/skills/help/SKILL.md against the help-skill rubric — coverage, freshness, frontmatter fidelity, plus five judgment dimensions and a trigger-collision check.
tools
Use when the user wants to "scaffold a help skill", "add a /<plugin>:help command", or "build a plugin index skill", or wants to give a plugin an orientation surface that lists its skills and common workflows. Produces a SKILL.md at plugins/<plugin>/skills/help/SKILL.md.
tools
Audits pair-level integrity of a primitive-pair (the artifact `/build:build-skill-pair` produces) by walking the four required artifact slots — principles doc, `build-<primitive>/SKILL.md`, `check-<primitive>/SKILL.md`, and the `primitive-routing.md` registration — and reports cross-artifact issues a per-SKILL.md checker cannot see: missing principles doc, divergent principles paths between halves, absent routing registration, missing build→check handoff. Per-half structural compliance with the unified pattern (`check-skill-pattern.md`) is delegated to `plugins/build/_shared/scripts/check_skill_pattern.py`. Use when the user wants to "audit a skill pair", "review a primitive pair", or "validate the skill pair for X". Not for auditing a single SKILL.md — route to `/build:check-skill`. Not for re-distilling a stale principles doc — route to `/build:build-skill-pair`.
testing
Audit a root-level resolver — verify AGENTS.md pointer, managed-region integrity, filing-table coverage against disk, context-table actionability, and trigger-eval pass rate. Use when the user wants to "audit a resolver", "validate routing table", or "find dark capabilities".