/meta:create-agentsfrom meta
Designing, authoring, and auditing Claude Code subagents — frontmatter, tool scoping, model choice, and memory. Use when creating, editing, or auditing an agent file in `.claude/agents/`.
Ships in meta. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
First, call the Skill tool for "writing-for-agents". A subagent body is a document an agent consumes, so those rules govern how it is written; this skill covers the subagent-specific mechanics on top.
Author Claude Code subagents that delegate well, stay focused, and keep the main conversation clean. Subagents are specialized AI assistants that run in their own context window with a custom system prompt, scoped tool access, and independent permissions. They follow the spec at code.claude.com/docs/en/sub-agents.
| Pick subagent when | Pick something else when |
|---|---|
| Task produces verbose output you don't need in main context | Task needs frequent back-and-forth or iterative refinement |
| You want to enforce specific tool restrictions or permissions | Multiple phases share significant context (plan -> impl -> test) |
| Work is self-contained and only the summary matters | You're making a quick, targeted change in current context |
| You keep spawning the same kind of worker with the same instructions | Logic is reusable knowledge or workflow -> use a skill |
| You want context isolation for parallel research | Workers need to message each other -> use agent teams |
| You want a guarantee that fires on a lifecycle event -> use a hook |
See subagents-vs-alternatives.md for a full decision matrix.
Subagents are Markdown files with YAML frontmatter. The frontmatter is the configuration; the body is the system prompt.
---
name: code-reviewer
description: Expert reviewer. Use proactively after code changes.
tools: Read, Glob, Grep, Bash
model: opus
---
You are a senior code reviewer. When invoked:
1. Run git diff to see recent changes
2. Focus on modified files
3. Provide feedback organized by severity
Subagents receive only this system prompt plus basic environment info (working directory). They inherit CLAUDE.md (or AGENTS.md when it loads as project instructions, v2.1.277+; skipped with omitClaudeMd: true) and git status from the parent, but not the parent's conversation history, its invoked skills, or the default Claude Code system prompt. List skills explicitly with the skills: field if you need them.
Higher-priority locations override lower ones when names collide. Every scope is scanned recursively, and identity comes from the name field alone, so keep names unique across the tree.
| Location | Scope | Priority |
|---|---|---|
Managed settings .claude/agents/ | Org-wide | 1 (highest) |
--agents CLI flag (JSON) | Current session | 2 |
<project>/.claude/agents/ | Current project | 3 |
~/.claude/agents/ | All your projects | 4 |
<plugin>/agents/ | Where plugin is enabled | 5 (lowest) |
Project subagents (.claude/agents/) live with the code and ride version control. User subagents (~/.claude/agents/) follow you across every project. See scopes-and-discovery.md for the --agents JSON form and plugin notes.
Claude Code watches .claude/agents/ and ~/.claude/agents/, so adding or editing a file takes effect within a few seconds — no restart. Two exceptions: creating a scope's first agent file in an agents directory that didn't exist at session start, and sessions launched with --disable-slash-commands. As of v2.1.198 /agents no longer opens a creation wizard; write the file or ask Claude to.
Only name and description are required. Full details in frontmatter.md.
| Field | Purpose |
|---|---|
name | Unique identifier. Lowercase letters and hyphens. Can't start with - or contain : (reserved for plugin scoping) — such files are skipped with a debug-log error (v2.1.218+). |
description | When Claude should delegate to this subagent. Front-load trigger phrases. |
tools | Allowlist of tools. If omitted, inherits all tools from parent. If no entry resolves to a tool, the subagent usually fails to launch. |
disallowedTools | Denylist. Applied before tools resolves. A specifier entry like Bash(git push *) still removes the whole tool. |
model | sonnet, opus, haiku, fable, a full model ID, or inherit. If omitted, resolves via CLAUDE_CODE_SUBAGENT_MODEL, then the main conversation's model. |
permissionMode | default (alias manual), acceptEdits, auto, dontAsk, bypassPermissions, or plan. bypassPermissions applies only when the parent is already in it. |
maxTurns | Hard cap on agentic turns before the subagent stops. Output is returned marked partial and can be resumed (v2.1.246+). |
autoCompactWindow | Auto-compact window in tokens, 100000 to 1000000. Requires v2.1.296+. |
skills | Skills to fully preload into the subagent's context at startup (up to 32, v2.1.295+). |
mcpServers | MCP servers scoped to this subagent. Inline definitions or names. |
hooks | Lifecycle hooks scoped to this subagent's runtime. |
memory | user, project, or local. Enables cross-session persistent memory. |
background | true to always run in background, even when Claude needs the result right away. Redundant where fork mode is on (the default) — Claude Code backgrounds every spawned subagent there and Claude can't ask for the foreground. |
omitClaudeMd | true to launch without user, project, and local CLAUDE.md (managed policy files still load). Ignored when run as the main session via --agent. Requires v2.1.271+. |
effort | low, medium, high, xhigh, max. Available levels depend on the model. |
isolation | worktree to run in a temporary git worktree. |
color | UI color: red, blue, green, yellow, purple, orange, pink, cyan. |
initialPrompt | Auto-submitted first user turn when this agent runs as the main session via --agent. |
experimental | Map of experimental options. Its cacheTtl key (5m or 1h) picks the prompt-cache lifetime for this subagent's requests. Read only from subagent files. Requires v2.1.248+. |
Plugin subagents ignore hooks, mcpServers, and permissionMode. Copy the file into .claude/agents/ if you need those.
Pick exactly one of these strategies, not both at once unless intentional:
tools: Read, Grep, Glob, Bash -> subagent only sees these.disallowedTools: Edit, Write -> subagent inherits everything else from parent.disallowedTools applies first, then tools resolves against the remainder.Fork mode is on by default in interactive sessions (v2.1.232+) and, since v2.1.302, in -p, the Agent SDK, the desktop app, and VS Code; CLAUDE_CODE_FORK_SUBAGENT=0 turns it off. Where it's on, every subagent Claude spawns runs in the background; where it's off, Claude backgrounds by default and foregrounds when it needs the result. A background subagent keeps every MCP tool but only a narrow set of built-ins: Read, Grep, Glob, Bash, PowerShell, Edit, Write, NotebookEdit, WebFetch, WebSearch, TodoWrite, Skill, ToolSearch, EnterWorktree, ExitWorktree, Monitor, TaskStop, SendMessage, Artifact. Anything else is dropped silently, whether inherited or named in tools, so the same definition can resolve to different tools in foreground and background. Forks are exempt.
permissionMode works like CLI --permission-mode. Parent modes bypassPermissions, acceptEdits, and auto always take precedence over the subagent's setting, and a subagent can't escalate into bypassPermissions from a parent in default, dontAsk, or plan — that value is dropped for the parent's mode (v2.1.267+). See tools-and-permissions.md for Agent(type) spawn restrictions and permissions.deny rules.
Claude Code already ships with several. Don't recreate these:
| Built-in | Model | Use for |
|---|---|---|
Explore | Inherits (capped at Opus on the Claude API) | Read-only codebase search and analysis |
Plan | Inherits | Read-only research during plan mode |
general-purpose | Inherits | Multi-step tasks needing both exploration and modification |
claude | Inherits | Catch-all with every subagent-available tool, for tasks no specialized agent fits |
statusline-setup | Sonnet | Triggered by /statusline |
claude-code-guide | Haiku | Triggered by questions about Claude Code features |
Reach for a custom subagent when these don't fit. See built-in-subagents.md.
For most cases, copy templates/basic-subagent.md and fill in:
name (lowercase + hyphens, matches filename)description (front-load trigger phrases; add "use proactively" if you want eager delegation)tools or disallowedTools (least privilege)model and effort, picked per role from ~/.claude/skills/tune-harness/references/model-routing.mdThen drop the file in <project>/.claude/agents/<name>.md (project) or ~/.claude/agents/<name>.md (personal). The watcher picks it up within seconds; restart only if that agents directory didn't exist when the session started.
| Template | Purpose |
|---|---|
| basic-subagent.md | Minimal frontmatter, custom system prompt |
| read-only-reviewer.md | Code reviewer with locked-down tools |
| researcher.md | Read-only explorer with persistent memory |
| implementer.md | Edit-capable specialist in a worktree |
| domain-expert.md | Memory + preloaded skills for a domain |
| Workflow | Purpose |
|---|---|
| create-new-subagent.md | Author a new subagent end to end |
| audit-existing-subagent.md | Review an existing file against best practices |
| debug-subagent.md | Diagnose missed delegations, runaway tools, stale memory |
bypassPermissions to silence prompts -> writes to .git, .claude, .vscode skip approval. Use acceptEdits or pre-approve in permissions.allow instead.CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH changes it; 1 turns nesting off). To stop a subagent from spawning others, omit Agent from its tools or add it to disallowedTools. For workers that must message each other, use agent teams.context: fork skills for reference-only content -> the fork gets no task and returns nothing.MEMORY.md by hand mid-session -> the subagent owns curation. Read memory.md for proper usage.name matches filenamemodel and effort match the role in model-routing.mdpermissionMode set if subagent runs autonomouslyskills: lists every skill the subagent needs (parent skills don't carry over)memory: set with right scope if cross-session learning is neededhooks/mcpServers/permissionMode (silently ignored)Agent is in tools only if the subagent should spawn its own subagents (depth capped at 3 by default)Detailed guidance lives in references/:
--agents JSON, managed settingsAgent(type) spawn control, permission modesskills: field, inverse with context: fork, what doesn't inheritsettings.json lifecycle hooks@-mention, --agent, agent settingWhat SKILL.md sets; muted values are Claude Code's defaults
9 skills in this plugin
/brainstorm-modsBrainstorm mods and plugins worth building, for one project or globally, then design and build the one you pick./claude-docsAnswer Claude Code questions (CLI, Agent SDK, plugins, hooks, skills, slash commands, MCP, settings) from a locally cached copy of the official docs./create-mcpAuthor Code Mode MCP servers that wrap multiple host functions behind one code-generating tool, replacing per-call JSON tool dispatch with a single executed JavaScript function.Other plugins' skills for the same job
npx claudepluginhub sustinbebustin/.dotfiles --plugin meta