DEV Community

brian austin
brian austin

Posted on

Claude Code parallel agents: run 5 tasks simultaneously and finish in 20% of the time

Claude Code parallel agents: run 5 tasks simultaneously and finish in 20% of the time

If you're running Claude Code tasks one at a time, you're leaving 80% of your throughput on the table.

Claude Code supports parallel subagent execution — you can spin up multiple agents simultaneously, each working on an isolated task, and collect all results at once. Here's exactly how to do it.

The bottleneck you don't notice

Most Claude Code users work sequentially:

  1. Write tests → wait → fix code → wait → refactor module A → wait → refactor module B

Each step takes 2-5 minutes. A full feature takes 30-60 minutes.

With parallel agents, you compress that to:

  1. Spawn 4 agents simultaneously: tests + fix code + refactor A + refactor B → collect results → done

Same work, 5x faster.

The parallel agent pattern

Here's the core structure. Put this in your CLAUDE.md or use it as a prompt template:

Orchestrator prompt:
"You are coordinating 4 parallel agents. Each agent gets an isolated task. 
Spawn them simultaneously. Report when all complete.

Agent 1 task: [specific bounded task]
Agent 2 task: [specific bounded task]  
Agent 3 task: [specific bounded task]
Agent 4 task: [specific bounded task]

Constraints for each agent:
- Work only in files listed for that agent
- Do not modify shared files
- Output: list of files changed + summary"
Enter fullscreen mode Exit fullscreen mode

Real example: refactoring a Node.js API

Before (sequential, ~45 minutes):

# One at a time, waiting for each
claude "Add input validation to auth routes"
claude "Add input validation to user routes"  
claude "Add input validation to payment routes"
claude "Write tests for all validation"
Enter fullscreen mode Exit fullscreen mode

After (parallel, ~12 minutes):

claude "
Run these 4 tasks in parallel:

Agent 1: Add input validation to /src/routes/auth.js only
- Use Joi for schema validation
- Handle 400 errors with structured messages
- Do not touch any other file

Agent 2: Add input validation to /src/routes/users.js only  
- Same Joi approach
- Same error structure
- Do not touch any other file

Agent 3: Add input validation to /src/routes/payments.js only
- Same approach
- Extra: validate card number format
- Do not touch any other file

Agent 4: After agents 1-3 complete, write tests for all new validation
- Test files: /src/tests/validation.test.js
- Test each route's validation logic
- Target: 90% coverage on new code

When all done, report: files changed, tests passing/failing"
Enter fullscreen mode Exit fullscreen mode

The isolation rule (this is critical)

Parallel agents fail when they touch the same files. Always:

✅ Agent 1: auth.js only
✅ Agent 2: users.js only
✅ Agent 3: payments.js only

❌ Agent 1: auth.js + shared utils
❌ Agent 2: users.js + shared utils  ← merge conflict
Enter fullscreen mode Exit fullscreen mode

If agents need to touch shared code, put it in a sequential cleanup step after parallel work finishes.

The git branch pattern

For larger refactors, give each agent its own branch:

claude "
Before starting: create branches agent-1, agent-2, agent-3 from main.

Agent 1: checkout agent-1, implement feature X in src/feature-x/
Agent 2: checkout agent-2, implement feature Y in src/feature-y/
Agent 3: checkout agent-3, write docs in /docs/

When done: merge all branches to main. If conflicts, resolve in favor of the more complete implementation."
Enter fullscreen mode Exit fullscreen mode

What tasks parallelize well

Great for parallel:

  • Adding the same pattern to multiple isolated files (validation, logging, error handling)
  • Translating code between languages
  • Writing tests for independent modules
  • Documentation for different sections
  • Linting/formatting multiple directories

Needs sequential:

  • Tasks with shared dependencies
  • Anything that modifies a config file
  • Database migrations (ordering matters)
  • Tasks where Agent 2's input is Agent 1's output

The rate limit problem

Here's the catch: parallel agents multiply your API usage. 5 agents = 5x the tokens = 5x the rate limit pressure.

If you're on Claude Pro's standard rate limits, parallel agents will hit the wall fast. Each agent burns through context, and when you're running 4-5 simultaneously, you'll see:

Error: rate_limit_exceeded
Retrying in 60 seconds...
Enter fullscreen mode Exit fullscreen mode

This defeats the entire point — your 5x speedup becomes a 2x speedup because agents are constantly waiting.

The fix: Use ANTHROPIC_BASE_URL to route through a proxy with higher limits.

export ANTHROPIC_BASE_URL=https://simplylouie.com
Enter fullscreen mode Exit fullscreen mode

That's it. Claude Code reads this env var and routes all API calls through SimplyLouie's endpoint. You get the same claude-3-5-sonnet model, but without the rate throttling that kills parallel agent performance.

For parallel agent workflows specifically, this is the difference between the pattern actually working vs constantly hitting walls. SimplyLouie is $2/month — less than what you pay for a coffee — and it's what makes parallel agents viable at scale.

Measuring the speedup

Time your sessions before and after:

# Add to your parallel agent prompt:
"Track and report: time started, time completed for each agent, total wall-clock time"
Enter fullscreen mode Exit fullscreen mode

For most users, the first session with parallel agents shows 3-5x speedup on tasks that were previously sequential. After a few sessions, you'll restructure your entire workflow around parallelism.

The right mental model

Think of yourself as an engineering manager, not a solo developer:

  • You define the work and the constraints
  • You hand it to multiple agents simultaneously
  • You review the combined output

Claude Code's parallel execution is the closest thing to having 5 junior engineers you can direct simultaneously — except they work at 100x speed and never need clarification if your prompts are specific enough.

Start with 2 parallel agents on a task you'd normally do sequentially. Time it. Then try 4. The speedup compounds.


Using parallel agents at scale? ANTHROPIC_BASE_URL proxy at SimplyLouie routes around rate limits — $2/month flat.

Top comments (0)