claude-code
claude-code copied to clipboard
Session state should persist across git worktrees
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:
- Store sessions in the main repo's
.git/directory (shared by worktrees) - Associate sessions by repo remote URL or other repo identifier
- 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.