---
title: "VB-04: Subagents from Basics to Deep Dive – I Got It All Wrong!"
url: "https://zuey.me/articles/vb-04-subagents-tu-basic-den-deep-dive-toi-da-hieu-sai?lang=en"
locale: en
access: members
full_text: false
published_at: "2025-07-30T14:55:50.000Z"
tags: ["Claude Code", "Vibe Coding", "AI", "SaaS", "Startup"]
translations:
  vi: "https://zuey.me/articles/vb-04-subagents-tu-basic-den-deep-dive-toi-da-hieu-sai.md?lang=vi"
  zh: "https://zuey.me/articles/vb-04-subagents-tu-basic-den-deep-dive-toi-da-hieu-sai.md?lang=zh"
  ko: "https://zuey.me/articles/vb-04-subagents-tu-basic-den-deep-dive-toi-da-hieu-sai.md?lang=ko"
  ja: "https://zuey.me/articles/vb-04-subagents-tu-basic-den-deep-dive-toi-da-hieu-sai.md?lang=ja"
---
# VB-04: Subagents from Basics to Deep Dive – I Got It All Wrong!

> I thought I understood Claude Code Subagents. Turns out I had it all wrong 😅 A deep dive into Context Management, Context Rot, and how I rebuilt my subagent team into a “Context Collector Army” to finally crack a test suite I'd been stuck on for 3 days.

> **INFO:** Part 04 of the series **Vibe-coding with Claude Code** (VB).

This 4th post was supposed to be about Claude Code “Commands”, but I discovered quite a few mistakes I'd been making with Subagents, so I decided to push the Commands post to part 05 😅

**What's in this post?**

- An overview of Claude Code Subagents
- The benefits subagents can bring
- A few pretty useful repos
- Time to Deep-Dive!
- The research I read and how I applied it
- Rebuilding my subagent team and the results
- As always: a few “dumb-but-it-works tricks” scattered throughout 😂

> **INFO:** **A quick heart-to-heart:** Claude Code and the Sub-agents concept only launched 1-2 months ago, so it's still brand new for everyone. Like many others, I'm just trying things out and writing down interesting findings. I've never claimed that everything I share is 100% RIGHT. (Who knows, in a few days I might find yet another way to optimize this bunch of Subagents! 🫣)

![Claude Code Subagents: from Basics to Deep Dive](https://media.zuey.me/blog/2025/132e5fbf-claude-subagents-deep-dive.png)

---

### Claude Code Subagents overview

#### How to create a Subagent

Use CC's `/agents` command for the fastest setup, then open the MD file and customize it however you like.

```text
# Open the sub agents interface
/agents

# Select "Create New Agent"
# Choose project-level or user-level
```

#### Understanding “delegation”

By default, Claude Code itself is the Main Agent and executes everything. Once we create subagents, CC will automatically summon the relevant agent and delegate tasks when needed “intelligently” – according to Claude's docs (so intelligent that you rarely see it summon a subagent at all; the main agent just handles everything itself, like: *“pfft, that's easy, I got this!”* 😂)

So, to summon subagents more effectively, we have 2 options:

**1/ Automatic (smarter than that default “intelligence”):**

Add the following instructions to `CLAUDE.md` to remind CC that it has an army under its command:

```text
...
During the implementation process, you will delegate tasks to the following subagents based on their expertise and capabilities

- Use `planner-researcher` agent to plan for the implementation plan.
- Use `database-admin` agent to run tests and analyze the summary report.
- Use `tester` agent to run tests and analyze the summary report.
- Use `debugger` agent to collect logs in server or github actions to analyze the summary report.
- Use `code-reviewer` agent to review code.
- Use `docs-manager` agent to update docs in `./docs` directory if any.
...
```

**2/ The old-fashioned way (Manual):** put it straight into your prompt or use a Command (user prompt).

Next, you should know there are 2 ways to summon subagents: **“Sequential” (Chaining)** and **“Parallel”**.

**Chaining Sub-Agents**

```text
# Complex workflow example
> First use the code-analyzer subagent to find performance issues, 
> then use the optimizer subagent to fix them
```

**Parallel Execution**

```text
# Competing approaches
> Deploy 2 subagents in parallel:
> Subagent 1 - Incremental Modernizer: Design gradual migration strategy
> Subagent 2 - Complete Rewrite Advocate: Propose full stack modernization
```

> **WARN:** Spawning many subagents at once and letting them work in parallel can easily cause conflicts, so only use it depending on your workflow and the nature of each agent. Ideally, configure it in a command so you can trigger the right kind of workflow when needed.

Note that each sub-agent has:

#### Its own context window

Not affected by the main conversation

#### A custom system prompt

“Trained” for a specific role

#### Its own tool access

Only allowed to use the tools it needs

#### Deep expertise

100% focused on its domain expertise

#### Benefits subagents can bring

| Benefit | What it means |
| --- | --- |
| **Context Preservation** | Instead of re-explaining everything from scratch every time you switch tasks, each sub-agent keeps its own context. The main conversation stays clean and focused. |
| **Specialized Expertise** | A sub-agent fine-tuned for security will always beat a general AI at reviewing code for security. The success rate is significantly higher. |
| **Reusability & Team Sharing** | Create once, use forever. Share it with your team for a consistent workflow. |
| **Parallel Processing** | Instead of working sequentially: analyze → code → test → review, you can run multiple sub-agents in parallel. |

> **TIP:** **Pro tip:** Join the “r/ClaudeAI” and “r/ClaudeCode” subreddits to share and learn about sub-agents from the community. That's where experts are experimenting and sharing interesting approaches.

---

### A few pretty useful repos

**A list of subagents for reference** (use their descriptions and workflows as inspiration to customize your own agents – don't just copy them verbatim):

[wshobson/agents](https://github.com/wshobson/agents)

> github.com

**Claude Sub-Agent Spec Workflow System:** this one has plenty of nice workflows too; I borrowed ideas from it to build my own subagents.

[zhsama/claude-sub-agent](https://github.com/zhsama/claude-sub-agent/blob/main/README.md)

> github.com

---

### Time to Deep-Dive!

Has anyone else been in the same spot as me: you've got a “godlike” team of AI agents that can do everything, but when you actually use them... sometimes it works, sometimes it doesn't?

Sometimes it works so brilliantly that it burns tokens at a million miles an hour, but other times the results aren't what you expected, or it gets stuck in an endless reincarnation cycle of fixing bugs that never go away?

I was in exactly that situation the past few days. Subagents didn't feel very effective; they just burned tokens and time... and I was still stuck solving a Test Suite for almost 3 days.

So I decided to dig deeper, and here's what I learned...

---

### Context Management is the key!

---

*Phần còn lại dành cho thành viên có quyền đọc toàn bài (Knowledges, Kết hợp, Cộng đồng) — see plans at https://zuey.me/pricing*
