Support --fork-session combined with --worktree for parallel isolated sessions with shared context
Resolved 💬 2 comments Opened Mar 24, 2026 by KaizenTamashi Closed Apr 22, 2026
Problem
When A/B testing approaches (e.g., comparing two skill implementations), you need:
- Session history — so both branches start with the same conversational context
- Filesystem isolation — so edits in one branch don't interfere with the other
Currently these are mutually exclusive:
--fork-sessionpreserves conversation history but stays in the same directory--worktreecreates filesystem isolation but starts a fresh session
There's no way to fork a session into a different worktree.
Proposed Solution
Allow combining the two flags:
claude --fork-session <session-id> --worktree <name>
This would:
- Create a new git worktree (as
--worktreedoes today) - Fork the specified session's conversation history into the new worktree's session
- The new session operates in the worktree directory with full filesystem isolation
Use Cases
- A/B testing skills/prompts — Fork the same context into two worktrees, apply different skills, compare results
- Branching complex investigations — Mid-debug, fork to try two different fix strategies in isolation
- Team collaboration — Share a session's context with a colleague working in a different worktree
Alternatives Considered
- Shared context files — Write context to a file readable by both worktrees. Works but loses conversational nuance and tool call history.
- Subagent isolation — Run both variants as subagents in the same session. Limited by subagent context and still shares the filesystem.
- Sequential testing — Test A, stash, test B. Loses parallelism.
Additional Context
Sessions are currently directory-bound. This feature would require decoupling session storage from the originating directory, or copying/linking session data when creating the worktree.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