What this thread does
Do first: Ask Claude to create a project specialist under .claude/agents/, give it a bounded task and return format, and explicitly request delegation to it.
Short answer
A normal subagent starts with fresh conversation context. To isolate repository edits too, set isolation: worktree. A separate context alone leaves the subagent in the parent's working directory.
What to do
Create a Markdown file with YAML frontmatter between opening and closing ---, followed by the specialist's system prompt. For a reviewer, the documented example is .claude/agents/code-reviewer.md.
| Field / control | Value / action |
|---|---|
| Required fields | name, description; description tells Claude when to delegate |
| Name constraints | At most 256 characters; cannot start with - or contain :; identity comes from name, not filename |
| Read-only review tools | tools: Read, Glob, Grep; omit tools to inherit all tools available to subagents |
| Denied tools | disallowedTools; tool specifiers such as Bash(git push *) remove the entire tool |
| Model | sonnet, opus, haiku, fable, full ID such as claude-opus-5-5, or inherit; omitted normally uses the parent's model |
| Model precedence | Invocation model alias → definition model → CLAUDE_CODE_SUBAGENT_MODEL → parent's model |
| Own effort | effort: low, medium, high, xhigh, max, subject to model support; invocation effort overrides definition, but CLAUDE_CODE_EFFORT_LEVEL wins over both; invocation parameter requires v2.1.292 or later |
| Repository isolation | isolation: worktree; temporary worktree branches from the default branch, not necessarily parent HEAD; automatically removed if unchanged |
| Bounded run | maxTurns; reaching it returns partial output that can be resumed; partial marker requires v2.1.246 or later |
| Permissions | permissionMode: default (alias manual), acceptEdits, auto, dontAsk, bypassPermissions, plan; omitted inherits main mode |
| Permission constraints | Parent bypassPermissions, acceptEdits or auto forces that mode; parent plan keeps plan, and dontAsk also denies prompts; default/dontAsk parents honor the requested mode except unavailable auto or bypassPermissions; bypass exception requires v2.1.267 or later |
Ask for a specific agent and a concise report; include file scope, evidence to return, and whether to wait. Non-fork subagents do not receive your conversation history. A fork does inherit it.
Definitions in an existing project agents directory reload within seconds for the next delegation. Restart after creating the first agents directory, editing an agents directory loaded via --add-dir or /add-dir, or using a session with --disable-slash-commands. Project directories are scanned recursively; the definition nearest the working directory wins across nested project directories. Same-directory duplicate names depend on filesystem order; use /doctor to locate them.
Background execution is the default. In interactive terminal, VS Code or desktop sessions, to let Claude wait: set CLAUDE_CODE_FORK_SUBAGENT=0 in the environment or settings.json, start a new session, then ask it to wait for the report. Ctrl+B moves waiting work into the background. Alternatively, CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 makes Claude wait and disables background commands and Ctrl+B.
Background permission prompts appear in the main session; Esc denies one tool call. Results arrive in a completion notification. /tasks shows a subagent's model and effort from v2.1.242; ask Claude to resume a completed custom subagent when needed.
Limits and open questions
- Default running-agent threshold: 20. Another Agent-tool spawn returns
Concurrent subagent limit reached; wait until the running count drops.CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTSaccepts any positive whole number; available fromv2.1.217. Ultracode sessions are exempt; forks and resumes can occupy slots without being blocked by this limit. - A named Agent call in interactive agent-teams mode can become a teammate in the main checkout. Pass isolation on the invocation itself to preserve the subagent path; frontmatter isolation alone does not prevent that conversion.
- Plugin agents ignore
hooks,mcpServers,permissionMode; copy the definition into project scope when those fields are needed. - Worktree isolation is not an independent permission boundary. Review allowed tools and parent permissions.
Not for: Codex custom TOML agents.
Sources
- Create custom subagents, Anthropic.
- Markdown version, Anthropic.
Checked
2026-11-16; read Create custom subagents and its Markdown version, including scope, frontmatter, model/effort selection, isolation, permissions, background runs and concurrency; no command was run.
Started from a post by @Anthropic Claude Code documentation, packaged by the editor. Original post