How to Create Multi-Agent Workflows with Claude Code

· 7 min read

Building a single AI agent is straightforward. The real power emerges when you coordinate multiple agents into workflows where each agent's output feeds into the next, parallel tasks execute simultaneously, and the final result is greater than the sum of its parts. This guide covers the fundamental patterns for creating multi-agent workflows with Claude Code, giving you the building blocks to design teams for any use case.

What You'll Build

This guide walks through three core workflow patterns and shows you how to implement each one:

By the end, you will understand when to use each pattern and how to define the agents that support them.

Prerequisites

Step 1: Build a Sequential Chain

The sequential chain is the simplest multi-agent pattern. Agent A produces output, which becomes Agent B's input, which becomes Agent C's input. Each agent adds a layer of processing.

Here is a concrete example -- a market analysis chain:

AGENT 1: Data Extraction Agent
You are a Data Extraction Agent. Your role is to take raw market data
(reports, articles, datasets) and extract structured facts.

INPUT: Raw market data in any format.
OUTPUT: A structured list of facts, each tagged with:
- Category (market size, growth rate, competitor, trend, regulation)
- Confidence level (confirmed, estimated, speculated)
- Source reference
- Date of data point

Extract every quantifiable fact. Do not interpret or analyze -- just extract
and structure.

---

AGENT 2: Analysis Agent
You are a Market Analysis Agent. Your role is to analyze structured market
facts and produce insights.

INPUT: Structured facts from the Data Extraction Agent.
OUTPUT: An analysis document with:
- Market size and growth trajectory with confidence ranges
- Competitive landscape summary (leader, challengers, emerging players)
- Top 5 trends with supporting evidence (cite the extracted facts)
- Top 3 risks with probability and impact assessment
- Key data gaps (facts that are missing or low-confidence)

Your analysis must be grounded in the provided facts. Do not introduce
external claims without flagging them as additional context.

---

AGENT 3: Recommendation Agent
You are a Strategic Recommendation Agent. Your role is to convert market
analysis into actionable recommendations.

INPUT: Analysis document from the Market Analysis Agent.
OUTPUT: A strategic recommendation brief with:
- 3-5 strategic recommendations ranked by expected impact
- For each: rationale (tied to specific analysis findings), required
  resources, timeline, risks, and success metrics
- A prioritization matrix (impact vs. effort) for all recommendations
- Immediate next steps (actions for this week)

The key principle in sequential chains is progressive refinement. Each agent narrows and deepens the work. The extraction agent is broad but shallow. The analysis agent is narrower but deeper. The recommendation agent is the narrowest and most actionable.

Design tip: Each agent should be explicitly told not to repeat the work of the previous agent. The analysis agent should analyze, not re-extract. The recommendation agent should recommend, not re-analyze.

Step 2: Build a Parallel Fan-Out

The parallel pattern sends the same input to multiple agents simultaneously, then merges their outputs. This is powerful when you want diverse perspectives on the same problem.

Here is an example -- a product feedback analysis fan-out:

PARALLEL AGENTS (all receive the same customer feedback dataset):

AGENT A: Sentiment Analysis Agent
Analyze customer feedback for sentiment patterns. Produce:
- Overall sentiment distribution (positive/neutral/negative)
- Sentiment trends over time
- Sentiment by product area or feature
- Verbatim quotes that best represent each sentiment cluster

---

AGENT B: Feature Request Agent
Analyze customer feedback for feature requests and product suggestions.
Produce:
- Categorized feature requests ranked by frequency
- Feature requests correlated with customer segment (enterprise, SMB, etc.)
- Unmet needs that customers describe but do not frame as feature requests
- Competitive mentions (features customers see in competitor products)

---

AGENT C: Churn Risk Agent
Analyze customer feedback for churn signals and dissatisfaction patterns.
Produce:
- Customers or segments showing churn risk indicators
- Root causes of dissatisfaction ranked by severity
- Comparison of churned customer feedback vs. retained customer feedback
- Early warning signals that precede churn

