Raising Claude Code - Part 5: Subagent implementation

Part 4 (Extension) covered when to use Skills vs Subagents — the conceptual side. Subagents are easy to grasp at the concept level. Where most people stall is “how do I actually implement one?

That’s what this post is about.

But before getting into it, I want to be clear about my position.

I’m against treating multiple agents as “peers”

There’s a recurring pattern in the AI space lately:

I’ve written about this elsewhere (“It’s too early to ‘organize’ AI agents”), and I’m against this pattern.

Reasons:

But hierarchical Subagents are fine

Equal-peer consensus: no. Main agent calling Subagents in a hierarchical structure: different story.

In this shape:

In other words: don’t make them peers. don’t let them chat. final call stays with the human. This is the same idea as Part 4 (Extension).

When to reach for a Subagent (recap)

Good fit:

Avoid when:

Step 1: create the directory

project-root/
  .claude/
    agents/
      code-reviewer.md
      security-reviewer.md
      research-explorer.md

One file = one Subagent under .claude/agents/. Match the filename (without extension) to the name field in frontmatter when you can — it isn’t strictly required, but if you don’t, you lose track of which file is which Subagent.

Step 2: write the Subagent file

.claude/agents/code-reviewer.md:

---
name: code-reviewer
description: Conducts code reviews focused on separation of concerns,
  KISS / SOLID, security, error handling, and testability.
  Invoked when the main agent "delegates a review."
  Final adoption decision is made by main agent + human.
tools: Read, Grep, Glob, Bash
model: sonnet
---

# Code Reviewer

You are a dedicated code-review agent.
Review the code/diff handed to you by the main agent and return
a list of findings.

## Review perspectives

- Separation of concerns (no bloated single-file/single-function responsibilities)
- KISS / SOLID (over-abstraction, complex inheritance)
- Security (input validation, authorization, leaked secrets)
- Error handling (swallowed exceptions, re-raise, error types)
- Testability (DI, isolation of side effects)

## Output format

| ID | Severity (high/medium/low) | Category | Problem | Required Action | Verification |

## Constraints

- Don't make adopt/reject decisions (just hand findings back to main)
- Don't edit files (read and report only)
- Don't invoke other Subagents on your own

Key points:

Step 3: invoke from the main agent

The main agent calls Subagents through the Agent tool (formerly Task, renamed in v2.1.63).

Auto-invocation (triggered by description match):

User: review src/auth/login.ts
Main: launch code-reviewer Subagent → get findings list →
  present to user → ask "adopt these?"

Explicit invocation:

User: have code-reviewer look at src/auth/login.ts

Note: invocation is the main agent’s call. Don’t let a Subagent invoke another Subagent (don’t break the hierarchy).

Step 4: codify the hierarchy in CLAUDE.md

Write this in the main agent’s CLAUDE.md:

# Subagent usage rules

- Subagents are invoked one-way from the main agent
- Subagents must not talk to each other directly
- Whether to adopt a Subagent's output is decided by the main agent + user
- Don't have Subagents make final decisions or do heavy operations like prod deploys

This is the Part 3 (Persuasion) layer applied to Subagents. Codify “don’t make them peers” as an explicit rule.

Without this, Claude has learned the “organized multiple agents” pattern from training data and may try to coordinate Subagents on its own.

Step 5: smoke test (replay test)

  1. Place the Subagent file
  2. Send a simple task from the main
  3. Confirm the Subagent gets invoked as expected
  4. Confirm it still gets invoked in a fresh session (same idea as the replay test in Part 6)

Common reasons it doesn’t get invoked:

Subagents that pay off when you build them first

Subagents to avoid building:

Anti-patterns

The ones that bite hardest in practice:

Wrap-up

Treating multiple agents as peers: no. But hierarchical Subagents: yes.

Implementation keys:

Operate Subagents under these constraints and you keep the main context clean while avoiding the accuracy loss that comes from consensus.

This is the implementation side of “make the chain of command explicit” — the throughline of the whole series.

Next is Part 6, the final post — Operations: the improvement loop and anti-patterns for keeping the whole setup healthy over time.