[BUG] macOS auto-memory scoped to home-dir hash, ignoring cwd-hash dirs
Environment
- Claude Code version: 2.1.118 (brew cask) AND 2.1.126 (native installer at ~/.local/bin/claude). Reproduced on both.
- macOS: Sequoia (Darwin 24.3.0 arm64), Apple Silicon Mac mini
- Cross-reference Linux: Same architecture works correctly on Linux (Ubuntu 24.04 / Claude Code 2.1.122 native installer)
Expected behavior (per docs)
Auto-memory is cwd-keyed: when CC runs at <cwd>, it reads/writes ~/.claude/projects/<cwd-with-/-replaced-by-->/memory/. Different cwds get different memory dirs. Documented as platform-agnostic.
Actual behavior on macOS
Auto-memory is keyed only to the user's HOME-dir hash, regardless of cwd. CC at /Users/leofloa/utopia, /Users/leofloa/medumio, or ~ all read/write the SAME dir: ~/.claude/projects/-Users-leofloa/memory/. The cwd-specific hash dirs are never used for memory (only for session JSONLs).
Reproduction
- Pre-create a memory file outside CC at the cwd-specific path:
```bash
mkdir -p ~/.claude/projects/-Users-leofloa-utopia/memory
cat > ~/.claude/projects/-Users-leofloa-utopia/memory/MEMORY.md <<'EOM'
- Test sentinel: the festival mascot is a gardener gnome named Gertrude
EOM
```
- Start CC at the matching cwd:
``bash``
cd ~/utopia && claude
- Without invoking /recall, ask Claude: "What's the festival mascot for the sync test?"
- Expected: "Gertrude" (loaded from MEMORY.md at the cwd-hash path)
- Actual: "I don't have any record of a Utopia festival mascot — nothing in MEMORY.md, the Utopia CLAUDE.md, or the agent vault references one."
Confirming via CC's own write path
Step 1: at /Users/leofloa/utopia, prompt Claude remember this: utopia mascot is Gertrude. save to memory.
Step 2: Claude responds "Saved to utopia_sync_test_mascot.md and indexed under Project in MEMORY.md."
Step 3: Check filesystem:
- File DOES NOT appear at
~/.claude/projects/-Users-leofloa-utopia/memory/(the cwd-hash dir, where it should land) - File DOES appear at
~/.claude/projects/-Users-leofloa/memory/utopia_sync_test_mascot.md(the home-dir, where it should NOT land for a~/utopiacwd)
So even when CC itself writes (the canonical write path), it goes to home-dir hash on macOS.
Cross-platform comparison
On Linux at /home/vbox/medumio, CC correctly uses /home/vbox/.claude/projects/-home-vbox-medumio/memory/. Past session JSONLs at ~/.claude/projects/-home-vbox-medumio/*.jsonl reference loading the cwd-hash path's feedback_*.md files dozens of times. Linux behavior matches the docs.
Things ruled out
- Project registration: Adding
/Users/leofloa/utopia(and all life-domain cwds) as entries under theprojectskey in~/.claude.json, mirroring the Linux machine's structure. No effect. - CC version: Tested on 2.1.118 (brew) and upgraded to 2.1.126 (native). Same behavior on both.
- Permissions: Both the cwd-hash dir and the home-hash dir have identical 755/644 permissions on macOS.
- File format: MEMORY.md content is valid markdown matching the format that loads correctly on Linux.
Impact
This breaks per-project memory scoping on macOS — all projects share one memory blob, mixing unrelated domain context. For users with multiple distinct project areas under one HOME (typical), it makes auto-memory effectively unusable as a per-context tool.
Hypothesis
Likely a path-normalization or HOME-stripping bug in macOS-specific slug generation. The slug encoding (replace / with -) appears to collapse the cwd to the home-dir prefix on macOS only.
3 Comments
Update: project-level workaround tested, also doesn't work
After filing this, tried a workaround using project-level
.claude/settings.jsonto overrideautoMemoryDirectoryper-cwd. The setting does work at user-level (~/.claude/settings.json) — verified by settingautoMemoryDirectory: ~/.claude/memory-test-tildethere and confirming Claude Code wrote a memory file at the configured path. But at project level it's silently ignored.Reproduction
``
bash
``cd ~/medumio
mkdir -p .claude
cat > .claude/settings.json <<'JSON'
{"autoMemoryDirectory": "~/.claude/memory-medumio"}
JSON
mkdir -p ~/.claude/memory-medumio
``
bash
``claude
> save to memory: testing project-level settings — sentinel
CherryPie~/.claude/projects/-Users-leofloa/memory/project_settings_test_sentinel.md(the home-dir hash dir, the same broken location from the original bug), not at~/.claude/memory-medumio/as the project-level setting requested.Implication
The two combined behaviors mean per-cwd memory routing is fully broken on macOS: the default cwd-hash mechanism doesn't work (original bug), and the per-project override mechanism is also silently ignored. Users with multiple distinct project areas under one HOME effectively can't keep memories scoped per-project.
Tested versions
~/.local/bin/claude)Both produce the same behavior. Linux at the same versions correctly honors both cwd-hash AND project-level settings — confirmed empirically.
Question (not requesting an answer here, just for issue completeness)
Is project-level
autoMemoryDirectoryintentionally not honored as a security measure (preventing untrusted project dirs from redirecting memory)? If so, that warrants a doc note. If not, this is a second related bug.Closing — this is not a bug, it's expected behavior I misunderstood.
Per the official memory docs: "Each project gets its own memory directory at
~/.claude/projects/<project>/memory/. The<project>path is derived from the git repository, so all worktrees and subdirectories within the same repo share one auto memory directory."What I observed on macOS was correct:
/Users/leofloa/medumio,/Users/leofloa/utopia, etc. were all subdirectories of one git repository (a parent vbox repo containing all life domains). Claude Code correctly derived their project root as the parent repo and routed memory to the parent's slug dir. I just misread it as a per-cwd hash.Verified the same behavior on Linux (
claude -pat/home/vbox/medumiowrites to~/.claude/projects/-home-vbox/memory/, the vbox repo root, not-home-vbox-medumio/memory/which only exists as legacy from when medumio was a separate repo before May 1, 2026).So both platforms behave per docs. No bug. Apologies for the noise.
The earlier comment about project-level
autoMemoryDirectorynot being honored at project scope (only user scope) — separate concern, but if you'd like that as its own report I can file it cleanly.This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.