# "I was using sub-agents wrong"
<!--
ref: @content/youtube/ai-jason/2025-08-14-i-was-using-sub-agents-wrong
triggers: [sub-agents causing confusion, context loss during implementation, ineffective debugging, fragmented workflows]
trigger_prompt: When users struggle with debugging or find their AI coding workflows inefficient due to misapplied sub-agents, this protocol provides clarity on their correct usage.
version: 4
updated_at: 2026-10-31T20:06:41.254Z
-->

From AI Jason, 2025-08-14: Sub-agents exist for **context optimization, not labor division**. The common pattern of splitting implementation across specialist sub-agents (frontend dev, backend dev) fragments context and cripples debugging.

AI Jason, a builder and educator focused on practical AI coding workflows, walks through a corrected mental model for Claude Code sub-agents after realizing most users (himself included) were misapplying them.

## Core Thesis
Sub-agents exist for **context optimization, not labor division**. The common pattern of splitting implementation across specialist sub-agents (frontend dev, backend dev) fragments context and cripples debugging. Instead, treat sub-agents as **scoped researchers and planners** that produce markdown design docs, while the parent agent — holding full context — does all execution.

## Key Insights
- The `task` tool saves tokens because only a sub-agent's final summary enters the parent's history; intermediate reads/searches stay hidden. This is the entire point of sub-agents.
- Implementation sub-agents fail on bug fixes: sessions are isolated, the parent can't see their intermediate work, and nobody holds enough context to debug.
- Build **one expert sub-agent per major service/dependency** (Vercel AI SDK, Shadcn, Stripe, Supabase, Tailwind), each loaded with that service's latest docs in its system prompt and scoped MCP tools.
- Borrow Manus's "file system as ultimate context management" pattern: offload bulky tool output to local MD files instead of stuffing it into history.
- A shared `context_session.md` acts as persistent memory — parent creates it, every sub-agent reads it before starting and updates it after finishing.
- Sub-agents inherit `CLAUDE.md`, which can cause recursive self-calls into their own MCP — must be explicitly forbidden in their rules.
- Sub-agent config can be project-scoped (`.claude/`) or global (`~/.claude/`); global agents apply everywhere.
- Claude Code's background sessions let long sub-agent runs be monitored without blocking the parent.

## Actionable Takeaways
1. **Use sub-agents only for research and planning** — they output design docs to `doc/task/*.md`, never code.
2. **Let the parent agent execute all implementation** so it retains the full context needed for iterative fixes and debugging.
3. **Create one specialist sub-agent per dependency**, each with (a) latest official docs pasted into the system prompt, (b) relevant MCPs (Shadcn component MCP, TweakCN, Context7), (c) strict rules forbidding implementation.
4. **Maintain a single `context_session.md` per feature** — mandated via `CLAUDE.md` rules so every agent reads first, updates last.
5. **Standardize sub-agent prompt structure**: Goal → Process rules → Output format (save to MD + return pointer) → Context rules.
6. **In parent `CLAUDE.md`**, enforce: maintain the context file, delegate to named sub-agents, pass the context filename on every delegation, require read-before-execute.

## Notable Quotes
> "The whole purpose of sub agent has been around context engineer and context optimization but where things fail is when people start trying to get a sub agent not only doing the research work but also directly doing the implementation."

> "Consider each sub agent almost as a researcher and think about what kind of planning and research steps can actually dramatically improve your current AI coding workflow."

> "The goal is to design propose a detailed implementation plan and never do the actual implementation."

> "All the execution will be done by this parent agent. So it will have full context."

> "They use file system as ultimate context management system."

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*