David WalshSubscribe
Claude Code · Skill

Agent Creator

Create Claude Code subagent definitions — the YAML + Markdown files in .claude/agents/ that the main thread delegates tasks to. Interviews you enough to make opinionated choices, then writes a definition that actually triggers.

v114 KBsubagents · claude-code · workflow
Download .skill

This skill creates Claude Code subagent definitions — the YAML+Markdown files that live in .claude/agents/ (project scope) or ~/.claude/agents/ (user scope), and that Claude Code's main thread delegates tasks to based on their descriptions.

A good subagent is deceptively hard to write. Most of the quality comes down to two things:

  1. The description field. This is the only signal the main Claude thread uses to decide whether to delegate. If it's vague, the agent either never triggers or triggers on the wrong things.
  2. The system prompt body. It has to give the subagent a clear role, workflow, and output format without turning into a wall of MUSTs.

Your job is to interview the user enough to understand what the agent should do, make opinionated choices for them where you can, write a definition that actually triggers when it should, and save it to the right place on disk.

When to use this skill

Any request that implies creating, editing, or understanding a subagent definition. For example:

If the user is asking about Claude Code subagents conceptually (how they work, when to use them, what they're for) rather than asking to build one, just answer the question — you don't need to produce a file.

The shape of a subagent file

---
name: <kebab-case-identifier>        # required
description: <when to delegate>      # required — the triggering signal
tools: <comma-separated list>        # optional — inherits all if omitted
model: <sonnet|haiku|opus|inherit>   # optional — defaults to inherit
---

<System prompt in Markdown.>
<Describes the subagent's role, workflow, and output format.>

Only name and description are required. Every other field has a sensible default. Don't add a field unless it's pulling its weight — don't set model: inherit explicitly, don't list every tool if inheriting is fine, don't set permissionMode: default.

The full field reference lives in references/frontmatter-reference.md. Read it when you need a field not covered in this file (hooks, memory, isolation, worktrees, permission modes, MCP scoping, skills preloading).

Five complete example agents (researcher, reviewer, debugger, DB query validator with hooks, specialist with preloaded skills) live in references/examples.md. Consult when you want a concrete reference for a shape you're drafting.

The workflow

1. Understand what the agent should do

The user usually tells you in one line: "an agent that does X". That's a starting point, not a spec. Before writing anything, you want clear answers to these, inferred from context or asked:

If the user gave enough detail upfront, skip straight to drafting. If they gave a one-liner, ask 2–3 targeted questions — don't interrogate. Good question shapes: "Should this be able to edit files, or read-only?", "Do you want it to run automatically after code changes, or only when you explicitly @-mention it?", "Project-scoped (checked into this repo) or available across all your projects?".

If the skill was invoked because the user said "turn this into an agent" about a workflow already in the conversation, mine the conversation for answers before asking anything — what tools got used, what output shape the user expected, what corrections they made along the way. Confirm your inferences briefly, then draft.

2. Choose the scope

Default to project unless the user said something that implies user scope ("I want this available everywhere", "add this to my personal agents", or the task is obviously generic).

3. Write the name

Lowercase, hyphenated, 2–4 words. It should be a thing, not a sentence: pr-reviewer, test-runner, migration-guardian. Avoid generic suffixes like -agent or -bot — the whole file is an agent, the suffix is noise. Make it specific enough that a teammate seeing it in .claude/agents/ can guess what it does.

4. Write the description — this is the most important field

Claude Code's main thread reads the description to decide whether to delegate. If the description doesn't clearly say when to use this agent, auto-delegation won't happen. Include three things:

  1. What the agent does, in action-oriented language.
  2. When to use it — the specific situations that should trigger it.
  3. Whether delegation should be proactive. If you want Claude to delegate automatically without being asked, include the phrase "use proactively" or equivalent. If the agent should only run when explicitly invoked, leave that out.

Good descriptions — narrow, action-oriented, specific:

Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.

Runs the test suite and reports only failing tests with their error messages. Use after implementing a feature, after refactoring, or whenever the user asks whether anything broke.

Database migration reviewer. Reads proposed SQL migrations, checks for unsafe operations (table locks, missing indexes, destructive changes without backups), and blocks risky migrations. Use proactively before applying any migration.

Bad descriptions:

If the user hasn't told you whether delegation should be proactive, infer from the task. Safety-critical things (migration review, test runs before deploys, security scans) usually want "use proactively". Flow-interrupting things (style nitpicks, refactoring suggestions) usually don't. When uncertain, ask.

5. Choose tools

Omit tools entirely to inherit everything from the main conversation. Specify tools only when you want to restrict. Two common patterns:

If the agent needs MCP tools, inheriting is simplest — the main conversation's MCP servers come along. Use mcpServers only when you want to give the agent access to an MCP server not in the parent session, or scope one exclusively to the subagent. See the reference file for syntax.

disallowedTools is the denylist alternative. Use when you want to inherit everything except a few tools:

disallowedTools: Write, Edit

When in doubt, restrict more rather than less. Tight tool scoping is one of the main reasons to use a subagent in the first place — it makes the agent cheaper to trust and easier to debug.

6. Choose the model

Pin a model only when you have a reason. "Inherit" means the user's session choice flows through, which is usually what they want.

7. Write the system prompt body

This is the Markdown under the frontmatter. It's the subagent's entire system prompt — it does NOT inherit Claude Code's default system prompt, just this plus basic environment info (working directory, etc.).

A good system prompt has four parts:

1. Role statement — one or two sentences. Sets identity and standards.

You are a senior code reviewer ensuring high standards of code quality and security.

2. Workflow — numbered list, 3–6 steps. The sequence the subagent follows when invoked. Steps should be concrete actions.

When invoked:
1. Run `git diff` to see recent changes
2. Focus on modified files
3. Begin review immediately

3. Checklist or criteria — bullet list. What to look for, what counts as done. This is where most of the domain knowledge lives.

4. Output format — explicit. How to structure the final response. "Organize feedback by priority: critical / warnings / suggestions" is good. Leaving it implicit tends to produce rambling.

Things to avoid in system prompts:

8. Show the draft to the user

Before writing anything to disk, show the user the complete file — frontmatter and body — and ask if they want to adjust. People often have opinions about description wording or want to tighten the tool list once they see it written out.

9. Save the file

Write to the appropriate path based on scope:

Create the directory if it doesn't exist:

mkdir -p .claude/agents

After saving, tell the user:

Common patterns

A few shapes that come up repeatedly. Use them as starting points, not templates to copy blindly. Five complete worked examples live in references/examples.md.

Read-only researcher

For anything that explores a codebase or external docs without changing anything. Examples: understanding how a feature works, finding all callers of a function, summarizing a large log file.

tools: Read, Grep, Glob, Bash
model: haiku   # optional — speeds up exploration

System prompt: emphasize returning only the summary the main conversation needs, not dumping everything found.

Reviewer (read-only with structured output)

PR reviewers, security scanners, style checkers. Read-only with a specific output format that makes findings actionable.

tools: Read, Grep, Glob, Bash

System prompt: numbered review checklist, output organized by priority (critical / warning / suggestion), with concrete fix suggestions.

Worker (read + edit with verification)

Implementers, refactorers, debuggers — agents that modify code. These should always end with a verification step (run tests, re-read the file, run the linter) so they don't return "done" when they aren't.

tools: Read, Edit, Write, Bash, Grep, Glob

System prompt: diagnose → minimal fix → verify → summarize what changed.

Specialist for an external tool

DB query runners, browser automators, API clients. Usually need a specific MCP server or CLI tool. Restrict tools tightly and, if the tool is destructive (e.g., SQL), consider a PreToolUse hook that validates the action. Hook syntax is in the reference file.

Diagnosing bad drafts

If the draft feels off, common fixes:

Things worth proactively flagging

While drafting, mention these to the user if relevant — they're easy to miss:

Reference files

Install

Download agent-creator.skill with the button above, then follow the steps for your surface.

Claude Desktop / Web
  1. Open SettingsCustomize.
  2. In the Skills panel, click the + button.
  3. Choose Upload skill file and select agent-creator.skill.
  4. The skill is live immediately — trigger it the next time its description matches what you're doing.
Claude Code (CLI)
  1. Unzip the .skill file into ~/.claude/skills/ (user scope) or .claude/skills/ (project scope).
  2. You should end up with ~/.claude/skills/agent-creator/SKILL.md.
  3. Restart Claude Code. The skill loads on next launch and the main thread will delegate to it when its description matches.