Project key inconsistency: spaces in directory names produce two different project keys across versions

Resolved 💬 3 comments Opened Mar 23, 2026 by Nick-Supira Closed Mar 27, 2026

Description

When a working directory path contains spaces (e.g., C:\Users\user\Drift Analysis), Claude Code creates two different project keys under ~/.claude/projects/:

  1. C--Users-user-WorkSummary-NOTES-Drift Analysis (space preserved) — created by older versions
  2. C--Users-user-WorkSummary-NOTES-Drift-Analysis (space replaced with hyphen) — created by current version (2.1.81)

This causes memory files and session data to be silently lost on upgrade, because the new key doesn't find files stored under the old key.

Root cause

The UM function in cli.js uses:

A.replace(/[^a-zA-Z0-9]/g, "-")

This replaces ALL non-alphanumeric characters (including spaces) with hyphens. An earlier version likely used a narrower regex that only replaced path separators (/, \, :), preserving spaces.

Impact

  • Memory files stored under the old project key are invisible to sessions using the new key
  • Users with spaces in their directory paths silently lose all project-specific memory on upgrade
  • No migration or warning is provided

Workaround

Create a directory junction from the hyphenated key to the space-preserving key:

New-Item -ItemType Junction -Path "$env:USERPROFILE\.claude\projects\<hyphenated-key>\memory" -Target "$env:USERPROFILE\.claude\projects\<space-key>\memory" -Force

Suggested fix

Either:

  1. Migrate old project keys to the new format on first access
  2. Check both key formats when looking up project data
  3. Use a stable hashing scheme that doesn't change between versions

Environment

  • Claude Code version: 2.1.81
  • OS: Windows 11 Enterprise 10.0.26100
  • Shell: Git Bash

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