All skills
Skillintermediate

šŸ” Layer 2: Main Agent Layer

<div align="center">

Claude Code Knowledge Pack7/10/2026

Overview

<div align="center">

šŸ  Home › šŸ”§ Implementation › šŸ›ļø Architecture › šŸ” Layer 2: Main Agent

← šŸ™‹ā€ā™€ļø User Layer ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā—ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā” šŸ”€ Delegation Layer →

</div>

šŸ” Layer 2: Main Agent Layer

Central orchestrator that interprets intent and coordinates execution.


Purpose

The Main Agent Layer is the brain of the system. It receives normalized input from the User Layer, determines the appropriate execution strategy, and coordinates all downstream work.


Responsibilities

ResponsibilityDescription
Intent RecognitionUnderstand what user wants
Pattern SelectionChoose appropriate execution pattern
Task DelegationSpawn 🐦 subagents or use šŸ”§šŸ”ŒšŸ’ā€ā™€ļø tools
Result SynthesisCombine results into coherent response

Critical Rule

The šŸ” Main Agent is the ONLY entity that can spawn 🐦 Subagents.

🐦 Subagents cannot spawn other subagents. All delegation flows through the šŸ” Main Agent.


Diagram

%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
flowchart TB
    classDef main fill:#8b5cf6,stroke:#7c3aed,stroke-width:2px,color:#ffffff
    classDef user fill:#6366f1,stroke:#4f46e5,stroke-width:2px,color:#ffffff
    classDef tool fill:#f59e0b,stroke:#d97706,stroke-width:2px,color:#ffffff

    subgraph MainAgentLayer["šŸ” Main Agent Layer"]
        direction TB
        INTENT[Intent Recognition]
        PATTERN[Pattern Selection]
        DELEGATE[Task Delegation]
        SYNTH[Result Synthesis]

        INTENT --> PATTERN
        PATTERN --> DELEGATE
        DELEGATE --> SYNTH
    end

    INPUT["šŸ™‹ā€ā™€ļøšŸ“„ User Input"]:::user --> INTENT
    SYNTH --> OUTPUT["šŸ’ā€ā™€ļøšŸ“¤ User Response"]:::user
    DELEGATE --> EXEC["⚔ Execution Layer"]:::tool
    EXEC --> SYNTH

    classDef mainBox fill:#f3e8ff,stroke:#8b5cf6,stroke-width:2px,color:#5b21b6

    MainAgentLayer:::mainBox

Decision Points

%%{init: {'theme': 'base', 'themeVariables': {'lineColor': '#64748b'}}}%%
flowchart TD
    classDef start fill:#10b981,stroke:#059669,stroke-width:2px,color:#ffffff
    classDef wizard fill:#14b8a6,stroke:#0d9488,stroke-width:2px,color:#ffffff
    classDef parallel fill:#3b82f6,stroke:#2563eb,stroke-width:2px,color:#ffffff

    START["šŸ™‹ā€ā™€ļøšŸ“„ User Request"]:::start --> Q1{Complex task?}
    Q1 -->|Yes| Q2{Independent subtasks?}
    Q1 -->|No| DIRECT[Direct Execution]

    Q2 -->|Yes| PARALLEL["šŸš‚ Parallel Subagents"]:::parallel
    Q2 -->|No| Q3{Requires confirmation?}

    Q3 -->|Yes| WIZARD["šŸ§™ Wizard Workflow"]:::wizard
    Q3 -->|No| SEQUENTIAL[Sequential Execution]

Processing Pipeline

1. Intent Recognition

Input: "Fix the login bug and add tests"
 │
 ā”œā”€ā–ŗ Bug fix task identified
 └─► Test addition task identified

2. Pattern Selection

ScenarioPattern Selected
Single simple taskDirect Execution
Independent tasksšŸš‚ Parallel Subagents
Dependent tasksSequential Chain
High-risk changesšŸ§™ Wizard Confirmation

3. Task Delegation

# Simple task
šŸ” Main Agent → šŸ”§ Built-in Tools

# Complex task
šŸ” Main Agent → 🪺 Task(subagent_type="code-reviewer")

# Parallel tasks
šŸ” Main Agent → [🪺 Task(...), 🪺 Task(...), 🪺 Task(...)]

4. Result Synthesis

🐦 Subagent 1 → Result 1 ─┐
🐦 Subagent 2 → Result 2 ─┼─► šŸ” Merge → šŸ’ā€ā™€ļøšŸ“¤ Final Response
🐦 Subagent 3 → Result 3 ā”€ā”˜

Layer Position

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  šŸ™‹ā€ā™€ļø LAYER 1: USER LAYER                           │
│  Human input, 🦓 /commands, natural language        │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                          │
                          ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  šŸ” LAYER 2: MAIN AGENT LAYER  ◄─── YOU ARE HERE   │
│  Claude Code - orchestration, decision-making       │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜
                          │
                          ā–¼
ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
│  šŸ”€ LAYER 3: DELEGATION LAYER                       │
│  🦓 Slash Commands, šŸ“š Skills - workflow definition │
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

<div align="center">

← šŸ™‹ā€ā™€ļø User Layer ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā—ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā”ā” šŸ”€ Delegation Layer →

</div>