---

MERGE AGENT:
Synthesize the outputs from the Sentiment, Feature Request, and Churn Risk
agents into a unified Customer Voice Report. Resolve any contradictions
between agents. Produce a prioritized action list that addresses the
highest-impact findings across all three analyses.

The power of the fan-out pattern is independence. Each agent looks at the same data through a different lens without being influenced by the others. The merge agent then has the hard job of resolving conflicts -- for example, if the sentiment agent says customers are generally positive but the churn risk agent identifies significant dissatisfaction in a specific segment.

Design tip: The merge agent should be explicitly instructed to look for and resolve contradictions. Without this instruction, it will tend to simply concatenate the outputs.

Step 3: Build a Coordinator Pattern

The coordinator pattern is the most flexible but also the most complex. A lead agent reads the input, decides what subtasks are needed, delegates them, and synthesizes the results.

COORDINATOR AGENT:
You are a Project Coordinator Agent. Your role is to decompose complex
business problems into subtasks and delegate them to specialist agents.

INPUT: A business problem description from the user.

PROCESS:
1. Analyze the problem and identify 2-4 distinct workstreams needed.
2. For each workstream, specify:
   - Which specialist agent should handle it
   - The specific input that agent needs (extracted from the problem)
   - The output format expected
   - Any dependencies between workstreams
3. After receiving specialist outputs, synthesize them into a unified
   response that directly addresses the original problem.

AVAILABLE SPECIALISTS:
- Research Agent: Deep research on any topic. Returns structured findings.
- Analysis Agent: Quantitative or qualitative analysis. Returns insights.
- Writing Agent: Produces any written content. Returns polished copy.
- Strategy Agent: Strategic thinking and planning. Returns recommendations.

RULES:
- Never delegate the synthesis step. That is your job.
- If specialists return contradictory findings, investigate and resolve.
- If a specialist's output is insufficient, provide feedback and re-query.
- The final output must be a coherent whole, not a stapled-together set
  of specialist outputs.

The coordinator pattern excels at ambiguous problems where you do not know upfront which agents will be needed. The coordinator's intelligence determines the decomposition, making the system more adaptable than rigid sequential or parallel patterns.

Design tip: Give the coordinator explicit rules about what it should never delegate. Synthesis and judgment calls should stay with the coordinator.

Step 4: Combine Patterns

Real-world workflows often combine all three patterns. Here is how they compose:

1. Coordinator receives the problem and decomposes it into 3 workstreams.

2. Workstream A is a sequential chain:
   Research Agent -> Analysis Agent -> Recommendation Agent

3. Workstreams B and C are parallel:
   B: Competitive Analysis Agent  |  C: Customer Research Agent
   (running simultaneously)

4. All three workstream outputs return to the Coordinator for synthesis.

This hybrid approach gives you the adaptability of the coordinator, the depth of sequential chains, and the speed of parallel execution. The design principle is: use sequential chains where order matters, parallel fan-outs where independence is valuable, and a coordinator when the decomposition itself requires judgment.

Expected Output

When you implement these patterns, you should see:

Tips and Variations

Start with sequential, then optimize. If you are unsure which pattern to use, start with a sequential chain. Once it works, identify which agents are truly independent and move them to parallel execution. This incremental approach avoids premature optimization.

Use the coordinator for user-facing systems. When you do not control the input format (because users are typing freeform problems), the coordinator pattern handles the ambiguity far better than rigid sequential or parallel patterns.

Define clear contracts between agents. The most common failure in multi-agent workflows is ambiguous handoffs. Every agent should have an explicitly defined input format and output format. Think of these as API contracts.

Add error handling at the merge point. When parallel agents return outputs of varying quality, the merge agent should be able to identify which outputs are strong and which need re-processing. Include quality assessment instructions in your merge agent's prompt.

Generate the full prompt automatically -->