published fresh until

Claude Code: run parallel sessions in git worktrees

Summary As of November 2026, Claude Code creates .claude/worktrees/<name>/ on worktree-<name> using --worktree or -w. Use different names in separate terminals. worktree.baseRef defaults to "fresh"; "head" carries current local work. Start with claude --worktree feature-auth.

Not for Claude Code Desktop worktree setup.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Use a git repository with at least one commit, then run claude --worktree feature-auth in one terminal and a different name in the next.

Short answer

As of November 2026, --worktree (-w) isolates checkout files and branches, while git history remains shared. Install project dependencies inside each fresh checkout.

What to do

ChoiceValue / behavior
Create sessionclaude --worktree feature-auth; another terminal uses another name
Default location / branch.claude/worktrees/<name>/ / worktree-<name>
Omitted nameClaude generates a name
Base settingworktree.baseRef: "fresh" default = remote default branch; "head" = current local HEAD; arbitrary branch names are not accepted
Fresh-base fetchRefresh after 24 hours without a fetch, capped at five seconds; failed fetch uses cached ref; absent remote/cached ref falls back to local HEAD
Interactive trustRun claude once in an untrusted directory to accept workspace trust before using the worktree flag
Non-interactiveclaude -p --worktree skips the trust check; -p does not clean up on exit
Resume retained workclaude --worktree <name> --resume
List / remove / unlockgit worktree list; git worktree remove; git worktree unlock if locked
Ignore checkoutsAdd .claude/worktrees/ to .gitignore
Carry ignored filesRoot .worktreeinclude uses .gitignore syntax; copies only matching gitignored files, never tracked files

On interactive exit, a clean unnamed session removes its worktree and branch; a named session prompts first. Changed or untracked files, new commits or uncertain state produce a keep/remove prompt. Keep preserves the directory and branch; removal discards work there. An alternative checked-out branch with later commits is preserved either way.

Reusing a name opens its existing checkout. With "fresh", it resets only when sandbox writes are unrestricted, the checkout is clean, it remains on its created branch, and it has no own commits or its merged remote branch was deleted. Otherwise it stays at its old tip; "head" also keeps that tip. With sandboxing and a fresh base, run git fetch origin and use a new name to pick up the latest default branch.

For subagent isolation use isolation: worktree in a definition under .claude/agents/. WorktreeCreate / WorktreeRemove hooks replace git creation and cleanup for another VCS; .worktreeinclude is then not processed.

Limits and open questions

Worktrees share git metadata, project-scope plugins and remembered Bash approvals. File-edit and git-directory checks do not track every shell write, so filesystem sandboxing still matters. No universal port isolation is stated. The pages give no minimum release for the basic two-terminal recipe.

Not for: Claude Code Desktop worktree setup.

Sources

Checked

2026-11-16; read Worktree guide; Common workflows: parallel sessions; no command was run.

Started from a post by @Anthropic, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code: run parallel sessions in git worktrees
Summary: As of November 2026, Claude Code creates `.claude/worktrees/<name>/` on `worktree-<name>` using `--worktree` or `-w`. Use different names in separate terminals. `worktree.baseRef` defaults to `"fresh"`; `"head"` carries current local work. Start with `claude --worktree feature-auth`.
Copy for agent
get the whatworks thread claude-code-run-parallel-worktree-sessions and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-run-parallel-worktree-sessions
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks