Building with AI

How to Run Multiple Claude Code Agents Without a Mess

Run multiple Claude Code agents by starting with one agent for the design, then splitting the work. Give each agent one job and a check you can run, put each session in its own git worktree, and tell every agent to loop, review its own code, and test in Playwright before it stops.

By Roupen Odabashian
Published  |  Updated  |  8 min read

Here's the habit that changed how fast I work: several Claude Code instances open in one VS Code window, with one of them handing out the jobs.

Watch on YouTube: How I get several AI instances to work together in VS Code (49 seconds)

Below are the rules I follow so that several agents speed me up instead of creating a disaster. They come in the order I use them: set up, design with one agent, split the work, keep sessions apart, keep agents small, and make each one finish the job.

What do you need before running several Claude Code agents?

You need VS Code, the Claude Code extension, and a folder open. That's the whole setup. I tell every doctor I teach to download VS Code first if they want to use AI on their own computer.

Think of VS Code as a word processor, but for code. And code is just instructions to the computer, so don't be scared of it. The steps:

  1. Download VS Code for Mac or Windows.
  2. Go to the extensions section and add the Claude Code extension (or OpenAI's, if that's what you use). Anthropic's VS Code guide walks through it.
  3. Log in with your own subscription.
  4. Open a folder. This is the step that makes it all work. Once a folder is open, your AI has access to what's inside it.

The layout is simple. Folders on the left, the editor in the middle, Claude Code on the right. From there you can ask the agent to rename files, create a Word document or an Excel sheet, or build an app. The AI just needs an environment to work in, and VS Code is the easiest one I know. Short version: Download VS Code first if you want to use AI on your own computer.

Should you start a new app with one agent or several?

Start with one. If you put five agents on a new app and ask them to build it, you end up with a disaster, because several agents give you several different designs.

So I open one Claude Code instance and spend a lot of time on the UI and UX. How it looks, how it feels, and what each button is going to do. At this stage the buttons don't have to work. I'm only looking at the interface, on my own computer, running locally.

Once I like how things look and function, I split the work. Either I tell that same instance to build the backend, or I open several Claude Code instances and ask one of them to split the work and tell the others to start on the backend.

The other half of this rule: don't open PRs, merge them to GitHub, and then go test things in the cloud. Build locally first, build the UI and UX first, and deploy after. That design step is what makes you faster later. Short version: Design with one AI agent first, then split the work.

How do several Claude Code instances work together in VS Code?

One instance plans, then messages the others and gives each one a job. When you open several Claude Code instances in the same VS Code window, one instance can know that the other instances exist.

Here's how I use that:

That's how I get through a list of pull requests much faster. When I'm vibe coding, this trick increased my productivity at least ten times. Anthropic documents the feature as cross-session messaging, and if you want Claude Code to coordinate a group of sessions with shared tasks, read the docs on agent teams.

The planner matters more than the number of agents. One instance holds the plan and hands out the jobs. The rest execute.

How do you stop parallel Claude Code sessions from overwriting each other?

Give each session its own git worktree. A worktree is just a copy of your code in a separate folder, so each AI works in its own folder and their changes don't collide.

I say it in the prompt, plainly: I want you to work in your own separate worktree, because there are other Claude Code instances working on this repository. Then each instance creates its own. That's how I can work on two, three, four or five features at the same time, each in its own tab.

Claude Code has this built in. The official docs on running parallel sessions with worktrees cover the --worktree flag and cleanup, and the common workflows page shows the basic command. If you want the git side, here's the git worktree reference.

One more thing I learned the expensive way: I don't deploy on every PR. Each agent merges its PRs one by one into the staging branch, and I deploy once at the end. Every deploy runs GitHub Actions, and those minutes cost money. I go deeper on this in how I ship 30 PRs a day with Claude Code.

Why build several small agents instead of one big one?

