Blog · Guide · 16 November 2026

How to Run Claude Code in Parallel

There are four ways to run Claude Code in parallel, and they suit different jobs. You can start separate sessions in git worktrees, delegate to subagents inside one session, form an agent team, or launch headless sessions from a script. This guide goes through each with the commands from Anthropic's documentation, explains how to choose, and then deals with the practical issue every parallel setup runs into: permission prompts arriving faster than one person can answer them.

Option 1: Separate sessions in git worktrees

A git worktree is a second working directory on its own branch that shares the repository's history. Claude Code can create one for you:

claude --worktree feature-auth

Per the docs, this creates the worktree under .claude/worktrees/feature-auth/ on a new branch named worktree-feature-auth and starts Claude there. Run the command again with a different name in another terminal for a second session. If you omit the name, one is generated.

Use this when the tasks are independent and should end up as separate pull requests. You coordinate; nothing connects the parallel sessions automatically.

Tips:

  • Untracked files such as .env are not in a fresh worktree. The docs describe a .worktreeinclude file for copying what a session needs.
  • Each worktree needs its own dependency install and its own ports if you run servers.
  • Clean up worktrees you no longer need.

Option 2: Subagents

Subagents run inside one session. Each has its own context window and returns only a summary to the main conversation.

You define a subagent as a Markdown file with YAML frontmatter in .claude/agents/:

---
name: test-runner
description: Runs the test suite and reports failures with file and line.
tools: Bash, Read, Grep
---
Run the project's tests. Report only failing tests and the likely cause.

Facts from the docs: subagents can run in the foreground or the background, 20 can run at once by default, they can nest up to three levels, and isolation: worktree gives a subagent its own temporary worktree.

Use subagents when you want focused work done and only the result matters: searching a codebase, running checks, making a contained change.

Option 3: Agent teams

Agent teams coordinate several full sessions with a lead, a shared task list and direct messages between teammates. They are experimental and off by default. Enable them in settings:

{ "env": { "CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1" } }

Then describe the team in plain language, for example: "Spawn three teammates to review this PR: one for security, one for performance, one for test coverage."

The docs suggest three to five teammates, say token use is significantly higher than a single session, and list limitations: one team per session, no nested teams, and no teammates in non-interactive mode.

Use a team when the workers benefit from talking to each other, such as debating competing explanations for a bug.

Claude Code subagents vs agent teams compares options 2 and 3 in more depth.

Option 4: Headless sessions from a script

Claude Code runs non-interactively with -p:

for pkg in billing search notifications; do
  (cd "sandboxes/$pkg" && claude -p "Migrate packages/$pkg to the new HTTP client. Edit only that package." &)
done
wait

This is how CI jobs and cloud sandboxes run it, and it is the route to dozens or hundreds of sessions.

The catch is permissions. A headless session cannot show a prompt. The docs say that in sessions that cannot prompt, a tool call with no permission decision is denied. So you must decide in advance what is allowed, through allow rules, a permission mode such as dontAsk with an explicit list, or a hook that answers.

How to choose a way to run Claude Code in parallel

You want Use
Independent tasks, separate pull requests Worktree sessions
A quick answer without filling the main context Subagents
Workers that discuss and challenge each other An agent team
Many workers with no terminal Headless sessions
One sequential task in the same files A single session

The docs are clear on the last row: for sequential tasks, same-file edits or work with many dependencies, a single session is more effective than any parallel arrangement.

The permission prompts problem

Every parallel option multiplies permission prompts.

  • With worktree sessions, each terminal waits separately.
  • With agent teams, the docs say teammate permission requests bubble up to the lead, and recommend pre-approving common operations before spawning teammates.
  • With headless sessions, an unanswered request is a denial.

Work through this in order.

1. Write allow rules for the routine. Put them in the project's settings so every session shares them:

{
  "permissions": {
    "allow": ["Bash(npm run test *)", "Bash(npm run lint)", "Bash(git status)"],
    "deny": ["Bash(git push --force *)", "Read(./.env)"]
  }
}

Deny rules are checked first, then ask, then allow.

2. Choose a mode. acceptEdits removes prompts for file edits in the working directory. Auto mode hands routine decisions to a classifier. See Claude Code permission modes compared.

3. Turn on the sandbox so commands are confined.

4. Give the remaining prompts one destination. Whatever is left still appears in whichever terminal asked. With four sessions that means watching four terminals.

The last step is what Forkit handles. Its PermissionRequest hook sends each remaining prompt to one queue. Shared command rules answer first, and the rest appear in a web inbox or in a single terminal running forkit watch, where one key allows once, allows for an hour, makes a rule or denies. Identical requests from several agents are merged. If you do not answer within 90 seconds by default, the session shows its normal prompt.

Setup is one command, which signs you in, creates a key per agent it finds and adds the hooks to ~/.claude/settings.json after making a backup:

npx forkit-cli init

Keeping parallel sessions out of each other's way

  • Split by files. Give each session a directory it owns and say so in the prompt.
  • One owner for shared files. Lockfiles, routers and schemas belong to a single session.
  • Merge often. Short-lived branches conflict less.
  • Claims across sessions. If sessions share a branch or run on different machines, record who is editing what. See file locking for AI agents.

Costs to expect

  • Tokens. Each session has its own context. Teams cost the most, subagents the least.
  • Attention. Four sessions produce four results to review. Review becomes the limit before compute does.
  • Machine load. Each worktree may run its own build and tests.

Start with two sessions. Add more when review keeps up.

Where Forkit fits

Claude Code supplies the parallelism. Forkit supplies the single place where all those sessions ask and you answer, plus file claims and messages between sessions when they need to coordinate. It is free to try. More at forkit-mcp.com.