<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Subagents on RockB</title><link>https://baeseokjae.github.io/tags/subagents/</link><description>Recent content in Subagents on RockB</description><image><title>RockB</title><url>https://baeseokjae.github.io/images/og-default.png</url><link>https://baeseokjae.github.io/images/og-default.png</link></image><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 08 Jul 2026 12:00:00 +0000</lastBuildDate><atom:link href="https://baeseokjae.github.io/tags/subagents/index.xml" rel="self" type="application/rss+xml"/><item><title>Claude Code Subagents Parallel Agents Guide 2026: Faster Development Without Context Bloat</title><link>https://baeseokjae.github.io/posts/claude-code-subagents-guide-2026/</link><pubDate>Wed, 08 Jul 2026 12:00:00 +0000</pubDate><guid>https://baeseokjae.github.io/posts/claude-code-subagents-guide-2026/</guid><description>A practical Claude Code subagents guide for parallel agents, worktrees, model routing, and real developer workflows in 2026.</description><content:encoded><![CDATA[<p>Claude Code subagents are the cleanest way to delegate noisy, self-contained coding work without filling your main session with logs, search results, and half-finished reasoning. In 2026, they are also the simplest entry point to parallel AI development: Markdown files, YAML frontmatter, scoped tools, optional worktree isolation.</p>
<p>I use subagents when a task has a clear boundary and a noisy execution path. Running a full test suite, researching three unrelated modules, auditing a diff for security issues, or generating migration notes are good fits. Asking a subagent to co-own an ambiguous refactor with you is usually a bad fit. The difference matters because subagents do not share your full conversation by default. They start with their own prompt, their own context window, and a task summary from the main agent.</p>
<p>This guide focuses on the parts that actually change day-to-day Claude Code usage: how subagents are defined, how to run them in parallel, when to add <code>isolation: worktree</code>, how model routing affects cost, and when you should step up to agent teams instead. I am using the current Claude Code behavior from the official <a href="https://code.claude.com/docs/en/sub-agents">subagents documentation</a>, including the v2.1.198 changes where <code>/agents</code> no longer opens the old interactive wizard and subagents run in the background by default.</p>
<h2 id="what-are-claude-code-subagents">What Are Claude Code Subagents?</h2>
<p>A Claude Code subagent is a specialized worker that Claude can delegate to from your main session. Each custom subagent is a Markdown file with YAML frontmatter at the top and a system prompt in the body. Claude Code discovers these files from known scopes such as <code>.claude/agents/</code> for a project or <code>~/.claude/agents/</code> for your personal machine-wide agents.</p>
<p>In practice, a subagent gives you three things that a normal prompt does not:</p>
<table>
  <thead>
      <tr>
          <th>Capability</th>
          <th>What it means in practice</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Isolated context</td>
          <td>Logs, search output, and exploratory reads stay inside the subagent instead of bloating the main chat</td>
      </tr>
      <tr>
          <td>Specialized behavior</td>
          <td>The subagent can have a tighter role, output format, and tool policy than your main session</td>
      </tr>
      <tr>
          <td>Parallel execution</td>
          <td>Multiple independent subagents can investigate separate paths at the same time</td>
      </tr>
  </tbody>