Because when one big agent gets things wrong, you can't tell where it broke. Small agents, each with one job, are easy to check and easy to fix. I use three rules.

  1. One agent, one process. Not "handle my email." Triage the inbox and draft replies. That's it.
  2. Give every agent a check you can run. If it drafts an email, you read it before it sends. If it writes code, the tests have to pass. If you can't check it, it's too big. Split it.
  3. Put one orchestrator on top. It decides the order and what needs your approval. The small agents never reach the outside world without it.

Here's mine. Every morning, one command in Claude Code runs six small agents: inbox, podcast, posts, video, opportunities, and people I should reconnect with. They all run on Claude, but each one has a narrow job, and that's why each one does it well. When one breaks, I fix that one, not my whole day.

Small agents you can check beat one big agent you have to trust. Short version: Stop building one AI agent for everything: 3 rules I use in Claude Code. If you want to build these yourself, Anthropic's docs on custom subagents are the place to start.

Why does my AI coding agent keep stopping?

Because you gave it a task, not a job. A task is "fix this bug." A job is "own this until it's done." An agent with a task stops after every step and waits for you.

Three lines in the prompt hand over the whole job:

  1. Tell it to loop. I use the /loop command and ask it to keep going until the work is done. It's documented under running prompts on a schedule.
  2. Make it check its own work. I run /code-review before every pull request. Then a second tool, Codacy, reviews the pull request again once it's open.
  3. Make it prove it works. I add one line to the prompt: test everything in Playwright, and don't stop working until everything is tested. Playwright opens a real browser and clicks through the app like a user.

Loop, review, test. The software factory is here. Short version: Your AI coding agent keeps stopping? 3 Claude Code rules.

What are all the rules in one place?

Six rules, each fixing one specific way multi-agent work goes wrong.

RuleWhat it preventsVideo
Set up VS Code and open a folderAn agent with nothing to work onDownload VS Code first
Design with one agent, test locallyFive agents, five designsDesign with one agent first
One planner messages the othersAgents duplicating or skipping workSeveral instances together
Each session in its own worktreeSessions overwriting each other's changes30 PRs a day post
One agent, one process, one check, one orchestratorNot knowing where a big agent brokeStop building one agent
Loop, review, testAn agent that stops after every stepAgent keeps stopping

What do you still have to check yourself?

The logs, the traces, and the result. This workflow works, but it needs attention. Mistakes still happen, even with all of these rules.

When something goes wrong, I go and look at my traces and logs and work out where the mistake happened. That's where the human comes in. The agents make the work faster. They don't make understanding the system optional. You still need to be able to read the code they write.

Frequently asked questions

Can Claude Code instances in VS Code talk to each other?

Yes. When I open several Claude Code instances in the same VS Code window, one instance can know the others exist. I draft the plan with one of them, then ask it to message the others, break the plan into pull requests, and give each instance one job. Anthropic documents this as cross-session messaging.

Do I need git worktrees to run parallel Claude Code sessions?

If more than one session edits the same repository, yes. A worktree is a copy of your code in a separate folder, so each agent works in its own folder and their changes do not collide. I tell each instance that other Claude Code instances are working on the repo and that it should create its own worktree.

Why does my AI coding agent keep stopping after every step?

Usually because you gave it a task, not a job. Fix this bug is a task. Own this until it is done is a job. I tell it to loop with the /loop command, review its own code with /code-review before every pull request, and test everything in Playwright before it stops.

How many agents should I start with on a new app?

One. If you put several agents on a new app at the same time, you get several different designs. I build the UI and UX with one Claude Code instance, test it locally, and only split the work across several instances once I like how it looks and what each button does.

Is one big agent or several small agents better?

Several small ones, each with one job and a check you can run, with one orchestrator on top that decides the order and what needs your approval. When one small agent breaks, you fix that one. When one big agent breaks, you cannot tell where it went wrong.

Roupen Odabashian

About the author

Roupen Odabashian is a medical oncologist and the founder of MeDucation AI. He taught himself to code during his hematology and oncology fellowship and now builds software with AI every day. He writes about where artificial intelligence actually changes the work, in medicine and in the tools behind it.

More about Dr. Odabashian  ·  All writing  ·  YouTube