claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Session state should persist across git worktrees

Open davidrimshnick opened this issue 1 month ago • 2 comments

When using git worktrees, Claude Code stores session state (.claude/) in the worktree folder rather than the main repository. This causes conversation history to be lost when the worktree is deleted after merging.

Current behavior

  • Create worktree for feature branch
  • Work with Claude Code (session stored in worktree's .claude/)
  • Merge branch to main
  • Delete worktree → session history lost

Expected behavior

Session state should be associated with the git repository identity, not the filesystem path. Options:

  1. Store sessions in the main repo's .git/ directory (shared by worktrees)
  2. Associate sessions by repo remote URL or other repo identifier
  3. Allow session migration when worktree is removed

Use case

Worktrees are designed to be disposable - you create them for a branch, do work, merge, and delete. Tying session state to the worktree folder works against this workflow pattern.

davidrimshnick avatar Dec 30 '25 05:12 davidrimshnick