When to delegate
A useful assignment has an input, a stopping point and a deliverable. “Compare these two files and list unsupported claims” is easier to review than “improve our documentation.” Keep a quick edit or a conversation that needs frequent decisions in the main session.
Anthropic’s team comparison explains the native distinction. Teams are experimental and require separate enablement. They can also affect delegation: with teams enabled, a subagent Claude names can launch as a teammate. For the broader setup, see multiple Claude Code agents.
For a one-off codebase lookup, Claude also has a built-in read-only Explore subagent. Define a custom worker when you want to reuse a particular review contract. See built-in subagents.
Start with one worker. Add parallel assignments only when each can finish without waiting for another worker’s changes.
Prerequisites
You need an installed, signed-in Claude Code CLI, a local project where you may create example files, and permission to read those files. Check your installed version:claude auth status if sign-in is uncertain. This exercise needs no MCP server, external API, package installation or credentials in files. Leave experimental agent teams disabled for the exercise so you can inspect ordinary subagent delegation.
1. Prepare two small inputs
From your project root, create these directories if they do not already exist:subagent-demo/routes.json:
subagent-demo/api-guide.md:
2. Define a reusable, read-only reviewer
Save the following as.claude/agents/docs-route-auditor.md. Project definitions live in .claude/agents/; personal definitions live in ~/.claude/agents/. The frontmatter configures the worker and the Markdown body supplies its instructions. See subagent file configuration.
maxTurns bounds agentic turns, not elapsed time or spending. A worker reaching that limit can return partial output; decide whether the remaining question merits another run. See the frontmatter reference.
3. Invoke that worker with a complete assignment
Start a fresh interactive session from the same project root after saving the files:@ and select docs-route-auditor from the agent picker. Current Claude Code also accepts the manual mention below. An agent mention selects the worker explicitly; a natural-language request leaves delegation to Claude’s judgment. See explicit invocation.
claude --agent docs-route-auditor flag starts the main session using that agent definition. It is useful for a dedicated reviewer session, but it is a different exercise from delegating a worker inside your current conversation. See --agent in the CLI reference.
4. Observe the run and verify the result
Use/tasks to inspect running shells and subagents. In the terminal, Ctrl+O opens the detailed transcript viewer. Ctrl+T toggles Claude’s checklist, which is a different view. See interactive controls.
Subagents can work in the background. Wait for the completion result before assessing findings; an active task is still work in progress. See foreground and background execution.
Check the actual delegation and tool activity before accepting the answer. For this fixture, a useful report should:
- Identify
GET /statusin the guide as absent from the supplied inventory. - Cite the relevant files and lines, with a suggested removal or qualification.
- State that no server was queried and no runtime behavior was verified.
- Leave the two inputs unchanged.
Permissions and context boundaries
Review/permissions before broadening access. Deny rules take precedence over ask and allow rules, and managed policies can constrain the session. A description such as “read-only” expresses intent; the tool list and permission system enforce what calls are available. See permission rules.
This definition omits permissionMode, so it inherits the parent mode. Setting that field does not guarantee an independent mode: the parent can override it. Check subagent permission modes before adding a mode to another worker.
Do not solve a blocked review by granting every tool. First decide whether the task actually requires the blocked action. This fixture needs file reads; a shell or write permission would not help prove the mismatch.
An ordinary non-fork subagent starts with a separate context, rather than the full chat history. Send the decision-relevant facts and paths in the assignment. A conversation fork is an exception and inherits the conversation. See startup context and fork behavior.
Keep important constraints in the assignment even when project instructions also cover them. For example: “The inventory is a fixture; do not probe production” removes ambiguity that a filename alone cannot resolve. Context separation also does not assign file ownership or isolate simultaneous edits. Use worktrees when independently editing checkouts is appropriate.
Troubleshooting
The configuration and version checks follow Anthropic’s subagent troubleshooting details. For installation and settings diagnostics, use the read-only
claude doctor command documented in the CLI reference.