Filesystem Subagents (.claude Agents)
Definition
Subagents defined as Markdown files with YAML frontmatter under .claude/agents/*.md, one of three ways to create subagents (alongside the programmatic agents param and the built-in general-purpose).
Key points
- Required frontmatter:
name(lowercase + hyphens; hooks receive it asagent_type),description. Optional:tools,disallowedTools,model(defaults toinherit),permissionMode(default/acceptEdits/auto/dontAsk/bypassPermissions/plan/manual),maxTurns,skills,mcpServers,hooks,memory,background,effort,isolation(worktree= temp git worktree),color,initialPrompt. - File precedence (high→low): Managed settings >
--agentsCLI flag >.claude/agents/(project) >~/.claude/agents/(user) > pluginagents/. Plugin subagents don't supporthooks/mcpServers/permissionMode. - Programmatic AgentDefinition defs take precedence over filesystem defs of the same name.
- Built-in subagents:
Explore(read-only),Plan(read-only, plan mode) — see Plan Mode And Explore Subagent — andgeneral-purpose. - Model resolution:
CLAUDE_CODE_SUBAGENT_MODELenv → per-invocationmodel→ frontmattermodel→ main model. - Subagents inherit their own system prompt + the Agent tool prompt, project CLAUDE.md (via
settingSources), and tool definitions; they do not receive parent conversation history, tool results, or system prompt.
Why it matters for the exam
- D3 (20% of scored content) tests the frontmatter fields (esp.
modeldefaulting toinherit), the file-precedence chain, and that subagents are invoked via the Agent tool.
Common gotchas
- Filesystem
modeldefaults toinherit, whereas a programmatic AgentDefinition omittingtoolsinherits all tools — different defaults for different creation paths. - Task→Agent rename: subagents are invoked via the
Agenttool, but"Task"still appears insystem:inittools and inpermission_denials[].tool_name— check both (see Task and Agent tool). - Programmatic defs override same-named filesystem defs.
See also
Sources
Referenced by
Practice questions optional · AI
Generate fresh practice questions about this concept with AI. These are not vault-verified.