Session state should persist across git worktrees

Open 💬 5 comments Opened Dec 30, 2025 by davidrimshnick

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.

View original on GitHub ↗

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