Summary
/worktree is great when a task fits cleanly inside a single git repo, but several rough edges make it painful in common real-world workflows. Filing as a bundle since they share a theme.
The pain points
-
Sessions are keyed by cwd, so worktrees fragment session history.
Starting a session in the repo root and then spawning a worktree means claude --resume from either location sees only half the history. There's no obvious way to follow a session across the cwd change.
-
No way to change a running session's cwd.
Once you realize mid-session you wanted to be in a worktree, you can't move the session into it. You either abandon context or abandon the worktree.
-
/worktree requires a git repo.
Useful when you're working in ~/scratch/, a docs-only dir, or any non-repo workspace and want the same isolation guarantee. Today you have to git init just to get a worktree.
-
Worktrees don't extend to sibling repos touched during the task.
My tasks routinely edit repo A while consulting/modifying repo B next to it. The worktree isolates A but the agent still reads/writes the real checkout of B, which defeats the "safe sandbox" promise of worktrees.
-
Gitignored local config (.env, decrypted secrets, local symlinks) isn't copied into the worktree.
First run of pnpm dev / tests inside the worktree fails because every gitignored dev-time file is missing. An opt-in copy list (or a documented convention) would unblock this.
Why this matters
Worktrees are the main mechanism for parallel agent work and safe experimentation. The current shape biases users toward single-repo, git-repo-only, dev-server-free tasks — a narrow slice of what people actually do.
Suggestions (not prescriptive)
- Session metadata could be keyed by session ID with cwd tracked as a mutable property.
- Allow
/worktree in non-repo dirs via a plain directory copy (opt-in).
- Let
/worktree accept additional repo paths to also worktree.
- A settings key for "files to copy into each worktree" (
.env*, *.local, etc.) with sensible defaults.
Environment
- Claude Code on macOS (darwin 24.6.0)
- Worktrees created via
/worktree into .claude/worktrees/<name>
Summary
/worktreeis great when a task fits cleanly inside a single git repo, but several rough edges make it painful in common real-world workflows. Filing as a bundle since they share a theme.The pain points
Sessions are keyed by cwd, so worktrees fragment session history.
Starting a session in the repo root and then spawning a worktree means
claude --resumefrom either location sees only half the history. There's no obvious way to follow a session across the cwd change.No way to change a running session's cwd.
Once you realize mid-session you wanted to be in a worktree, you can't move the session into it. You either abandon context or abandon the worktree.
/worktreerequires a git repo.Useful when you're working in
~/scratch/, a docs-only dir, or any non-repo workspace and want the same isolation guarantee. Today you have togit initjust to get a worktree.Worktrees don't extend to sibling repos touched during the task.
My tasks routinely edit repo A while consulting/modifying repo B next to it. The worktree isolates A but the agent still reads/writes the real checkout of B, which defeats the "safe sandbox" promise of worktrees.
Gitignored local config (
.env, decrypted secrets, local symlinks) isn't copied into the worktree.First run of
pnpm dev/ tests inside the worktree fails because every gitignored dev-time file is missing. An opt-in copy list (or a documented convention) would unblock this.Why this matters
Worktrees are the main mechanism for parallel agent work and safe experimentation. The current shape biases users toward single-repo, git-repo-only, dev-server-free tasks — a narrow slice of what people actually do.
Suggestions (not prescriptive)
/worktreein non-repo dirs via a plain directory copy (opt-in)./worktreeaccept additional repo paths to also worktree..env*,*.local, etc.) with sensible defaults.Environment
/worktreeinto.claude/worktrees/<name>