One AI agent is powerful. Multiple AI agents working together are something else entirely. One developer tasked 16 Claude agents with building a Rust-based C compiler from scratch — one agent worked on parsing, another on code generation, another on optimization passes — all communicating and validating each other’s work.

Multi-agent coding is no longer theory. Anthropic released Agent Teams in February 2026, and multi-agent system inquiries surged over 1,400% in the past year. By the end of 2026, 40% of enterprise applications are expected to include task-specific AI agents.

But multi-agent workflows are still early. This article focuses on the patterns that work today — not what might work in six months. If you need background on AI agents in general, start with What Are AI Coding Agents?.

Single Agent vs Multi-Agent — When to Use Which

Not every task needs multiple agents. Most coding tasks are better with a single focused agent.

Use a single agent when:

  • The task is focused: “fix this bug,” “write this function,” “add this test”
  • You need back-and-forth conversation to refine the approach
  • The task takes less than 15 minutes
  • The scope fits in one context window

Use multiple agents when:

  • You need to change multiple independent parts of the codebase at the same time
  • The task is large enough to be parallelized (frontend + backend + tests)
  • You want specialized agents for different concerns (coding, reviewing, testing)
  • You are building a feature that touches many files across different modules

The rule of thumb: if you would assign the task to one developer, use one agent. If you would assign it to a team, use multiple agents.

Pattern 1: Subagents — Quick Parallel Workers

Subagents are the simplest form of multi-agent workflow. You launch focused agents for specific tasks and they report back to you.

Think of subagents as contractors you send on separate errands. They each do their job and bring back results. They do not talk to each other.

When to use subagents:

  • Parallel independent tasks (run linting while generating tests while checking docs)
  • Research tasks (search the codebase for all uses of a deprecated API)
  • Simple delegated work that does not need coordination

Example with Claude Code:

I need to prepare for a refactor. Run these tasks in parallel:

1. Find all files that import from the old @utils/date module
2. Check our test coverage for the date utility functions
3. Look at how date-fns handles the same operations
   we have in our custom date module

Give me a summary of all three when done.

Claude Code’s subagents handle each task independently and report back. The key benefit is speed — three tasks run at the same time instead of sequentially.

Limitations of subagents:

  • They cannot share findings with each other
  • They cannot coordinate on overlapping work
  • If subagent A discovers something that affects subagent B’s task, there is no way for them to communicate
  • They work well for independent tasks, not interdependent ones

Pattern 2: Agent Teams — Coordinated AI Collaboration

Agent Teams, released with Claude Code v2.1.32, are fundamentally different from subagents. Team members share a task list, message each other directly, and coordinate their work.

Think of it as a project team sitting in the same room. Each person works on their piece while staying in sync through conversation.

How it works:

  1. One agent acts as the Team Lead — it coordinates work and assigns tasks
  2. Other agents are Teammates — they work independently but communicate with the lead and each other
  3. All agents share a task list that tracks who is doing what
  4. Teammates can message each other to share findings or ask questions

Setting up Agent Teams:

Agent Teams is still experimental. Enable it by adding the setting to your environment:

export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=true

Or add it to your Claude Code settings.json.

Starting a team session:

Start an agent team to build the user notification feature.

Team roles:
- Backend agent: Create the notification service, database
  schema, and API endpoints
- Frontend agent: Create the notification UI component,
  badge counter, and notification list
- Test agent: Write integration tests for the notification
  endpoints and unit tests for the UI

The backend agent should start first so the frontend agent
knows the API contract. The test agent can start writing
test structures immediately.

Claude Code creates the team, assigns roles, and the agents start working. The backend agent messages the frontend agent when the API contract is ready. The test agent watches both and writes tests as the code takes shape.

Real-world performance:

A 5-agent team uses roughly 5x the tokens of a single session. For a 30-minute multi-agent session, expect to use significantly more tokens than a solo session. But if the task would take 3 hours with a single agent, finishing it in 30 minutes with a team can be worth the cost.

Pattern 3: Tool Specialization

Instead of one agent doing everything, assign different tools to different agents. This works with or without Agent Teams.

The specialist pattern:

Terminal 1: Claude Code — Code writer
"Implement the new payment processing module.
Focus only on writing the code."

Terminal 2: Claude Code — Code reviewer
"Watch the files in src/services/payment/.
Whenever a file changes, review it for security
issues and logic errors."

Terminal 3: Claude Code — Test writer
"Watch the files in src/services/payment/.
Whenever a file changes, write or update the tests
to match the new code."

You run three Claude Code instances in separate terminals. The code writer builds, the reviewer catches issues, and the test writer keeps coverage up to date.

This is less automated than Agent Teams but gives you more control. You see each agent’s output in real time and can redirect any of them.

Pattern 4: Sequential Pipeline

A pipeline passes work through stages, where each stage is handled by a different agent or prompt.

The pipeline pattern:

Stage 1: Architecture Agent
"Design the database schema and API contract for
the notification feature. Output a specification
document. Do not write any implementation code."

→ Output: specification.md

Stage 2: Implementation Agent
"Read specification.md. Implement the backend API
and database migrations exactly as specified.
Do not deviate from the specification."

→ Output: implemented code

Stage 3: Test Agent
"Read specification.md. Write tests that verify the
implementation matches the specification. Test every
endpoint and error case mentioned in the spec."

→ Output: test files

