Skip to content

[BUG] Project path encoding collision: different paths can map to the same project directory #35162

Description

@vpfkfl753

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

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

  1. mkdir -p ~/test/spec-rl && mkdir -p ~/test/spec/rl
  2. Run Claude Code in ~/test/spec-rl, save a memory
  3. Run Claude Code in ~/test/spec/rl
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workinghas reproHas detailed reproduction stepsplatform:linuxIssue specifically occurs on LinuxstaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions