⛓️Prompt Chaining
⚡Parallelization
🔀Routing
🎯Orchestrator
🔄Evaluator
Exercise 1

Prompt Chaining — Sequential Pipeline

Objective: build a pipeline where each step uses the result of the previous one. This is the simplest pattern — and the one most often confused with Orchestrator.

1

Ask Claude to build a 3-step processing pipeline with each step clearly shown:

💬 Type in Claude Code
Apply a 3-step prompt chaining pipeline to this text, clearly showing each step and its output: Text: "Our mobile app launched 6 months ago. Feedback is mixed: users appreciate the speed but complain about sync bugs and an unintuitive interface. We have 12,000 active users but a 30-day retention rate of only 23%." Step 1: Extract the 3 main problems Step 2: For each problem, identify a precise technical solution Step 3: Prioritize solutions by impact/effort and create a 2-week plan
✅ Expected result 3 distinct outputs, each built on the previous. Step 2 references the problems from Step 1. Step 3 references the solutions from Step 2.
💡 When to choose Prompt Chaining

When tasks are sequential and dependent. The output of N is the input of N+1. Typical case: extract → transform → format. Not to be confused with Orchestrator (which delegates to sub-agents) or Parallelization (no dependency).

Exercise 2

Parallelization — Fan-out and Fork

Objective: observe the parallelization pattern, understand fork vs fresh agent, and know when it is appropriate.

1

Request a parallel analysis across several independent dimensions:

💬 Type in Claude Code
Analyze the file /tmp/cert-training/src/app.py across 3 dimensions in parallel (launch them simultaneously): 1. Security: are there any risks? 2. Performance: is it optimal? 3. Maintainability: does it follow Python best practices? For each dimension, give a score /10 and 2 concrete recommendations.
✅ Expected result Claude launches 3 independent analyses. Results can arrive in any order. This is the fan-out pattern: 1 input → N parallel processes → N outputs.
2

Now ask it to explain fork vs fresh agent:

💬 Type in Claude Code
Explain the difference between a fork (subagent_type: "fork") and a fresh agent in the parallelization pattern. When to use one vs the other? Mention the impact on context and cache.
✅ Expected points Fork inherits full context (warm cache, fewer tokens). Fresh agent = zero context (total isolation, prompt must be self-contained). Fork for open-ended questions on what you're already exploring. Fresh for isolation.
💡 When to choose Parallelization

When tasks are independent (no dependency between them) and you want to reduce latency. Same input, N processes, N outputs. Note: don't parallelize if one task depends on the result of another.

⚠️ Exam Trap

"Fork and fresh agent are interchangeable in Parallelization" → FALSE. Fork inherits context + shares the prompt cache (cheaper). Fresh agent starts from scratch — requires a self-contained prompt, cannot see the history.

Exercise 3

Routing — Conditional Dispatcher

Objective: understand the routing pattern: an LLM analyzes the input and routes it to the appropriate specialized sub-agent.

1

Build a simple router:

💬 Type in Claude Code
Build a 2-step routing system for these 3 user requests: - "I have a TypeError: 'NoneType' in line 42" - "How can I improve the performance of my SQL query?" - "Explain the Observer pattern in Python" Step 1 (Router): Classify each request into a category (bug/optimization/education) with justification. Step 2 (Specialist): For each category, simulate a response from the corresponding specialized sub-agent with an adapted style.
✅ Expected result Router classifies → dispatches to 3 different specialists (debugger, optimizer, teacher). Each response has a different tone/style according to the specialist.
💡 When to choose Routing

When inputs are very different in nature and require specialized processing. The router is a lightweight LLM (Haiku) that classifies quickly, then delegates to the right expert (Sonnet/Opus). Reduces costs vs sending everything to a powerful model.

Exercise 4

Orchestrator-Subagents — Hierarchical Delegation

Objective: build an orchestrator that decomposes a complex task, delegates to sub-agents, then synthesizes. This is the most powerful pattern — and the most complex.

1

Ask Claude to play the role of an orchestrator:

💬 Type in Claude Code
Play the role of an orchestrator for this complex task: "Audit the /tmp/cert-training/ project and produce a quality report" 1. First, break this task into 4 independent sub-tasks you would delegate to 4 specialized sub-agents 2. For each sub-agent, specify: its name, its exact prompt, and the information it needs 3. Execute the 4 sub-tasks and synthesize the results into a final structured report
✅ Expected result Orchestrator decomposes → 4 agents work → final synthesis. Each sub-agent has a precise, self-contained prompt. The orchestrator does not know in advance which sub-tasks will be created (that's what distinguishes it from chaining).
💡 Orchestrator vs Prompt Chaining

Chaining = predefined sequential steps. Orchestrator = dynamic decomposition, the orchestrator decides the sub-tasks at runtime based on task analysis. The orchestrator can also parallelize some sub-agents.

Exercise 5

Evaluator-Optimizer — Feedback Loop

Objective: build a loop where one agent evaluates another's work and triggers improvement iterations until a quality criterion is met.

1

Build an evaluator-optimizer loop:

💬 Type in Claude Code
Build an evaluator-optimizer loop to improve this marketing message: Initial message: "Our software is very good and fast. Buy it now!" Evaluation criteria (score /10 each): - Clarity of value proposition - Social proof or concrete figure - Precise call-to-action Iterate until reaching an average score ≥ 8/10 (max 3 iterations). Clearly show each cycle: Draft → Evaluation → Feedback → Improved Draft.
✅ Expected result Visible cycle: Generator produces → Evaluator scores and critiques → Generator improves → loop stops when criterion met or max iterations reached. The loop has a clear exit condition.
2

Ask for an explanation of the pattern:

💬 Type in Claude Code
In the Evaluator-Optimizer pattern, what are the 2 possible exit conditions from the loop? And why is it critical to have one?
✅ Expected answer Exit 1: quality criterion met. Exit 2: max iterations reached. Without an exit condition → infinite loop. The evaluator must return a structured signal (pass/fail + feedback).
💡 When to choose Evaluator-Optimizer

When output quality is hard to guarantee in a single pass. Typical cases: code generation (tests as evaluator), writing (rubric as evaluator), translation (back-translation). The cost is higher — multiple iterations.

⚠️ Exam Trap

"The evaluator and the generator must be the same model" → FALSE. The evaluator can be lighter (Haiku) if criteria are simple, or more powerful (Opus) if evaluation is complex. It can also be a deterministic tool (test suite, linter).