</table>
<p>The context isolation is the feature I care about most. When building a migration plan, I often want one worker to inspect schema files, another to scan API handlers, and a third to read test failures. I do not want all intermediate file reads and dead-end hypotheses in the main session. I want the final summary, affected files, risks, and recommended patch order.</p>
<p>Subagents are not magic concurrency. They are useful when the work can be split cleanly. If two workers need to edit the same file or make decisions based on each other&rsquo;s partial results, you need stronger coordination. That is where agent teams or explicit sequential phases become better choices.</p>
<h2 id="how-do-subagents-differ-from-agent-teams">How Do Subagents Differ From Agent Teams?</h2>
<p>Claude Code now has several parallel-work primitives: subagents, agent teams, worktrees, background agents, and plain multiple terminal sessions. The confusing part is that they overlap. The practical decision is simple: use subagents when workers only need to report back to the caller; use <a href="https://code.claude.com/docs/en/agent-teams">agent teams</a> when workers need to talk to each other.</p>
<table>
  <thead>
      <tr>
          <th>Pattern</th>
          <th>Best for</th>
          <th>Communication</th>
          <th>Cost profile</th>
          <th>Main risk</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Subagents</td>
          <td>Focused research, review, test runs, summaries</td>
          <td>Report back to main agent</td>
          <td>Lower than agent teams</td>
          <td>Poor task boundaries</td>
      </tr>
      <tr>
          <td>Agent teams</td>
          <td>Multi-role design, competing hypotheses, cross-layer features</td>
          <td>Teammates can message each other</td>
          <td>Higher, each teammate is a full Claude instance</td>
          <td>Coordination overhead</td>
      </tr>
      <tr>
          <td>Worktrees</td>
          <td>File isolation for parallel edits</td>
          <td>No orchestration by itself</td>
          <td>Similar to separate sessions</td>
          <td>Environment drift</td>
      </tr>
      <tr>
          <td>Multiple terminals</td>
          <td>Manual parallel work</td>
          <td>You coordinate everything</td>
          <td>Depends on usage</td>
          <td>Human context switching</td>
      </tr>
  </tbody>
