USMAN’S INSIGHTS
AI ARCHITECT
  • Home
  • About
  • Thought Leadership
  • Book
Press / Contact
USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeBook
HomeBookEradicate Context Confusion with Specialists
Previous Chapter
Agent Skills Exercises
Next Chapter
MCP Integration
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

20 sections

Progress0%
1 / 20

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a leading Agentic AI Architect and Software Engineer specializing in the design and deployment of multi-agent autonomous systems. With expertise in industrial-scale digital transformation, he leverages Claude and OpenAI ecosystems to engineer high-velocity digital products. His work is centered on achieving 30x industrial growth through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. Based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Book
  • About
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

Subagents and Orchestration

A subagent is a specialized AI Agent with its own instructions and isolated context window. Each subagent is an expert at one type of task.

Think of Claude Code as a project manager with a team of specialists:

  • Claude Code (main): Coordinates overall work
  • Plan subagent: Researches your codebase and creates multi-step plans
  • Custom subagents: You can create specialists for your team's specific needs (content planning, research synthesis, document structuring, etc.)
Three-tier hierarchy tree showing Claude Code (orchestrator) at top, Subagents (specialized agents) in middle tier, and Skills (reusable capabilities) at bottom, with delegation arrows and example instances
Three-tier hierarchy tree showing Claude Code (orchestrator) at top, Subagents (specialized agents) in middle tier, and Skills (reusable capabilities) at bottom, with delegation arrows and example instances

You already have a team of AI specialists. Let's meet them.


You Already Have a Team

Run this command in Claude Code right now:

Specification
/agents

What you'll see:

text
│ Agents │ │ ❯ Create new agent │ │ │ │ Built-in agents (always available) │ │ Bash · inherit │ │ general-purpose · sonnet │ │ statusline-setup · sonnet │ │ Explore · haiku │ │ Plan · inherit │ │ claude-code-guide · haiku │

These are subagents—specialized AI assistants that Claude Code can delegate work to. Each has its own expertise and isolated context window.

You don't need to create anything yet. You already have a team ready to work.


Try It Now: Your First Subagent

Let's use the Explore subagent to see what's in your current folder.

Type this in Claude Code:

Specification
Use the Explore subagent to tell me what's in this folder and summarize the project structure.

What happens:

  1. Claude Code delegates to the Explore subagent
  2. Explore scans your directory with its own clean context
  3. Explore returns a summary to main Claude Code
  4. You see the results

Try it! This is hands-on learning—run it now and see what Explore finds.


Meet the Built-In Agents

AgentBest ForModel
ExploreFinding files, searching code, understanding codebase structureHaiku (fast)
PlanComplex multi-step tasks, creating implementation strategiesSonnet (smart)
general-purposeMulti-step tasks requiring various toolsSonnet
BashCommand execution tasksInherits current
claude-code-guideQuestions about Claude Code itselfHaiku

Key insight: Claude Code automatically picks the right specialist based on your request. But you can also explicitly invoke any agent.


How Subagents Work?

Critical concept: A subagent is invoked once for a specific goal, completes its work, and returns results to main Claude Code.

The flow:

  1. Main Claude Code recognizes a task that needs a specialist
  2. Launches the subagent with a specific goal
  3. Subagent works independently in isolated context
  4. Subagent completes its task and returns results
  5. Control returns to main Claude Code
  6. You interact with main Claude Code to proceed

Think of it like this: You send a specialist to research something. They go off, do their work, come back with a report, and then you continue the conversation with your main assistant.

Automatic Delegation

You don't command "use the Plan subagent." Claude Code decides when to delegate based on:

  • Task complexity (multi-step tasks trigger Plan)
  • Your request type (code review request might trigger a review subagent if you have one)
  • Subagent descriptions (Claude matches task to specialist)

Parallel Power: Multiple Agents at Once

Here's where it gets powerful. You can invoke multiple subagents in a single prompt.

Try this:

Specification
Use Explore to show me what files are in this project, AND use Plan to outline how I could add a README if one doesn't exist.

What happens:

  • Claude Code launches both subagents
  • They work in parallel with isolated contexts
  • Results combine into a single response

Real-world example:

Specification
Use Explore to find all test files in this project, AND use Plan to suggest a testing strategy for the gaps you find.

This is orchestration—coordinating multiple specialists toward a goal.


Why Subagents Work: Clean Context

