[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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