[BUG] Duplicate Memory Files Loaded When Working Directory Is Within User Home on Windows

Status Fixed / completed
Reported on v2.1.12
Maintainer reply ✓ Yes — bcherny
Activity 5 comments · opened Jan 20, 2026 · closed Aug 19, 2026
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.

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.

View original on GitHub ↗

4 Comments

github-actions[bot] · 8 months ago

Found 2 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/13288
  2. https://github.com/anthropics/claude-code/issues/18942

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

Colby-TC · 8 months ago

Duplicate memory files on Windows: user ~/.claude/ files load twice when project is under home directory

When a project lives under ~ (e.g., ~/dev/myproject/), all ~/.claude/CLAUDE.md and ~/.claude/rules/**/*.md files load as both "User" and "Project" scope due to a Windows drive letter case mismatch:

User:    C:\Users\Colby\.claude\CLAUDE.md    (uppercase C:)
Project: c:\Users\Colby\.claude\CLAUDE.md    (lowercase c:)

17 files duplicated = ~12k tokens wasted per conversation.

Reproduction: Any project under ~ on Windows. /context command 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.md as 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

voyagi · 7 months ago

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 at workspace/memory/ -> ~/.claude/projects/<hash>/memory/. MEMORY.md is 128 lines / 4,702 chars.

What happens: MEMORY.md appears twice in every system prompt:

  1. Auto-memory section (expected, first 200 lines)
  2. claudeMd block, 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):

  • No claudeMdExcludes option covers this path
  • CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 removes one copy but disables the entire auto-memory feature
  • Removing the workspace junction doesn't help (parent-dir walk still reaches ~/.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.

bcherny collaborator · 1 month ago

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: vs c:); the last report here was on 2.1.34, before the fix.

Closing — reply with your version if /memory or /context still lists the same file twice and this can be reopened.

🤖 Generated with Claude Code

Showing cached comments. Read the full discussion on GitHub ↗