Blog

Claude Code Parallel Agents Guide

Claude Code can run parallel subagents on independent tasks simultaneously — cutting multi-task development time by 50–70%. How to set them up and where they add the most value.

Phos Team ·
claude code

Claude Code Parallel Agents: Running Multiple Tasks Simultaneously

Sequential task execution has a hidden cost that most development teams accept without questioning it. Four independent tasks that each take 30 minutes finish in two hours if run one after another. The tasks did not need to be sequential. The time cost was purely architectural.

Parallel agents eliminate that cost for tasks that are genuinely independent. Claude Code can spawn multiple subagent instances that work concurrently on separate tasks. Four 30-minute tasks complete in roughly 35 minutes total, not two hours.

The constraint is real independence. Parallel agents work when tasks do not share files, do not depend on each other’s output, and do not require coordinated commits. When that condition holds, the time savings are substantial.

Parallel agents are not a faster version of sequential work. They are a different architecture. The question is not “how do I make this faster?” but “which parts of this work are actually independent?”


What Parallel Agents Are

When you describe multiple independent tasks to Claude Code in a single session, Claude Code can spawn separate child instances, called subagents, to handle each task concurrently. Each subagent runs in its own context with its own tool access. They work simultaneously and report back to the parent session when complete.

The parent Claude Code session orchestrates: it identifies which tasks can run in parallel, spawns the subagents, and coordinates the results. You describe the work at the parent level. The subagents handle execution.

This is distinct from running two separate Claude Code sessions manually in different terminal tabs. Parallel agents are invoked and coordinated by the parent session as a single workflow. The coordination logic is handled by Claude Code, not by you.


How to Invoke Parallel Agents

Parallel execution is triggered by describing tasks in a way that makes independence explicit:

Do the following tasks simultaneously:
1. Write unit tests for the UserService class in src/services/user.ts
2. Write unit tests for the OrderService class in src/services/order.ts
3. Write unit tests for the PaymentService class in src/services/payment.ts

Each task is independent. Commit each set of tests separately when complete.

The key phrase is "simultaneously" combined with a clear statement that the tasks are independent. Claude Code recognizes the parallelization opportunity and spawns subagents accordingly.

For complex tasks, describe the parallelization at a higher level:

Build the following microservices simultaneously. Each service is independent:
- Auth service: handles user authentication and JWT tokens (spec in docs/auth-spec.md)
- Notification service: handles email and SMS notifications (spec in docs/notification-spec.md)

Each service gets its own directory. Tests must pass before committing.

Claude Code will allocate one subagent per service, both run concurrently, and the parent coordinates the final state.


Git Worktrees as the Infrastructure Layer

Parallel agents work cleanest when each agent operates in its own git worktree. A worktree is an isolated working directory linked to the same repository but checked out to a separate branch. Each parallel agent gets its own worktree, so there are no file conflicts between concurrently running agents.

Set up worktrees before spawning parallel agents on the same codebase:

git worktree add ../project-feature-auth feature/auth-service
git worktree add ../project-feature-notifications feature/notification-service

Then describe the parallel work to Claude Code with the worktree paths in the task description:

Work on the following tasks in parallel using the existing worktrees:
- Auth service work in ../project-feature-auth
- Notification service work in ../project-feature-notifications

Without separate worktrees, parallel agents writing to the same branch can produce merge conflicts mid-execution. Worktrees eliminate this by giving each agent an isolated branch to work on. The merge happens after both agents complete, when you review and combine the PRs.


Where Parallel Agents Add the Most Value

Independent Test Writing

Writing test suites for multiple unrelated modules is the cleanest parallel agent use case. Each module’s tests are independent. They read different source files, write to different test files, and run in isolation. Four modules that each need test suites complete in the time it takes to test one.

Multiple Microservices

Building independent microservices simultaneously is well-suited to parallel execution. Each service has its own directory, its own spec, and its own test suite. The services may eventually call each other, but the build phase is independent. The time savings on a four-service build are significant.

Multi-Module Documentation

Generating technical documentation for independent modules, APIs, or services parallelizes cleanly. Each documentation task reads a set of source files and writes to a documentation file. There are no dependencies between modules at the documentation generation level.

Parallel Bug Fixes on Independent Issues

A backlog of unrelated bug fixes, each scoped to a different module, can run in parallel. The fixes do not interact. Each bug fix subagent reads the relevant code, makes the fix, runs the module’s tests, and commits.


Time Savings: A Concrete Example

Sequential execution of four independent tasks:

