[BUG] Auto-memory reads and writes resolve different paths for git worktrees, causing silent memory divergence

Resolved 💬 2 comments Opened Apr 6, 2026 by ayal-ivix Closed May 16, 2026

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:

  1. 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

  1. 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/

  1. 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/).

  1. In the worktree conversation, ask it to remember something new (e.g., "remember that I use pytest, not unittest").
  2. Observe that the new memory is written to a different path:

~/.claude/projects/-tmp-myrepo-wt/memory/

  1. 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":)

View original on GitHub ↗

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