[BUG] Duplicate Memory Files Loaded When Working Directory Is Within User Home on Windows
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using Claude Code for VS Code on Windows with a workspace located under the user's home directory (e.g., C:\Users\<username>\Desktop\Projects\), memory files from ~/.claude/ are loaded twice—once as "User" memory and once as "Project" memory—doubling token consumption.
What Should Happen?
Memory files should be loaded once
Error Messages/Logs
Steps to Reproduce
Step 1: Create User memory files
Create the following directory and files:
C:\Users\<your-username>\.claude\CLAUDE.md
C:\Users\<your-username>\.claude\rules\example-rule.md
Example content for CLAUDE.md:
User Instructions
- This is a test memory file
- Contains personal preferences
Example content for rules\example-rule.md:
Example Rule
- Test rule content
Step 2: Open a workspace within your home directory
Open VS Code and select a folder located under your user home directory:
C:\Users\<your-username>\Desktop\Projects\
(or any subfolder under C:\Users\<your-username>\)
Step 3: Start Claude Code
Open Claude Code panel in VS Code (Ctrl+Shift+P → "Claude Code: Open")
Step 4: Run /context command
Type /context in Claude Code chat
Step 5: Observe duplicate memory files
In the output, under "Memory Files" section, you will see the same files listed twice:
Once with Type "User"
Once with Type "Project"
Both entries point to the same physical file (only path casing may differ: C:\Users\ vs c:\Users\).
Step 6: Verify the fix (optional)
Close VS Code, reopen with a workspace on a different drive (e.g., D:\Projects\), run /context again—duplicates will be gone.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.12
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Non-interactive/CI environment
Additional Information
Root Cause Analysis
Claude Code recursively searches for memory files from the current working directory up to (but not including) the root. When the workspace is under C:\Users\<username>\, the ~/.claude/ folder is discovered both:
As User memory (from ~/.claude/)
As Project memory (from recursive parent directory search)
Suggested Fix
Deduplicate memory files by canonical path before loading, or skip loading Project memory when it resolves to the same physical location as User memory.
Showing cached comments. Read the full discussion on GitHub ↗
4 Comments
Found 2 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Duplicate memory files on Windows: user
~/.claude/files load twice when project is under home directoryWhen a project lives under
~(e.g.,~/dev/myproject/), all~/.claude/CLAUDE.mdand~/.claude/rules/**/*.mdfiles load as both "User" and "Project" scope due to a Windows drive letter case mismatch:17 files duplicated = ~12k tokens wasted per conversation.
Reproduction: Any project under
~on Windows./contextcommand shows every~/.claude/memory file listed twice with different scopes and drive letter casing.What I tested (none worked):
| Attempt | Result |
|---------|--------|
| Remove
@rules/imports from~/.claude/CLAUDE.md| Rules still auto-loaded from both scopes || Empty
~/dev/.claude/directory as traversal boundary | No effect || Empty
~/dev/.claude/CLAUDE.mdas boundary | No effect ||
.claude/rules/in intermediate or project directories | No effect |Existing dedup precedent: Skills already have dedup logic -- skill loading logs show
"Skipping duplicate skill ... same file as earlier source"when the same skill resolves from multiple sources. Memory files (CLAUDE.md, rules/) have no equivalent check.Suggested fix: Extend the skill dedup logic to memory file loading. Normalize paths (including Windows drive letter case) before comparison. When user-scope and project-scope resolve to the same file on disk, load it once.
Related: #8625 (same root cause)
Environment: Windows 11, Claude Code VSCode extension, Claude Opus 4.5
Still reproducing on v2.1.34 (Windows 11, VS Code extension). Adding data on the token cost impact since this is a silent performance drain.
My setup: Workspace at
C:\Users\<user>\general-claude, memory junction atworkspace/memory/->~/.claude/projects/<hash>/memory/. MEMORY.md is 128 lines / 4,702 chars.What happens: MEMORY.md appears twice in every system prompt:
claudeMdblock, labeled "user's private global instructions for all projects" (wrong label, wrong loader)Measured cost: ~1,176 duplicate tokens per API call. Over a 20-turn session that is ~23k wasted input tokens. Over a full workday it compounds significantly.
The label is also wrong: The claudeMd copy says "user's private global instructions for all projects" but the file is project-specific memory, not global instructions.
Workarounds tested (none work):
claudeMdExcludesoption covers this pathCLAUDE_CODE_DISABLE_AUTO_MEMORY=1removes one copy but disables the entire auto-memory feature~/.claude/)Suggested fix: Deduplicate by resolved canonical path (
fs.realpathSync) before injecting into context. Alternatively, stop the claudeMd traversal at the~/.claude/projects/boundary since those files are already handled by auto-memory.Fixed in 2.1.47 — changelog: "Windows: Fixed the same CLAUDE.md file being loaded twice when drive letter casing differs between paths" (https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md). That matches the diagnosis in this thread (the user-level and project-level copies differed only by
C:vsc:); the last report here was on 2.1.34, before the fix.Closing — reply with your version if
/memoryor/contextstill lists the same file twice and this can be reopened.🤖 Generated with Claude Code