Stage 4: Review Agent
"Review the implementation and tests against
specification.md. List any discrepancies.
Check for security issues and missing edge cases."

→ Output: review comments

Each stage builds on the previous one. The specification acts as a contract between agents. This is especially useful for large features where you want the architecture locked down before implementation begins.

Claude Code and Cursor Together

One powerful multi-agent pattern does not require any special setup. Run Claude Code in your terminal and Cursor in your editor at the same time.

How it works:

  • Claude Code handles complex reasoning, codebase-wide changes, running tests, and git operations
  • Cursor handles quick inline edits, UI tweaks, and file-focused changes

Real workflow:

  1. Use Claude Code to scaffold a new feature across multiple files
  2. Switch to Cursor to fine-tune the UI components with inline editing
  3. Switch back to Claude Code to write tests and check for issues
  4. Use Cursor’s Composer to make coordinated changes across a few files
  5. Use Claude Code to create the PR

This is not technically multi-agent — it is multi-tool. But it is the most practical “two AI” workflow that most developers use daily.

Failure Handling in Multi-Agent Workflows

When multiple agents work together, one bad output can cascade. Here is how to handle failures.

The domino problem: Agent A generates a buggy API. Agent B builds a frontend against that buggy API. Agent C writes tests that pass against the buggy code. Now you have three agents’ worth of work that is all wrong.

Prevention strategies:

1. Use specifications as contracts. Write the spec first (or have an agent write it), review it, then have implementation agents follow it. If the spec is right, the agents have clear success criteria.

2. Review agent output at each stage. Do not let agents chain together without human checkpoints. Review the architecture before starting implementation. Review the implementation before starting tests.

3. Run tests continuously. If Agent A breaks something, the test suite catches it before Agent B builds on top of broken code.

4. Use git branches per agent. Each agent works on its own branch. You review and merge each one separately. If one agent’s work is bad, you discard it without affecting the others.

5. Set time limits. If an agent spends more than 10 minutes going in circles, stop it and reassess. Multi-agent workflows amplify both productivity and waste.

Cost Management

Multi-agent workflows cost more. Here is how to manage the spend.

Token usage per pattern:

  • Single agent: Baseline cost
  • Subagents: 2-3x baseline (quick, focused tasks)
  • Agent Teams (3 agents): 3-5x baseline (more communication overhead)
  • Agent Teams (5+ agents): 5-10x baseline (significant communication overhead)
  • Sequential pipeline: 3-4x baseline (but each stage can use a cheaper model)

Cost optimization strategies:

Use the right model for each agent. The architecture agent needs the strongest model (Opus). The implementation agent can use Sonnet. The test generation agent can use Sonnet or even Haiku for simple test patterns.

Limit agent team size. Start with 2-3 agents. More agents means more communication overhead and higher token usage without proportional productivity gains.

Set budgets per session. Claude Code shows token usage in the terminal. Set a mental budget before starting a multi-agent session. If a 30-minute session costs 5x your normal budget, make sure the task justifies it.

Time-box multi-agent sessions. A 30-minute multi-agent session should accomplish what would take 2-3 hours solo. If it does not, the task might not be suited for multi-agent.

When Multi-Agent Makes Things Worse

Multi-agent workflows are not always better. They actively make things worse in these situations:

Small, focused tasks. Spinning up multiple agents for a 5-minute bug fix adds overhead without benefit.

Tightly coupled code. If every change affects every other file, agents will conflict with each other. They need independent areas to work in.

Unclear requirements. If you do not know what you want, multiple agents will build multiple wrong things faster.

Debugging. When something is broken, you need one focused agent tracing through the problem. Multiple agents debugging the same issue creates confusion.

A Real Multi-Agent Session

Here is what a practical multi-agent session looks like for building a feature.

The task: Add a commenting system to a blog application.

Setup:

Start an agent team for the commenting feature.

Backend agent:
- Create the Comment model (author, content, postId, createdAt)
- Create CRUD API endpoints (GET, POST, DELETE)
- Add rate limiting (max 10 comments per minute per user)
- Handle nested replies (one level deep)

Frontend agent:
- Create the CommentList component
- Create the CommentForm component
- Add optimistic updates for new comments
- Handle loading and error states

Wait for the backend API contract before starting
the frontend implementation.

What happens:

  1. The backend agent creates the database migration, model, and API routes
  2. It messages the frontend agent with the API contract: endpoint URLs, request/response formats
  3. The frontend agent builds the UI components using the provided API contract
  4. Both agents run their own tests
  5. The team lead agent checks that the frontend calls match the backend endpoints

Total time: About 20 minutes for a feature that would take 2-3 hours with a single agent.

Total cost: Approximately 4x a single-agent session.

Key Takeaways

  • Start with subagents. They are the simplest pattern and work well for parallel independent tasks.
  • Use Agent Teams for large features. When agents need to coordinate, Agent Teams handle communication automatically.
  • Combine tools. Claude Code in the terminal plus Cursor in the editor is the most practical daily workflow.
  • Review at checkpoints. Do not let agents chain together without human review between stages.
  • Watch the cost. Multi-agent workflows use more tokens. Make sure the time savings justify the spend.

What’s Next?

In Building a CLI Tool with AI — From Idea to Published Package, you will put everything together. You will build a real project from scratch using the techniques from this series — prompts, context, testing, review, and multi-agent workflows.


Part 14 of the Vibe Coding series.