Much of my current work involves a long-running data pipeline. In the past, this always started from a clean slate, but we're adapting it to support multiple runs and keep all the data. Recently, I was tasked with testing if the queries we're running are performant after multiple calculation runs. This meant running the same long-running data pipeline across different database sizes. Each run takes over 30 minutes, so I couldn't context-switch without abandoning progress or just waiting it out.

This is when I looked for Claude's built-in worktree support.

The Solution

Claude has a -w (or --worktree) flag that creates an isolated git worktree and starts a session in it:

claude -w fix-bug-while-performance-testing

That's it. Claude creates a worktree at .claude/worktrees/fix-bug-while-performance-testing, checks out a new branch, and starts a session there. Your main working directory stays untouched.

Running Parallel Sessions

Now I can have multiple Claude sessions running simultaneously.

Each session operates independently with its own branch and working directory. No conflicts, no context pollution.

Practical Example

Here's my typical workflow when I need to handle another task while the pipeline is running:

# Pipeline is running in main terminal...
just run_calculation

# New terminal - start a worktree session
claude -w another-jira-ticket

# Inside the session, work normally
> Hi Claude, we will now start on Jira issue AR-1234

When done, the changes are on their own branch, ready for PR. Claude will ask to clean up the worktree when you're done, but you can also use git directly to clean this up.

git worktree list
git worktree remove .claude/worktrees/urgent-fix

When This Shines

  • Long-running tasks: Data pipelines, migrations, comprehensive test runs
  • Code review while coding: Review a PR in a worktree while your main work continues
  • Parallel experiments: Try different approaches in separate worktrees

Note for Other AI Tools

The -w flag is Claude-specific, but the underlying mechanism is pure Git. If you're using other AI coding assistants, you can achieve the same result manually:

git worktree add ../my-repo-parallel -b feature/parallel-work
cd ../my-repo-parallel
# Start your AI assistant of choice

Each worktree needs its own dependencies installed (npm install, etc.), but commits and branches are shared with your main repo.

TL;DR

Stop waiting for long-running tasks to complete. With claude -w, you can spin up an isolated session in seconds and keep working on something else.

Your future self, waiting for that pipeline to finish, will thank you.

Follow our bi-weekly SaaS show

Fast, honest insights from the trenches of SaaS. Andreas and Sjimi, partners at madewithlove, share what they’re seeing inside real SaaS teams and products every two weeks.