</table>
<p>I reach for subagents first because the overhead is low. A reviewer subagent can inspect code and return a short report. A test-runner subagent can run noisy commands and return only failing tests. A docs-writer subagent can draft release notes without mixing prose work into an implementation session.</p>
<p>Agent teams are different. They are experimental, disabled by default, and require <code>CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1</code>. They make sense when you want a lead session to coordinate several independent Claude Code instances through a shared task list and mailbox. In the official docs, Anthropic recommends agent teams for research and review, new modules or features, debugging with competing hypotheses, and cross-layer coordination.</p>
<p>The trade-off is token cost. Anthropic&rsquo;s cost guidance says agent teams consume significantly more tokens because each teammate maintains its own context window. For routine sub-tasks, a subagent is cheaper and easier to reason about.</p>
<h2 id="how-do-you-create-a-custom-subagent">How Do You Create a Custom Subagent?</h2>
<p>As of Claude Code v2.1.198, the <code>/agents</code> command no longer opens the old interactive creation wizard. The current path is to ask Claude to write the agent file or create the Markdown file directly. This is a good change for teams because the actual artifact is reviewable and versionable.</p>
<p>Create a project-scoped subagent here:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>.claude/
</span></span><span style="display:flex;"><span>  agents/
</span></span><span style="display:flex;"><span>    code-reviewer.md
</span></span><span style="display:flex;"><span>    test-runner.md
</span></span><span style="display:flex;"><span>    migration-planner.md
</span></span></code></pre></div><p>Create a personal subagent here:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>~/.claude/
</span></span><span style="display:flex;"><span>  agents/
</span></span><span style="display:flex;"><span>    code-reviewer.md
</span></span></code></pre></div><p>Project subagents are best when the role depends on repository conventions. For example, a Rails monolith reviewer and a Next.js edge-runtime reviewer should not share the same assumptions. Personal subagents are better for generic habits you want everywhere, such as &ldquo;summarize failing tests without editing files.&rdquo;</p>
<p>Here is a subagent definition I would actually start from:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-markdown" data-lang="markdown"><span style="display:flex;"><span>---
</span></span><span style="display:flex;"><span>name: test-runner
</span></span><span style="display:flex;"><span>description: Runs test commands, captures failures, and returns concise debugging notes. Use after code changes or when tests are failing.
</span></span><span style="display:flex;"><span>tools: Read, Bash, Grep, Glob
</span></span><span style="display:flex;"><span>model: sonnet
</span></span><span style="display:flex;"><span>permissionMode: default
</span></span><span style="display:flex;"><span>maxTurns: 8
</span></span><span style="display:flex;"><span>background: true
</span></span><span style="display:flex;"><span>color: cyan
</span></span><span style="display:flex;"><span>---
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>You are a test runner for this repository.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Run the smallest relevant test command first. If that fails because the target is unclear,
</span></span><span style="display:flex;"><span>inspect package scripts, Makefiles, or project docs to find the right command.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Return:
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">1.</span> The command you ran
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">2.</span> Passing or failing status
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">3.</span> The smallest useful failure excerpt
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">4.</span> Likely cause
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">5.</span> Next debugging step
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Do not modify source files.
</span></span><span style="display:flex;"><span>Do not paste full logs unless the user explicitly asks.
</span></span></code></pre></div><p>There are a few details in that file that matter.</p>
<p>The <code>description</code> is not a label. It is the routing rule. Claude uses the task description, the current context, and this field to decide whether to delegate. Generic descriptions like &ldquo;helps with tests&rdquo; are weak. Specific descriptions like &ldquo;Runs test commands, captures failures, and returns concise debugging notes&rdquo; trigger more reliably.</p>
<p>The <code>tools</code> list is deliberately narrow. If a test runner should not edit files, do not give it edit tools. If a researcher only needs <code>Read</code>, <code>Grep</code>, and <code>Glob</code>, keep it read-only. I have found that tool scoping is one of the easiest ways to make agent behavior more predictable.</p>
<p>The <code>model</code> field should match the task. Use <code>sonnet</code> for most implementation and review work. Use <code>haiku</code> for simple summarization, changelog drafting, and low-risk lookups. Reserve <code>opus</code> for difficult architecture or debugging tasks where a wrong answer costs more than the tokens.</p>
<h2 id="which-frontmatter-fields-matter-most">Which Frontmatter Fields Matter Most?</h2>
<p>The official frontmatter surface is broader than most teams need on day one. Only <code>name</code> and <code>description</code> are required, but the optional fields are where subagents become production-grade.</p>
<table>
  <thead>
      <tr>
          <th>Field</th>
          <th>Use it when</th>
          <th>Example</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>name</code></td>
          <td>You need a stable agent identifier</td>
          <td><code>security-reviewer</code></td>
      </tr>
      <tr>
          <td><code>description</code></td>
          <td>You want automatic delegation to work</td>
          <td><code>Reviews auth changes for token, session, and input validation risks</code></td>
      </tr>
      <tr>
          <td><code>tools</code></td>
          <td>The agent should only use selected tools</td>
          <td><code>Read, Grep, Glob</code></td>
      </tr>
      <tr>
          <td><code>disallowedTools</code></td>
          <td>You inherit tools but want to block a few</td>
          <td><code>Edit, Write</code></td>
      </tr>
      <tr>
          <td><code>model</code></td>
          <td>The task needs explicit model routing</td>
          <td><code>haiku</code>, <code>sonnet</code>, <code>opus</code>, <code>claude-sonnet-5</code></td>
      </tr>
      <tr>
          <td><code>permissionMode</code></td>
          <td>You want a specific approval posture</td>
          <td><code>default</code>, <code>plan</code>, <code>acceptEdits</code></td>
      </tr>
      <tr>
          <td><code>maxTurns</code></td>
          <td>You want to cap runaway loops</td>
          <td><code>6</code></td>
      </tr>
      <tr>
          <td><code>background</code></td>
          <td>The task can run while you continue</td>
          <td><code>true</code></td>
      </tr>
      <tr>
          <td><code>effort</code></td>
          <td>The model supports effort levels and this task needs tuning</td>
          <td><code>low</code>, <code>medium</code>, <code>high</code></td>
      </tr>
      <tr>
          <td><code>isolation</code></td>
          <td>The subagent may edit files in parallel</td>
          <td><code>worktree</code></td>
      </tr>
      <tr>
          <td><code>skills</code></td>
          <td>The subagent should start with known skill content loaded</td>
          <td><code>[&quot;review-pr&quot;]</code></td>
      </tr>
      <tr>
          <td><code>hooks</code></td>
          <td>You need lifecycle automation around the subagent</td>
          <td><code>SubagentStart</code>, <code>SubagentStop</code></td>
      </tr>
  </tbody>
