-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Description
Bug Description
When using Windows junction links (mklink /J) to create multiple symlinks pointing to the same .claude directory, Claude Code loads the global CLAUDE.md file multiple times — once for each junction link path — instead of deduplicating by real path.
Environment
- Claude Code version: 2.1.45
- Subscription: Max 5
- OS: Windows 10
- Terminal: Windows Terminal
Setup
I have two junction links both pointing to the same physical directory:
C:\Users\Tony\.claude → D:\Tony\ubuntu_settings\.claude\ (mklink /J)
D:\Tony\.claude → D:\Tony\ubuntu_settings\.claude\ (mklink /J)
Both symlinks resolve to the same underlying directory D:\Tony\ubuntu_settings\.claude.
Observed Behavior
Running /context shows the global CLAUDE.md loaded twice, consuming ~20k tokens:
Memory files
└ C:\Users\Tony\.claude\CLAUDE.md: 10.1k tokens
└ D:\Tony\.claude\CLAUDE.md: 10.1k tokens
Expected Behavior
Claude Code should resolve junction links / symlinks to their real path before loading memory files. Duplicate real paths should only be loaded once:
Memory files
└ D:\Tony\ubuntu_settings\.claude\CLAUDE.md: 10.1k tokens
Impact
- ~10k tokens wasted per conversation due to duplicate loading
- In a 200k context window, this represents ~5% waste from a single duplicated file
- Users with junction links on Windows are silently penalized
Suggested Fix
Before loading CLAUDE.md files, resolve each candidate path to its real/canonical path (e.g., using fs.realpathSync on Node.js). Deduplicate by real path before loading.
Workaround
None currently available — removing one of the junction links would break other tooling that depends on the standard C:\Users\Tony\.claude location.