brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: claude -w gives every session its own git worktree

Claude
~/tips/tip-claude-worktree-flag

claude --worktree feature-auth

Starts Claude Code in its own git worktree and branch so parallel sessions do not collide.

Two Claude sessions editing the same checkout will trip over each other sooner or later.

A git worktree is a second working directory with its own branch, sharing the same history. Claude Code can make one for you with --worktree (or -w).

claude --worktree feature-auth

That creates .claude/worktrees/feature-auth on a new branch called worktree-feature-auth and starts Claude inside it. Run the same command with another name in a second terminal and you have two isolated sessions. Leave the name out and Claude picks one, like bright-running-fox.

On exit, a clean worktree from an unnamed session is removed together with its branch. If there is work in it, Claude asks whether to keep it.

The reason I like this over cloning the repo twice is that the history is shared. A branch made in one worktree is visible in the others right away, and git will refuse to check out the same branch in two places, which is a small safety net you want when two agents are busy. One session can build a feature while another fixes a bug, and neither sees the other's half-finished files.

Two catches. A worktree is a fresh checkout, so no node_modules and no .env. And add .claude/worktrees/ to your .gitignore, or the folders show up as untracked files in your main checkout.

Further reading: Run parallel sessions with worktrees – Claude Code docs, CLI reference – Claude Code docs, On this site: –add-dir lets Claude see a second folder in the same session, On this site: Ctrl+O opens the transcript view where Claude's work is not hidden

More Claude tips /recap /focus /skill-doctor /autocompact 500k claude purge ~/work/my-repo --dry-run All Claude tips (83) All topics

Link