</table>
<p>Two fields deserve special attention in 2026: <code>background</code> and <code>isolation</code>.</p>
<p>As of v2.1.198, subagents run in the background by default unless Claude needs the result before continuing. Permission prompts still surface in the main session. That means background execution is not a permission bypass; it is a scheduling behavior.</p>
<p>The <code>isolation: worktree</code> field gives a subagent a temporary git worktree. This matters when a subagent can modify files while other work is happening. Without worktree isolation, two agents editing the same checkout can collide. With isolation, each agent gets a separate working directory and branch context.</p>
<h2 id="how-do-you-run-subagents-in-parallel">How Do You Run Subagents in Parallel?</h2>
<p>You can invoke a subagent in natural language:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Use the test-runner subagent to run the auth tests and summarize failures.
</span></span></code></pre></div><p>You can also ask for multiple independent subagents:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Research the authentication, billing, and notification modules in parallel using separate subagents.
</span></span><span style="display:flex;"><span>Return a table with each module&#39;s entry points, risky dependencies, and test coverage gaps.
</span></span></code></pre></div><p>For more control, mention specific subagents:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Use the security-reviewer, test-runner, and docs-writer subagents in parallel.
</span></span><span style="display:flex;"><span>security-reviewer: inspect the auth diff for session and token risks.
</span></span><span style="display:flex;"><span>test-runner: run the smallest relevant auth test target and report failures only.
</span></span><span style="display:flex;"><span>docs-writer: draft migration notes for the changed login behavior.
</span></span><span style="display:flex;"><span>Wait for all three summaries before recommending the next patch.
</span></span></code></pre></div><p>The last sentence is not cosmetic. I often tell Claude to wait for all summaries because otherwise the main agent may start synthesizing too early. Parallel work is only useful if you collect the independent findings before deciding.</p>
<p>When building a real feature, I prefer a three-phase flow:</p>
<table>
  <thead>
      <tr>
          <th>Phase</th>
          <th>Main agent action</th>
          <th>Subagent action</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Explore</td>
          <td>Define boundaries and questions</td>
          <td>Inspect modules, logs, docs, tests</td>
      </tr>
      <tr>
          <td>Plan</td>
          <td>Merge findings into one patch plan</td>
          <td>Review plan for missing risks</td>
      </tr>
      <tr>
          <td>Execute</td>
          <td>Make changes in controlled order</td>
          <td>Run tests, review diff, draft docs</td>
      </tr>
  </tbody>
</table>
<p>This maps well to the broader <a href="/posts/ai-dlc-framework-2026/">AI-DLC framework</a> pattern: agents are strongest when you give them explicit lifecycle stages instead of one vague &ldquo;build this&rdquo; instruction.</p>
<h2 id="when-should-you-use-worktrees-with-subagents">When Should You Use Worktrees With Subagents?</h2>
<p>Use worktrees when parallel agents might edit files. Do not overthink it. If a subagent is read-only, worktrees are usually unnecessary. If it may write code while your main session or another agent is also writing code, add worktree isolation.</p>
<p>Claude Code supports worktree-backed sessions through <code>claude --worktree</code>, and subagents can use worktree isolation through frontmatter:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-markdown" data-lang="markdown"><span style="display:flex;"><span>---
</span></span><span style="display:flex;"><span>name: feature-implementer
</span></span><span style="display:flex;"><span>description: Implements isolated feature slices that can be reviewed and merged back by the main agent. Use when a task owns a distinct file area.
</span></span><span style="display:flex;"><span>tools: Read, Edit, Bash, Grep, Glob
</span></span><span style="display:flex;"><span>model: sonnet
</span></span><span style="display:flex;"><span>isolation: worktree
</span></span><span style="display:flex;"><span>maxTurns: 12
</span></span><span style="display:flex;"><span>---
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>You implement a single isolated feature slice.
</span></span><span style="display:flex;"><span>Before editing, identify the files you expect to own.
</span></span><span style="display:flex;"><span>Do not edit files outside that ownership boundary without stopping and reporting why.
</span></span><span style="display:flex;"><span>Run the narrowest relevant verification command before returning.
</span></span></code></pre></div><p>The current <a href="https://code.claude.com/docs/en/worktrees">worktrees documentation</a> has a few operational details that are easy to miss:</p>
<table>
  <thead>
      <tr>
          <th>Worktree behavior</th>
          <th>Why it matters</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>claude --worktree name</code> creates an isolated checkout under <code>.claude/worktrees/&lt;name&gt;/</code> by default</td>
          <td>Parallel sessions do not touch the same files</td>
      </tr>
      <tr>
          <td><code>.worktreeinclude</code> copies gitignored files such as <code>.env.local</code></td>
          <td>Agents can run tests that need local config</td>
      </tr>
      <tr>
          <td><code>worktree.baseRef</code> can use <code>&quot;fresh&quot;</code> or <code>&quot;head&quot;</code></td>
          <td>Use <code>&quot;head&quot;</code> when subagents must see your unpushed changes</td>
      </tr>
      <tr>
          <td>Subagent worktrees are removed automatically if they finish without changes</td>
          <td>Read-only or no-op work does not leave clutter</td>
      </tr>
      <tr>
          <td>v2.1.203 tightened behavior when a worktree directory disappears</td>
          <td>Commands should fail rather than accidentally run in the main checkout</td>
      </tr>
  </tbody>
