Non-ASCII project paths collide in ~/.claude/projects/, silently sharing memory and transcripts between different projects
Project directory paths are encoded lossily into ~/.claude/projects/ folder names: every non-alphanumeric character becomes a single -. For ASCII paths this is effectively injective, but for CJK (and any non-ASCII) paths it is not — two sibling directories whose names have the same character count collide onto one folder, and Claude Code then silently shares that folder's memory/ and transcripts between two unrelated projects. There is no warning.
A second consequence of deriving the folder name from the path: renaming a project directory silently orphans its memory. The next session computes a new folder name, finds nothing, and starts with empty memory. The old memory is still on disk but unreachable, and the user has to work out the encoding rule by hand to migrate it.
Reproduction
mkdir -p ~/work/新聞 ~/work/暫存 # two different projects, both 2 CJK chars
cd ~/work/新聞 && claude # let it write something to memory
cd ~/work/暫存 && claude # let it write something to memory
ls ~/.claude/projects/ | grep -- '-work-'
Both land in the same folder: -Users-<user>-work---.
Rename case:
mv ~/work/新聞 ~/work/news
cd ~/work/news && claude # memory is empty; the old folder is orphaned
Observed mapping
| Real path | Encoded folder |
|---|---|
| ~/Developer/ai-updates | -Users-<user>-Developer-ai-updates |
| ~/Developer/暫存 (2 chars) | -Users-<user>-Developer--- |
| ~/Developer/新聞 (2 chars) | -Users-<user>-Developer--- ← same |
| ~/Developer/碳排放 (3 chars) | -Users-<user>-Developer---- |
| ~/Developer/扣的白話文 (5 chars) | -Users-<user>-Developer------ |
Any two sibling directories with the same number of non-ASCII characters collide. The same is true for ASCII names differing only in punctuation (my-proj / my_proj / my.proj).
Impact
- Memory files from unrelated projects merge into one
memory/directory and are loaded into the wrong project's context. - Transcripts merge, so
--resumeand session listings show another project's sessions. - Both happen silently — there is no error, and the symptom (Claude "remembering" unrelated facts) is hard to trace back to the cause.
- Renaming a project directory loses its memory unless the user manually moves the folder and correctly reproduces the encoding.
On my machine one such folder holds 716 messages and 2 memory files from ~/Developer/暫存; a sibling ~/Developer/新聞 maps to the identical name and would merge into it on first use.
Suggested fix
Any of these would remove the ambiguity:
- Percent-encode or hex-escape non-alphanumeric bytes instead of collapsing them to
-, so the mapping is reversible. - Keep the readable folder name but append a short hash of the absolute path (e.g.
-Users-me-Developer---.a1b2c3d4). - Store the real absolute path in a metadata file inside the project folder and resolve by that rather than by name — this would also make renames migratable, and a
claude migrate-project <old> <new>command could then exist.
Option 3 additionally fixes the rename case, which options 1 and 2 do not.
Related
- #37562 —
statusLine not displayed when CWD contains non-ASCII (Japanese) characters(closed). Same family: non-ASCII cwd handling.
Environment
- Claude Code 2.1.259
- macOS 26.7 (arm64)
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