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:

  1. Session history — so both branches start with the same conversational context
  2. Filesystem isolation — so edits in one branch don't interfere with the other

Currently these are mutually exclusive:

  • --fork-session preserves conversation history but stays in the same directory
  • --worktree creates 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:

  1. Create a new git worktree (as --worktree does today)
  2. Fork the specified session's conversation history into the new worktree's session
  3. 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