TaskTime
Write tests for UserService30 min
Write tests for OrderService30 min
Write tests for PaymentService30 min
Write tests for InventoryService30 min
Total120 min

Parallel execution of the same four tasks:

TaskTime (concurrent)
All four test-writing tasks~35 min
Total~35 min

The 5 minutes of overhead above the slowest single task (30 min) accounts for spawning coordination and sequential commit finalization. The savings are approximately 85 minutes on a four-task set. Across a week of development work, the compounding effect is material.

The ratio holds roughly constant: parallel agents produce a 50-70% reduction in wall-clock time for sets of genuinely independent tasks of similar duration.


Task Type Reference

Task typeParallelizable?Approach
Tests for independent modulesYesOne subagent per module, separate worktrees
Independent microservicesYesOne subagent per service, separate worktrees
Multi-module documentationYesOne subagent per module
Sequential refactor (A depends on B)NoRun sequentially, A then B
Shared config file changesNoOne agent, sequential
Database migration + app code updateNoMigration first, then application update
Bug fixes on unrelated modulesYesOne subagent per bug, separate branches
Feature requiring cross-module coordinationNoSingle agent with full context

When Parallel Agents Do Not Work

Task interdependency. If task B requires the output of task A, they cannot run in parallel. Claude Code cannot merge results mid-execution. Run them sequentially and be explicit about the dependency in the prompt.

Shared files with race conditions. Two agents writing to the same configuration file, the same database seed file, or the same shared utility module will conflict. Worktrees help, but if the tasks genuinely share a file as an output target, they are not independent.

Ambiguous scope overlap. If two parallel tasks both need to modify the authentication layer, they are not actually independent. Describe one task that handles the full authentication scope rather than splitting it across agents that will fight over the same code.


Cost Considerations

Parallel agents are not cheaper. They are faster.

Each subagent runs its own Claude Code session with its own API calls and token consumption. Four parallel agents consume tokens at roughly four times the rate of one sequential agent completing the same tasks. The total token cost is similar either way. The wall-clock time is much shorter.

For teams where developer time is the binding constraint, the trade-off is straightforward. For high-volume automated pipelines where token cost is the binding constraint, sequential execution may be preferable.

Parallel agents optimize for time. Sequential execution optimizes for cost. Know which constraint matters more for the task at hand.


Frequently Asked Questions

How many parallel agents can Claude Code run simultaneously?

Claude Code can spawn multiple subagents in a single session. There is no hard-coded limit on the count. In practice, the practical ceiling is set by the number of genuinely independent tasks in the work set and the API rate limits on your account. Most teams find three to five parallel agents to be the productive range before task coordination overhead starts to offset the time savings.

Do parallel agents share context with each other?

No. Each subagent has its own isolated context window. This is intentional: it prevents one agent’s work from bleeding into another’s reasoning. The parent session holds the coordination context. Individual agents know their task but do not know what other agents are doing. This isolation is a feature, not a limitation.

Can I use parallel agents without git worktrees?

You can, but it is not recommended when agents are writing to the same repository. Without separate worktrees, concurrent writes to the same branch create merge conflicts mid-execution. Use worktrees whenever parallel agents are modifying files in the same codebase. If agents are working in completely separate repositories, worktrees are not required.

What is the difference between parallel agents and just opening multiple Claude Code terminals?

Multiple manual terminal sessions give you parallelism but require you to coordinate the work yourself. Parallel agents are coordinated by the parent Claude Code session: the parent decides which tasks are independent, spawns the agents, and handles the results. The orchestration is automated. Manual multi-terminal approaches require you to manage that coordination layer, which takes time and introduces human error in the handoff.


Ready to run parallel Claude Code agents on your team’s workload?

Start by identifying a batch of genuinely independent tasks in your current backlog, write the parallel invocation prompt using the format in this article, and set up git worktrees before the first run.

Path one: set it up yourself. Follow the worktree setup and invocation patterns above, start with two agents on clearly independent tasks, and measure the time savings before scaling up. The Claude Code course covers agent orchestration and workflow design in detail.

Path two: work with Phos AI Labs. If you want to identify where parallel agent workflows add real leverage in your team’s development process, and design the worktree and branching strategies that make parallel execution safe, we handle that design and implementation. Phos AI Labs is a CCA-F certified Claude implementation partner. Thirty minutes, no deck. Start here.

Related articles

The fastest way to know whether we're the right fit, is a conversation.

STEP 1/2 · ABOUT YOU