</table>
<p>The <code>worktree.baseRef</code> setting is the one I see teams get wrong. The default branches from the repository default branch. That is good for clean isolated tasks, but bad if your subagent needs the uncommitted or unpushed work in your current branch. For that case:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;worktree&#34;</span>: {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;baseRef&#34;</span>: <span style="color:#e6db74">&#34;head&#34;</span>
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Also add this to <code>.gitignore</code>:</p>
<pre tabindex="0"><code class="language-gitignore" data-lang="gitignore">.claude/worktrees/
</code></pre><p>If your tests depend on local secrets, use <code>.worktreeinclude</code> rather than asking every agent to manually copy files:</p>
<pre tabindex="0"><code class="language-gitignore" data-lang="gitignore">.env
.env.local
config/secrets.json
</code></pre><p>Only gitignored files matching <code>.worktreeinclude</code> patterns are copied. Tracked files are not duplicated through this mechanism.</p>
<h2 id="how-should-you-route-opus-sonnet-and-haiku">How Should You Route Opus, Sonnet, and Haiku?</h2>
<p>Model routing is where subagents become economically useful. The mistake is running every worker on your strongest model. That feels safe, but it burns budget on tasks that do not need deep reasoning.</p>
<p>My default routing looks like this:</p>
<table>
  <thead>
      <tr>
          <th>Task</th>
          <th>Model</th>
          <th>Reason</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Architecture review</td>
          <td><code>opus</code></td>
          <td>Higher reasoning value, fewer cheap shortcuts</td>
      </tr>
      <tr>
          <td>Implementation</td>
          <td><code>sonnet</code></td>
          <td>Best default balance for code edits</td>
      </tr>
      <tr>
          <td>Test failure triage</td>
          <td><code>sonnet</code></td>
          <td>Needs code understanding and command output interpretation</td>
      </tr>
      <tr>
          <td>Changelog or PR summary</td>
          <td><code>haiku</code></td>
          <td>Low-risk summarization</td>
      </tr>
      <tr>
          <td>File inventory or dependency list</td>
          <td><code>haiku</code></td>
          <td>Mostly extraction</td>
      </tr>
      <tr>
          <td>Security review of auth or payment code</td>
          <td><code>opus</code> or pinned full model ID</td>
          <td>False negatives are expensive</td>
      </tr>
  </tbody>
