Claude Code worktrees
Give each Claude Code task a worktree of its own
You want each Claude Code task kept apart from your main checkout, and from the other tasks. A git worktree does that. Here is what claude --worktree makes, and how to tidy up after.
A git worktree is a second folder for the same repository, on a branch of its own. Run claude --worktree with a name, and Claude Code makes one, by default in .claude/worktrees in your repository, and starts the session there, so its edits stay out of your main checkout.
A worktree is a second folder for one repository
A git repository usually has one working folder, the one you cloned. A worktree adds another, on a branch of its own.
Its files are separate, so a change made there leaves your main checkout alone. The history is shared. Every worktree uses the repository’s one .git directory, so a commit made in any worktree is in the repository straight away.
That makes a worktree a good home for a Claude Code task. The session edits only its own folder, while you, or another session, carry on elsewhere.
Good to know
- Worktrees keep file edits apart. To split one task between helpers inside a single session, use subagents instead.
In Mooring: No git worktree list. Every worktree, however it was made, is a row in the sidebar under its project.

What claude --worktree makes
Give claude --worktree, or -w for short, a name for the task. Before the session opens, Claude Code makes two things: a folder, .claude/worktrees/add-search, and a new branch checked out in it, worktree-add-search.
# folder .claude/worktrees/add-search, branch worktree-add-search
claude --worktree add-search
# the same, shorter
claude -w add-search
# no name: Claude Code makes one up
claude --worktreeGood to know
- The new branch starts from the repository’s default branch on the remote, usually
main, not from the branch you have checked out. So work you haven’t pushed isn’t in it. - With no name, Claude Code makes one up, in the style of
bright-running-fox. - A second terminal with a second name gives a second session, in a separate worktree.
- The folder must be a git repository Claude Code already trusts. If
claudehas never run there, run it once and answer the trust prompt.
In Mooring: No commands. Right-click the project’s tile in the sidebar, choose New Worktree…, then click Create. Mooring makes the folder in .claude/worktrees, on a worktree- branch.
Start from a pull request
To work on an open pull request, give its number in place of a name, with a # in front. Claude Code makes the worktree from the pull request’s head commit, in .claude/worktrees/pr-1234.
claude --worktree "#1234"
claude --worktree https://github.com/acme/app/pull/1234Good to know
- Put the number in quotes, or the shell may read everything from the
#on as a comment. - A link to a GitHub pull request or a GitLab merge request works too.
Get a new worktree ready to run
Claude Code builds the worktree from what git tracks, so it starts out like a fresh clone. The source is all there, but nothing git ignores is: no .env, no node_modules, no build output.
- Ignore the worktrees and list the files to copy, from the main checkout.
- Install the dependencies inside the new worktree.
# from the main checkout: ignore the worktrees, bring .env into new ones
echo ".claude/worktrees/" >> .gitignore
echo ".env" >> .worktreeinclude
# inside a new worktree: install, as in a fresh clone (a Node project here)
cd .claude/worktrees/add-search
npm install
What happens when you leave
When you leave a session in a worktree, Claude Code looks at what the worktree holds.
If nothing has changed, it removes the worktree along with its branch. If you gave the session a name of its own, it asks first.
If the worktree holds uncommitted changes or new commits, Claude Code asks what to do. Keep it, and the folder and the branch stay put. Remove it, and both are deleted, work and all.
To come back to a kept worktree, run the command Claude Code prints on the way out:
claude --worktree add-search --resumeGood to know
- A session’s name is its own, not the worktree’s.
claude --worktree add-searchon its own starts an unnamed session.
Start from a task, and see where each one stands
The --worktree option takes a name, not a task. So the name is where the task goes.
- Name the worktree after its ticket, such as
skv-42-add-search, so the folder and the branch both name the task. - Give Claude the task as your first message.
# every worktree: folder, latest commit, branch
git worktree list
# changes not yet committed in one worktree
git -C .claude/worktrees/skv-42-add-search status --short
# commits the branch adds over the remote’s main
git log --oneline origin/main..worktree-skv-42-add-searchIn Mooring: No git commands. Select a task in the Cards tab, press ⌘S, then click Create. Each sidebar row shows its branch, commits ahead and uncommitted files.