Each subagent has its own isolated context window. Why does this matter?

Without subagents (one AI doing everything):

  1. You ask Claude to research competitors
  2. Context fills with research notes
  3. You ask Claude to draft a pitch
  4. Context is cluttered—Claude might confuse research notes with your pitch

With subagents:

  1. Research subagent does research, returns clean summary
  2. Main Claude receives summary, context stays clean
  3. Planning subagent drafts pitch with fresh context
  4. Each specialist focuses on one job

Think of it like a team meeting: The researcher presents findings, then leaves. The strategist creates a plan with fresh focus. Nobody is juggling everything at once.

💬 AI Colearning Prompt

"Explain why subagents use isolated context windows instead of sharing the main conversation. What problems does context isolation solve?"


The Execution Model

How subagents work:

Specification
You → Main Claude Code → Launches Subagent → Subagent works → Returns results → Main Claude Code → You

Key concepts:

  1. One task, one completion: Subagent is invoked for a specific goal, completes it, returns
  2. Control returns: After the subagent finishes, you interact with main Claude Code again
  3. Automatic or explicit: Claude Code can auto-delegate, or you can request a specific agent

Automatic triggers:

  • Ask "What files handle authentication?" → Explore auto-activates
  • Ask "Help me add user login to this app" → Plan auto-activates (complex task)

Explicit invocation:

Specification
Use the Plan subagent to analyze this feature request.

Hands-On: Create Your First Custom Subagent

Now that you've used built-in agents, let's create your own specialist.

Step 1: Open the Agent Menu

Specification
/agents

Select "Create new agent"

Step 2: Choose Location

text
│ Choose location │ │ ❯ 1. Project (.claude/agents/) │ │ 2. Personal (~/.claude/agents/) │

Choose 1 (Project)—makes the agent available in this project only.

Step 3: Choose Creation Method

text
│ Creation method │ │ ❯ 1. Generate with Claude (recommended) │ │ 2. Manual configuration │

Choose 1—let Claude generate the agent from your description.

Step 4: Describe Your Agent

Type something like:

Specification
Help me review code for bugs and suggest improvements.Use when I say "review this code" or "check for bugs."

Claude Code creates:

  • Agent name (e.g., code-reviewer)
  • Instructions based on your description
  • Tool permissions
  • Saves to .claude/agents/code-reviewer.md

Step 5: Test It

Specification
Use the code-reviewer subagent to review this function: [paste your code]

You just created a reusable specialist.


Where Subagents Live

Project-level: .claude/agents/ (this project only) User-level: ~/.claude/agents/ (all your projects)

Example file (.claude/agents/code-reviewer.md):

yaml
--- name: code-reviewer description: Reviews code for bugs and suggests improvements model: sonnet --- # Code Review Instructions When reviewing code: 1. Check for bugs and edge cases 2. Suggest performance improvements 3. Note any security concerns 4. Recommend cleaner patterns

More Subagent Ideas

Once you understand the pattern, create specialists for any repeated task:

  • Research subagent: Deep-dive into documentation, gather requirements
  • Testing subagent: Generate test cases, identify edge cases
  • Documentation subagent: Write README files, API docs, architecture notes
  • Refactor subagent: Suggest cleaner code patterns, reduce complexity

The pattern:

  1. What expertise does this specialist have?
  2. What should it do autonomously?
  3. What format should results be in?

Skills vs. Subagents: Decision Criteria

Now that you understand both skills (Lesson 08) and subagents, when do you choose one over the other?

FactorChoose SkillChoose Subagent
InvocationAutomatic OR explicit by nameExplicit only (you invoke)
ContextShared with main conversationIsolated context window
ComplexityLightweight, single-focusMulti-step, complex workflows
GuaranteeFlexible (auto-triggers or invoke by name)Hard invocation (always runs)
Best forRepeated patterns, formatting, proceduresAudits, refactoring, comprehensive analysis

Use skill when: "I want Claude to automatically do this whenever it's relevant."

Use subagent when: "I need guaranteed execution with isolated context for this complex task."

Examples

Skill appropriate:

  • Meeting notes formatting (happens often, simple procedure)
  • Blog post planning (repeated task, consistent structure)
  • Code comment style (automatic enforcement)

Subagent appropriate:

  • Comprehensive security audit (complex, needs isolation)
  • Multi-file refactoring (guaranteed execution required)
  • Full codebase analysis (too large for skill context)