Skip to main content

Lesson 1 of 8 · Run several Claude Code sessions at once

Run two Claude Code sessions without them overwriting each other

From Claude Code in Parallel: From Idea to Merged PR: Run several Claude Code sessions at once without collisions, ask for options before Claude builds, check its proof instead of its word, and keep quality high as you ship more.


Lesson 01 · Parallel sessions

Run two Claude Code sessions without them overwriting each other

Two sessions in one folder edit the same files. See what breaks, then how to keep them apart.
  • Course: 8 lessons
  • Time: ~69 min
  • Free: This lesson, no account
  • Inspired by: A public talk on how Anthropic's design team uses Claude Code

You're running Claude Code on one task when a second one comes in. The obvious move is to open another terminal and start another session.

Here's what happens when both sessions share one folder. Make the calls you'd really make.

Two sessions, one folder

What went wrong. A checkout is one folder of files on one branch. Each session reads the other's edits, so its tests run against unfinished work.

A git worktree is a separate working folder with its own files and its own branch. It shares your repository's history and remote, so it isn't a second clone.

Give each session its own worktree and each edits its own copy: one builds a feature while another fixes a bug. Claude Code even refuses a worktree session's file edits that target your main checkout.

A new worktree is a fresh checkout, so install dependencies there first. Files git ignores, such as .env, aren't copied in unless a .worktreeinclude file lists them.

Start a session in its own worktree

Your toolbar session is busy in the main checkout, and the crash fix has its own worktree. A third task comes in: update the pricing page.
  1. In a new terminal, in your repo, start a session in its own worktree called pricing.
  2. List every checkout of this repository.

Its own worktree, or the same session?

Six tasks arrive while other sessions are busy. All six must be right.
Fix a crash on the payment page while another session restyles the toolbar
Rename a function the toolbar session added but hasn't merged
Write tests for an endpoint another session is still building
Build two versions of the settings page to compare side by side
Try a riskier fix for the same bug without touching the first attempt
Make the restyle's new buttons a little bigger

One question sorts all six

Does the task need changes another session hasn't merged yet?

If not, give it its own worktree and run both at once. If it does, keep it with that session: by default, a new worktree starts from your repository's default branch, without the unmerged change.

When a task is done, type /exit. Claude first checks the worktree for changed or untracked files and new commits.

  • Nothing in it: Claude removes the worktree and its branch. If you gave this session its own name with /rename, Claude asks first.
  • Work in it: Claude asks: keep or remove? Keep saves the folder and the branch. Remove deletes both, with the work in them.

Keep one, and Claude Code prints the command to come back, such as claude --worktree search-crash --resume.

Finish without losing work

One question.

Your crash fix is committed and pushed, and its pull request is open. A reviewer may still ask for changes. You type /exit, and Claude asks: keep or remove?

Finish without losing work

Your pricing change is done. It's committed and pushed, and its pull request is open.
  1. Leave this session.
  2. Two days later a reviewer asks for one more change to the pricing page. Go back into that worktree and resume your conversation.

One checkout holds one set of files, so two sessions in it edit each other's work.

Give each parallel task its own worktree: start it with claude --worktree <name>, and type /exit when it's done. Claude checks for work before it removes anything. Keep the worktree while review can still ask for changes, and remove it once it's merged.

Next: letting a session keep working without stopping to ask you before every step.

Topics: Claude Code, git worktrees, slash commands, pull request review, scheduled checks, interactive

Run two Claude Code sessions without them overwriting each other — Claude Code in Parallel: From Idea to Merged PR · SkillTycoon