Move stray changes into a worktree
Sometimes the work starts in your main checkout before you think of a worktree. Stashes belong to the repository, not to one folder, so the changes can move across.
- In the main checkout, set the changes aside:
git stash push -u -m "add-search" - Still there, start the worktree session, and leave it running:
claude --worktree add-search - In a second terminal, go into the new worktree:
cd .claude/worktrees/add-search - Bring the changes over:
git stash pop
Good to know
- Keep the session open until the pop is done. Leave it while the worktree is still clean, and Claude Code removes it and its branch, unless the session has a name of its own.
- The new branch starts from the remote’s
main, not from your checkout, so the changes may not fit cleanly. - If the pop runs into conflicts, git keeps the stash. Fix the conflicts, then run
git stash drop.
In Mooring: No stash. Choose Move to a New Worktree… from the main folder row’s ⋯ menu, and name the work. Files git isn’t tracking yet stay in the main folder.
Tidy up after a merge
Once the branch is merged, remove the worktree, then its branch. Neither step throws work away by accident.
- In the main checkout, bring
mainup to date:git pull - Remove the worktree:
git worktree remove .claude/worktrees/add-search - Delete its branch:
git branch -d worktree-add-search
Good to know
git worktree removerefuses while the worktree has changed or untracked files.git branch -ddeletes a branch only when git can see it was merged.- After a squash merge git can’t see that, and
-drefuses. Check the work is inmain, then use-D.
In Mooring: No git commands. Remove Worktree… in the row’s ⋯ menu deletes the folder and branch, even after a squash merge, and warns first if work would be lost.
With Mooring
Everything above works with plain Claude Code and git. Mooring takes the bookkeeping away. No branch names to make up: ⌘S suggests one from the task. No git worktree list: each sidebar row shows its branch, commits ahead and uncommitted files. No stash to juggle: Move to a New Worktree… carries stray changes across. No cleanup commands: Remove Worktree… deletes the folder and branch.
Worktrees made either way, side by side
Mooring builds its sidebar’s list of worktrees from git, not from its own records. So a worktree made with claude --worktree gets a row beside the ones Mooring made.
A row takes its name from the branch, minus the worktree- prefix, with the full branch underneath: worktree-add-search shows as add-search. A row linked to a task shows the task’s key and title instead.
Mooring makes its own worktrees in the same place, the project’s .claude/worktrees folder, on branches that start with worktree- too, so both kinds follow one pattern.

From a task to a worktree with ⌘S
Select a task in the Cards tab and press ⌘S, or choose Send to New Worktree… from its right-click menu.
A sheet suggests a name and shows the folder and the branch it will make, such as .claude/worktrees/skv-42-add-search on the branch worktree-skv-42-add-search. Here skv-42 is the task’s ticket key.
Click Create, and Mooring makes the worktree, opens a Claude tab in it, and waits for Claude’s prompt before handing the task over.
The first time Claude starts in a project, it asks you to trust the folder, and Mooring waits for your answer.

When Claude is slow to start
If Claude’s prompt isn’t ready within 20 seconds, Mooring says so above the tab. Try Again hands the task over in the same worktree and tab, so trying again never makes a second worktree.

Review against the branch it came from
Mooring notes the branch each worktree it makes was made from, so the Changes tab reviews the work against that branch.
When the branch merges into the default branch, Mooring moves its task to Done, with a short summary of the work.
Shown with Skiver, a made-up team chat app for people avoiding work.
Sources
Checked 7 November 2026, from these sources. Spotted something out of date? Say so.
- Claude Code docs: run parallel sessions with git worktrees
- Git documentation: git worktree
- Git documentation: git stash
- Git documentation: git branch

