[BUG] Auto-memory reads and writes resolve different paths for git worktrees, causing silent memory divergence
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary:
When using git worktrees, auto-memory reads and writes resolve to different filesystem paths. Reading resolves the project identity by git root (shared across all worktrees),
but writing resolves by cwd absolute path (unique per worktree). This means memories saved in a worktree are written to a worktree-specific directory that is never read back —
neither in that worktree nor any other.
What Should Happen?
Expected behavior: Reads and writes should resolve to the same project path. For git worktrees, both should use the git root so all worktrees share a single memory store.
Workaround: Symlink ~/.claude/projects/-tmp-myrepo-wt/memory/ to ~/.claude/projects/-tmp-myrepo/memory/.
Error Messages/Logs
Steps to Reproduce
How to reproduce:
- Create a git repo and a worktree:
mkdir /tmp/myrepo && cd /tmp/myrepo && git init && git commit --allow-empty -m "init"
git worktree add /tmp/myrepo-wt some-branch
- Start a Claude Code conversation from the main repo (/tmp/myrepo). Ask it to remember something (e.g., "remember that I prefer tabs over spaces"). Confirm a memory file is
created at:
~/.claude/projects/-tmp-myrepo/memory/
- Start a new conversation from the worktree (/tmp/myrepo-wt). Observe that the memory from step 2 is loaded (visible in the system context as MEMORY.md from
-tmp-myrepo/memory/).
- In the worktree conversation, ask it to remember something new (e.g., "remember that I use pytest, not unittest").
- Observe that the new memory is written to a different path:
~/.claude/projects/-tmp-myrepo-wt/memory/
- Start another conversation from either location. The memory from step 4 is never loaded — it exists only in the worktree-specific directory that the read path doesn't check.
Claude Model
Opus
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.92 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
Related issues (but only regarding the "read" part, not the "write":)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