Preflight Checklist
What's Wrong?
Claude Code encodes project paths by replacing /, -, and _ all with - when creating project directories under ~/.claude/projects/. This is a lossy encoding that can cause different project paths to map to the same directory.
For example:
- /home/user/project/spec-rl/ → -home-user-project-spec-rl
- /home/user/project/spec/rl/ → -home-user-project-spec-rl
Both produce the same encoded directory name, so two different projects would share memory, settings, and CLAUDE.md.
Similarly with underscores:
- /home/user/my_project/ → -home-user-my-project
- /home/user/my-project/ → -home-user-my-project
What Should Happen?
Each unique project path should map to a unique project directory. The encoding should be injective.
Error Messages/Logs
Steps to Reproduce
- mkdir -p ~/test/spec-rl && mkdir -p ~/test/spec/rl
- Run Claude Code in ~/test/spec-rl, save a memory
- Run Claude Code in ~/test/spec/rl
- Both sessions use the same ~/.claude/projects/ directory
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.1.77
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
Possible fix: use a delimiter that doesn't appear in path components,
e.g. encode each segment separately or use double-dash -- as separator
so /home/user/spec-rl → -home--user--spec-rl
vs /home/user/spec/rl → -home--user--spec--rl.
Preflight Checklist
What's Wrong?
Claude Code encodes project paths by replacing
/,-, and_all with-when creating project directories under~/.claude/projects/. This is a lossy encoding that can cause different project paths to map to the same directory.For example:
Both produce the same encoded directory name, so two different projects would share memory, settings, and CLAUDE.md.
Similarly with underscores:
What Should Happen?
Each unique project path should map to a unique project directory. The encoding should be injective.
Error Messages/Logs
Steps to Reproduce
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.1.77
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
Possible fix: use a delimiter that doesn't appear in path components,
e.g. encode each segment separately or use double-dash
--as separatorso
/home/user/spec-rl→-home--user--spec-rlvs
/home/user/spec/rl→-home--user--spec--rl.