claude-code - 💡(How to fix) Fix [BUG] macOS auto-memory scoped to home-dir hash, ignoring cwd-hash dirs [2 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#55676Fetched 2026-05-03 04:47:21
View on GitHub
Comments
2
Participants
1
Timeline
7
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×2closed ×1

Code Example

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

---

cd ~/utopia && claude
RAW_BUFFERClick to expand / collapse

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

  1. Pre-create a memory file outside CC at the cwd-specific path:

    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
  2. Start CC at the matching cwd:

    cd ~/utopia && claude
  3. Without invoking /recall, ask Claude: "What's the festival mascot for the sync test?"

  4. Expected: "Gertrude" (loaded from MEMORY.md at the cwd-hash path)

  5. 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 ~/utopia cwd)

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

  1. Project registration: Adding /Users/leofloa/utopia (and all life-domain cwds) as entries under the projects key in ~/.claude.json, mirroring the Linux machine's structure. No effect.
  2. CC version: Tested on 2.1.118 (brew) and upgraded to 2.1.126 (native). Same behavior on both.
  3. Permissions: Both the cwd-hash dir and the home-hash dir have identical 755/644 permissions on macOS.
  4. 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.

extent analysis

TL;DR

The issue can be fixed by modifying the slug generation to correctly handle the current working directory (cwd) on macOS, ensuring that the auto-memory is keyed to the cwd instead of the user's HOME directory.

Guidance

  • Investigate the path-normalization or HOME-stripping logic in the slug generation code to identify the bug causing the cwd to be collapsed to the home-dir prefix on macOS.
  • Verify that the cwd variable is being correctly set and passed to the slug generation function when running on macOS.
  • Compare the slug generation code between the Linux and macOS versions to identify any platform-specific differences that may be contributing to the issue.
  • Consider adding logging or debugging statements to the slug generation code to inspect the intermediate values and identify where the collapse to the home-dir prefix is occurring.

Example

No code snippet is provided as the issue description does not include the relevant code sections.

Notes

The issue appears to be specific to macOS and may be related to differences in how the operating system handles path normalization or environment variables. The fact that the issue is reproducible on multiple versions of Claude Code (2.1.118 and 2.1.126) suggests that the problem is not version-specific.

Recommendation

Apply a workaround to modify the slug generation logic to correctly handle the cwd on macOS, such as by using a platform-agnostic path normalization library or by manually constructing the slug using the cwd variable. This will allow per-project memory scoping to function correctly on macOS until a permanent fix can be implemented.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] macOS auto-memory scoped to home-dir hash, ignoring cwd-hash dirs [2 comments, 1 participants]