Path Encoding Collision: Directories with dashes conflict with path separators

Resolved 💬 4 comments Opened Sep 2, 2025 by theotheo Closed Jan 9, 2026

Path Encoding Collision: Directories with dashes conflict with path separators

Problem Description

Claude Code's conversation history storage uses a path encoding scheme that replaces forward slashes (/) with dashes (-) when creating directory names in ~/.claude/projects/. This creates naming collisions between:

  • Directories containing dashes in their names (e.g., data-analysis)
  • Nested directory structures (e.g., data/analysis)

Both paths encode to the same string: -home-username-data-analysis

Reproduction Steps

  1. Create two directories with colliding names:
mkdir -p ~/test/data-analysis    # Contains dash
mkdir -p ~/test/data/analysis    # Nested structure
  1. Start Claude Code sessions in both directories:
cd ~/test/data-analysis
claude "test session 1"

cd ~/test/data/analysis  
claude "test session 2"
  1. Check the encoded directories:
ls ~/.claude/projects/*data-analysis*
# Both sessions write to: -home-username-test-data-analysis
  1. Running claude --continue in either directory may load the wrong session.

Current Behavior

# Current encoding (problematic)
/home/user/my-project     → -home-user-my-project
/home/user/my/project     → -home-user-my-project  # COLLISION!

/home/user/data-analysis  → -home-user-data-analysis
/home/user/data/analysis  → -home-user-data-analysis  # COLLISION!

Suggested Solution

Use URL-encoding for path separators while preserving dashes in directory names:

/home/user/my-project     → -home-user-my-project      # dash preserved
/home/user/my/project     → -home-user-my%2Fproject    # %2F for separator

This maintains backward compatibility for paths without collisions while fixing the collision issue.

Workaround (Current)

Users should avoid using dashes in directory names when working with Claude Code to prevent collisions.

View original on GitHub ↗

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