Skip to content

Sub-agents Best Practice

Last Updated: Apr 04, 2026 | Claude Code v2.1.92

Claude Code subagents -- frontmatter fields and official built-in agent types.

Frontmatter Fields (16)

FieldTypeRequiredDescription
namestringYesUnique identifier using lowercase letters and hyphens
descriptionstringYesWhen to invoke. Use "PROACTIVELY" for auto-invocation by Claude
toolsstring/listNoComma-separated allowlist of tools (e.g., Read, Write, Edit, Bash). Inherits all tools if omitted. Supports Agent(agent_type) syntax to restrict spawnable subagents; the older Task(agent_type) alias still works
disallowedToolsstring/listNoTools to deny, removed from inherited or specified list
modelstringNoModel alias: haiku, sonnet, opus, or inherit (default: inherit)
permissionModestringNoPermission mode: default, acceptEdits, auto, dontAsk, bypassPermissions, or plan
maxTurnsintegerNoMaximum number of agentic turns before the subagent stops
skillslistNoSkill names to preload into agent context at startup (full content injected, not just made available)
mcpServerslistNoMCP servers for this subagent -- server name strings or inline {name: config} objects
hooksobjectNoLifecycle hooks scoped to this subagent. All hook events are supported; PreToolUse, PostToolUse, and Stop are the most common
memorystringNoPersistent memory scope: user, project, or local
backgroundbooleanNoSet to true to always run as a background task (default: false)
effortstringNoEffort level override when this subagent is active: low, medium, high, max. Default: inherits from session
isolationstringNoSet to "worktree" to run in a temporary git worktree (auto-cleaned if no changes)
initialPromptstringNoAuto-submitted as the first user turn when this agent runs as the main session agent (via --agent or the agent setting). Commands and skills are processed. Prepended to any user-provided prompt
colorstringNoCLI output color for visual distinction (e.g., green, magenta)

Official Built-in Agents (5)

#AgentModelToolsDescription
1general-purposeinheritAllComplex multi-step tasks -- the default agent type for research, code search, and autonomous work
2ExplorehaikuRead-only (no Write, Edit)Fast codebase search and exploration -- optimized for finding files, searching code, and answering codebase questions
3PlaninheritRead-only (no Write, Edit)Pre-planning research in plan mode -- explores the codebase and designs implementation approaches before writing code
4statusline-setupsonnetRead, EditConfigures the user's Claude Code status line setting
5claude-code-guidehaikuGlob, Grep, Read, WebFetch, WebSearchAnswers questions about Claude Code features, Agent SDK, and Claude API

Sources