P635 min

Design Patterns

Master the core design patterns that power production AI agents — from ReAct loops to multi-agent orchestration architectures.

SDK Focushooks.PreToolUse/PostToolUsehooks.StopTaskCreate / TaskUpdatesettingSourcespermissionMode: plan

Shipping Your First Pattern

Before any theory, run one pattern end-to-end. Five minutes from clone to first output — it's what makes every concept below land in muscle memory.

bash
cd content/learn/v1/starters/agent-loop
npm install && cp .env.example .env
# add your ANTHROPIC_API_KEY to .env
npm run dev -- "List the three largest TypeScript files under src/ and explain why they're large."

You'll see assistant messages, tool_use_summary actions, then a final result. That alternation — reason → act → observe → adapt — is the ReAct pattern, the simplest of the five we'll cover and the default for most real workflows.

Every other pattern is a deviation from ReAct

Reflection adds a critique loop. Plan-Execute adds a planning stage. Multi-Agent splits the thinker into specialists. Task Systems persist the plan to disk. As you read each pattern below, ask: what does this add to ReAct, and what does that addition cost? That's the design lens agent engineers actually use.

Pattern Decision Tree

text
Single answer fits in one tool call?            ──YES──→  ReAct (default)
            │
           NO
            │
Need a plan reviewed before any writes?         ──YES──→  Plan-Execute
            │
           NO
            │
Output quality improves with self-review?       ──YES──→  Reflection
            │
           NO
            │
Multiple specialists with different tool sets?  ──YES──→  Multi-Agent
            │
           NO
            │
Long-running work, must survive compaction?     ──YES──→  Task Systems

Pick by where you want extra control or specialization, not by what's most impressive on a slide. The pattern comparison table below is the same decision in tabular form, with SDK primitives mapped to each branch.

Premium lesson preview

Continue with full access

This lesson stays here for preview. Full access unlocks the complete lesson, flashcards, and related practice.

Sign In to Unlock

One purchase unlocks advanced lessons, practice, and future updates.