← All guides

When Should You Use a Subagent? Check Isolation First

Use a subagent when the task can return a bounded result without competing for the same files. Keep coupled implementation with one owner.

The answer

Use a subagent for independent research, inspection, or analysis that returns a bounded result.

Use an isolated agent or worktree for an independent task that writes files.

Keep one agent when tasks edit the same files or depend on shared intermediate decisions.

The deciding factor is isolation, not task count.

Good subagent work

A good subagent task has a narrow question, enough context, and a clear return format.

Examples include:

  • inspect one package and report its public API;
  • compare two official documents;
  • run read-only checks against one subsystem;
  • find all callers of a changed function;
  • review a diff without editing it.

Anthropic’s official subagent documentation describes subagents as separate context windows with their own prompts and tool access. That separation helps when the delegated context does not need to stay in the main thread.

The main agent must still integrate and verify the result.

Bad subagent work

Do not delegate a task only because it sounds large.

Avoid a subagent when:

  • both agents will edit the same component;
  • one task depends on decisions still forming in the other;
  • the main agent must repeat the full investigation to trust the result;
  • the handoff is longer than the task;
  • ownership of tests or final integration is unclear.

Two agents writing one file can create a read-think-write race. The second write can replace the first without a useful conflict signal.

The parallel-agent overwrite guide explains file partitioning and worktree isolation.

Use this ownership ladder

Task shapeChoiceOwnership rule
Small and coupledOne agentOne context owns the full change
Independent and read-onlySubagentReturn evidence, not edits
Independent and separate filesAgent with explicit pathsDo not touch files outside the assignment
Independent but repository-wideSeparate worktreeIsolate index, branch, and commits
Same filesOne agentSequence the work instead of parallelizing it

This ladder keeps parallelism proportional to the real isolation available.

Write a bounded assignment

A subagent prompt needs five parts:

  1. One concrete question or deliverable.
  2. The exact files or sources it may inspect.
  3. An explicit avoid list.
  4. A return format with evidence.
  5. A statement that the main agent owns integration.

“Research this repository” is not bounded. “Inspect these three files and return every call site with line references” is bounded.

For writing tasks, add explicit file ownership. Do not allow broad staging. The unrelated-file commit guide explains why explicit paths matter.

Context isolation is useful, not free

A separate context prevents one investigation from crowding the main task. It also hides the main agent’s evolving decisions unless you send them.

Use a subagent when the return can stand alone. Do not use one for constant back-and-forth.

Read-only research is the safest starting point. Parallel file writes need stronger isolation and a final integration owner.

The default decision

Default to one agent. Add a subagent only when you can state the boundary in one sentence.

If the task writes files, name the exact owned paths. If ownership cannot be separated, sequence the work.

Use which coding agent should you use to choose the primary workflow. Use MCP vs skills when the delegated task needs a new capability or a repeatable procedure.

Decision check

Should this task use a subagent?

Choose the task shape and file overlap. The result tells you when delegation helps and when it creates risk.

Need OpenClaw fixed live?

Remote rescue sessions for gateway, auth, tunnel, VPS, and model access problems.

See Rescue Session

Read next

AGENTS.md vs CLAUDE.md: Pick One Source of Truth
Use AGENTS.md for portable repository rules. Use CLAUDE.md for Claude-specific behavior. Keep shared rules in one file to prevent drift.
MCP vs Skills for Agent Tools: Use This Rule
Use a skill for a repeatable workflow. Use MCP when the agent needs a new external capability. This guide shows where each boundary belongs.
Which Coding Agent Should You Use? A Workflow Decision
Choose Codex, Claude Code, or Cursor from the work surface, control layer, and task shape. The interactive guide gives one recommendation.
Can Qwen 3.8 Replace Claude for Coding? The Honest Verdict
I ran Qwen3.8-27B as a local coding agent instead of Claude. Where it holds up, where it breaks, the hardware you need, and the split most people land on.