[BUG] Project slug encoding replaces all non-alphanumeric characters with "-", causing guaranteed path collisions
Preflight Checklist
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
- [x] I have searched existing issues and this hasn't been reported yet
What's Wrong?
Claude Code replaces all non-alphanumeric characters (including _ - .
and all non-ASCII characters) with a single - when generating the project
slug, causing different directory names to resolve to the same slug.
The function OVK / oU8 applies this regex:
``js``
path.replace(/[^a-zA-Z0-9]/g, "-")
If a character is in a-z A-Z 0-9 → keep it. Otherwise → replace with -.
### Collision case 1: ASCII separators
````
E:\MatLab_HomeWork → E--MatLab-HomeWork
E:\MatLab-HomeWork → E--MatLab-HomeWork ← same slug
E:\MatLab.HomeWork → E--MatLab-HomeWork ← same slug
_ - . are all outside [a-zA-Z0-9], so they all become - and are
indistinguishable from each other.
### Collision case 2: non-ASCII characters
````
D:\桌面\资料\matlab综合 → D--------matlab--
D:\其他\目录\matlab内容 → D--------matlab-- ← same slug
Each Chinese character becomes exactly one -, retaining no identity.
Two paths with the same number of non-ASCII characters in the same
positions will always collide.
## Steps to reproduce
- Create two directories, e.g.
E:\test_v1andE:\test-v1 - Open Claude Code in each directory
- Observe they share the same project slug, causing session history and
memory to leak across directories
## Expected behavior
_, -, and . should produce distinct slugs. Non-ASCII characters
should be encoded in a way that preserves distinguishable information.
## Environment
- OS: Windows 11
- Claude Code version: 2.1.153
## Additional context
Same root cause as issue #40946.
What Should Happen?
Different directory paths should produce different project slugs. Specifically:
_,-, and.in path names should remain distinct in the slug rather
than all collapsing to the same character
- Non-ASCII characters should be encoded in a lossless way (e.g., URL-style
percent encoding or base36 encoding of codepoints), so that two paths
containing different non-ASCII characters do not accidentally collide
Error Messages/Logs
Steps to Reproduce
1.Open a terminal and create two directories with names differing only
by _ vs -:
mkdir E:\tsa_demo
mkdir E:\tsa-demo
- Navigate to the first directory and start Claude Code:
cd E:\tsa_demo
claude
- Type a message (e.g. "hello"), then exit Claude Code.
- Navigate to the second directory and start Claude Code with
--continue:
cd E:\tsa-demo
claude -c
- Observe that
claude -cresumes the conversation from step 3 — it
treats both directories as the same project.
- Optionally, verify the slug collision by checking the project storage:
ls ~/.claude/projects/
# Both directories map to the single slug: E--tsa-demo
Claude Model
Other
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
Claude Code version: 2.1.153
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