</table>
<p>Claude Code also supports <code>CLAUDE_CODE_SUBAGENT_MODEL</code>, which overrides the per-invocation model and the subagent definition&rsquo;s <code>model</code> field. That is useful for controlled rollouts:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>export CLAUDE_CODE_SUBAGENT_MODEL<span style="color:#f92672">=</span>sonnet
</span></span></code></pre></div><p>For third-party deployments such as Amazon Bedrock, Google Cloud&rsquo;s Agent Platform, or Microsoft Foundry, the official model configuration docs recommend pinning provider-specific model IDs instead of relying blindly on aliases. Aliases are convenient for local use, but production teams usually want controlled upgrades.</p>
<p>This is the same basic trade-off I covered in the <a href="/posts/claude-sonnet-5-review-2026/">Claude Sonnet 5 review</a>: the best model is not always the most expensive model. The best model is the cheapest one that reliably clears the quality bar for that task.</p>
<h2 id="what-real-world-subagent-patterns-work-best">What Real-World Subagent Patterns Work Best?</h2>
<p>After using subagents on real repositories, I would start with five patterns. They are boring, which is a compliment. Boring agent workflows are easier to debug.</p>
<h3 id="how-do-you-use-a-review-swarm-without-getting-duplicate-findings">How Do You Use a Review Swarm Without Getting Duplicate Findings?</h3>
<p>Do not spawn five generic reviewers. Give each reviewer a different lens:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Run three subagents in parallel:
</span></span><span style="display:flex;"><span>1. security-reviewer: auth, secrets, injection, unsafe file access
</span></span><span style="display:flex;"><span>2. performance-reviewer: N+1 queries, caching, hot paths, bundle size
</span></span><span style="display:flex;"><span>3. test-reviewer: missing regression coverage and brittle tests
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Each subagent should return only high-confidence findings with file paths and severity.
</span></span></code></pre></div><p>This works because the domains do not overlap too much. A generic &ldquo;review this PR&rdquo; prompt produces duplicate comments and shallow coverage. Separate review lenses produce fewer but better findings.</p>
<p>For security-sensitive agent work, read the <a href="/posts/mozilla-0din-claude-code-case-study-2026/">Mozilla 0DIN Claude Code case study</a> as a reminder that clean-looking repositories can still manipulate coding agents through instructions, scripts, or environment assumptions. A subagent with fewer tools is not just cleaner; it is a smaller blast radius.</p>
<h3 id="how-do-you-keep-test-runs-from-polluting-context">How Do You Keep Test Runs From Polluting Context?</h3>
<p>A test-runner subagent should be one of the first agents you create. Test output is high-volume and mostly disposable. You rarely need 2,000 lines of stack traces in your main conversation.</p>
<p>Use a prompt like this:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Use the test-runner subagent to run the smallest relevant test target for the checkout flow.
</span></span><span style="display:flex;"><span>Return the command, pass/fail status, and at most 40 lines of failure output.
</span></span><span style="display:flex;"><span>Do not edit files.
</span></span></code></pre></div><p>That &ldquo;at most 40 lines&rdquo; constraint matters. Subagents return summaries to the main session, and detailed summaries still consume context. If you need the full log, ask for it later.</p>
<h3 id="how-do-you-split-a-migration-safely">How Do You Split A Migration Safely?</h3>
<p>For migrations, I use subagents for exploration, not blind implementation:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Use parallel subagents to inspect:
</span></span><span style="display:flex;"><span>1. database schema and migrations
</span></span><span style="display:flex;"><span>2. API handlers and service objects
</span></span><span style="display:flex;"><span>3. frontend form and validation code
</span></span><span style="display:flex;"><span>4. tests and factories
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Each subagent should report affected files, coupling points, and migration risks.
</span></span><span style="display:flex;"><span>Do not edit files yet.
</span></span></code></pre></div><p>Then the main agent creates one plan. This avoids the common failure mode where four workers each make locally reasonable changes that do not compose.</p>
<h3 id="how-do-you-use-community-subagents-safely">How Do You Use Community Subagents Safely?</h3>
<p>The <a href="https://github.com/VoltAgent/awesome-claude-code-subagents">VoltAgent awesome-claude-code-subagents repository</a> has grown into a large catalog of community subagents, with language specialists, backend roles, frontend roles, infrastructure roles, and meta-orchestration agents. It is useful, but I would not install a large pack into a production repository without review.</p>
<p>Treat community subagents like shell scripts from the internet:</p>
<table>
  <thead>
      <tr>
          <th>Check</th>
          <th>Why</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Read the prompt body</td>
          <td>It is executable behavior, even if it is Markdown</td>
      </tr>
      <tr>
          <td>Narrow the <code>tools</code> list</td>
          <td>Do not inherit broad tools by accident</td>
      </tr>
      <tr>
          <td>Prefer project scope for team agents</td>
          <td>Review changes through normal code review</td>
      </tr>
      <tr>
          <td>Avoid secrets access by default</td>
          <td>Most agents do not need environment files</td>
      </tr>
      <tr>
          <td>Pin behavior in your repo</td>
          <td>Do not depend on changing upstream prompts</td>
      </tr>
  </tbody>
</table>
<p>Community agents are strongest as starting points. Copy the useful role structure, remove assumptions that do not match your stack, and tighten the output format.</p>
<h3 id="how-do-you-avoid-parallel-agent-conflicts">How Do You Avoid Parallel Agent Conflicts?</h3>
<p>Most failed subagent workflows come from weak ownership boundaries. If two agents can touch the same files, you need either worktrees or a different plan.</p>
<p>I use this rule:</p>
<table>
  <thead>
      <tr>
          <th>Situation</th>
          <th>Use</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Multiple agents reading different areas</td>
          <td>Plain subagents</td>
      </tr>
      <tr>
          <td>Multiple agents editing different packages</td>
          <td>Subagents with <code>isolation: worktree</code></td>
      </tr>
      <tr>
          <td>Agents need to debate or coordinate</td>
          <td>Agent teams</td>
      </tr>
      <tr>
          <td>Same file needs careful edits</td>
          <td>Main session only</td>
      </tr>
      <tr>
          <td>High-risk production migration</td>
          <td>Plan mode plus review subagents</td>
      </tr>
  </tbody>
</table>
<p>For same-file edits, parallelism is usually fake speed. You save five minutes of agent time and spend fifteen minutes resolving inconsistent patches.</p>
<h2 id="what-configuration-should-a-team-start-with">What Configuration Should A Team Start With?</h2>
<p>For a real engineering team, I would check in three project subagents first:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>.claude/agents/
</span></span><span style="display:flex;"><span>  code-reviewer.md
</span></span><span style="display:flex;"><span>  test-runner.md
</span></span><span style="display:flex;"><span>  migration-planner.md
</span></span></code></pre></div><p>The <code>code-reviewer</code> should be read-only unless your process explicitly allows reviewer-suggested edits. The <code>test-runner</code> can use <code>Bash</code>, but should not use edit tools. The <code>migration-planner</code> should be read-only and biased toward plans, affected files, and risk tables.</p>
<p>Then add team guidance to your <code>CLAUDE.md</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-markdown" data-lang="markdown"><span style="display:flex;"><span><span style="color:#75715e">## Subagent usage
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">-</span> Use <span style="color:#e6db74">`test-runner`</span> after source changes that affect behavior.
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">-</span> Use <span style="color:#e6db74">`code-reviewer`</span> before final summaries for non-trivial diffs.
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">-</span> Use <span style="color:#e6db74">`migration-planner`</span> before database, API contract, or auth-flow changes.
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">-</span> Use worktree isolation before running any subagent that may edit files in parallel.
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">-</span> Do not spawn more than three subagents unless the task has independent ownership boundaries.
</span></span></code></pre></div><p>This gives Claude enough policy to delegate without turning every prompt into a long orchestration script.</p>
<p>For teams already thinking about AI coding as a lifecycle rather than a chat tool, subagents fit naturally into review, verification, and documentation stages. They are less useful as a substitute for architecture ownership. A senior developer still needs to define the boundaries, name the risks, and decide which results are trustworthy.</p>
<h2 id="what-are-the-common-mistakes">What Are The Common Mistakes?</h2>
<p>The first mistake is creating too many agents. A dozen vague roles such as <code>backend-helper</code>, <code>frontend-helper</code>, and <code>cleanup-helper</code> make delegation less predictable. Start with three high-value roles and add more only when you see repeated work.</p>
<p>The second mistake is giving every subagent every tool. Tool access should reflect the job. A docs agent rarely needs <code>Bash</code>. A security reviewer may not need <code>Edit</code>. A test runner may need <code>Bash</code> but not <code>Write</code>.</p>
<p>The third mistake is parallelizing dependent work. If the API contract is not decided, do not spawn frontend, backend, and test implementers and hope they converge. Have subagents research options, then let the main agent create the contract.</p>
<p>The fourth mistake is ignoring cost. Subagents are cheaper than agent teams, but they still consume tokens. Running eight subagents that each scan the whole repository is rarely better than asking three precise subagents to inspect known areas.</p>
<p>The fifth mistake is using community subagents without adapting them. A good public prompt can still be wrong for your repository&rsquo;s deployment model, security posture, or test commands.</p>
<h2 id="what-is-my-recommended-claude-code-subagents-workflow">What Is My Recommended Claude Code Subagents Workflow?</h2>
<p>For most developers, the best 2026 workflow is:</p>
<ol>
<li>Create a small set of project subagents in <code>.claude/agents/</code>.</li>
<li>Keep descriptions specific enough for automatic delegation.</li>
<li>Restrict tools aggressively.</li>
<li>Use <code>sonnet</code> as the default implementation and review model.</li>
<li>Use <code>haiku</code> for low-risk summaries and extraction.</li>
<li>Use <code>opus</code> for high-risk architecture, security, or ambiguous debugging.</li>
<li>Add <code>isolation: worktree</code> before parallel edits.</li>
<li>Use agent teams only when workers need direct communication.</li>
</ol>
<p>Here is the prompt I use when I want useful parallel work without chaos:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-text" data-lang="text"><span style="display:flex;"><span>Use parallel subagents for research only. Spawn:
</span></span><span style="display:flex;"><span>- one subagent for API handlers
</span></span><span style="display:flex;"><span>- one subagent for database schema and migrations
</span></span><span style="display:flex;"><span>- one subagent for tests
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Each subagent should return affected files, risks, and recommended changes.
</span></span><span style="display:flex;"><span>Do not edit files.
</span></span><span style="display:flex;"><span>After all three return, synthesize one implementation plan with patch order and verification commands.
</span></span></code></pre></div><p>That shape keeps exploration parallel and implementation coherent. It is not flashy, but it works.</p>
<p>Claude Code subagents are at their best when they act like focused senior assistants: inspect a bounded area, apply a specific lens, and return a concise judgment. They are at their worst when treated like a swarm of unsupervised junior developers editing the same checkout. The technology is useful, but the boundary-setting is still your job.</p>
<h2 id="what-do-developers-usually-ask-about-claude-code-subagents">What Do Developers Usually Ask About Claude Code Subagents?</h2>
<h3 id="what-is-the-difference-between-claude-code-subagents-and-the-agent-tool">What is the difference between Claude Code subagents and the Agent tool?</h3>
<p>The Agent tool is the mechanism Claude uses to delegate work. A custom subagent is a named, reusable agent definition that controls the delegated worker&rsquo;s prompt, tools, model, permissions, and optional isolation behavior. In normal usage, you create subagent files and ask Claude to use them; Claude handles the Agent tool call internally.</p>
<h3 id="where-should-i-store-claude-code-subagents">Where should I store Claude Code subagents?</h3>
<p>Use <code>.claude/agents/</code> for project-specific agents that should be reviewed and shared with the repository. Use <code>~/.claude/agents/</code> for personal agents you want across projects. Managed settings and CLI-defined agents can override those scopes, and plugin agents have the lowest precedence.</p>
<h3 id="do-claude-code-subagents-share-the-main-conversation-context">Do Claude Code subagents share the main conversation context?</h3>
<p>Normal subagents start with a fresh context window and receive a task summary from the main agent. They do not automatically see your whole conversation history. Forked subagents are different: they inherit the parent conversation, but that reduces the isolation benefit and should be used when the worker needs substantial prior context.</p>
<h3 id="can-claude-code-subagents-run-in-parallel-safely">Can Claude Code subagents run in parallel safely?</h3>
<p>Yes, when the tasks are independent. Parallel research, review, and test runs work well. Parallel implementation is safe only when file ownership is clear or the subagents use <code>isolation: worktree</code>. If agents need to coordinate directly, use agent teams instead of plain subagents.</p>
<h3 id="should-i-use-community-claude-code-subagents">Should I use community Claude Code subagents?</h3>
<p>Yes, but review them first. Community subagents are useful templates, especially from curated catalogs, but they are still prompts with tool policies. Read the system prompt, narrow tools, remove assumptions that do not match your stack, and prefer checking project agents into version control.</p>
]]></content:encoded></item></channel></rss>