[BUG] Memory file loaded twice when $HOME is a symlink

Resolved 💬 4 comments Opened Feb 19, 2026 by degraw4 Closed Mar 20, 2026

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?

## Describe the bug

When the user's home directory ($HOME) is a symlink to another path, ~/.claude/CLAUDE.md is loaded twice in the memory files — once via the symlink path and once via the
resolved real path. Both entries appear in /context output.

## Environment

  • Platform: Linux

## To Reproduce

  1. Set up $HOME as a symlink, e.g.:

/home/username -> /data00/home/username

  1. Place a CLAUDE.md at ~/.claude/CLAUDE.md
  2. Open Claude Code and run /context, observe the Memory files section

## Expected behavior

The file appears once in /context.

## Actual behavior

The file appears twice:

  • ~/.claude/CLAUDE.md (symlink path)
  • /data00/home/username/.claude/CLAUDE.md (resolved real path)

Both entries share the same inode, confirming they are the same physical file.

## Root cause hypothesis

Claude Code collects memory file paths using both the $HOME-expanded path and the readlink -f-resolved real path, without deduplicating by inode or canonical path before
loading.

## Impact

Duplicated file wastes token budget (~1k extra tokens per affected file per session).

What Should Happen?

The file should appear only once in the Memory files list under /context.
Claude Code should deduplicate memory files by inode or canonical (realpath-resolved) path, so that symlinked paths pointing to the same physical file are not loaded multiple times.

Error Messages/Logs

Steps to Reproduce

  1. On Linux, set up $HOME as a symlink to another path:

$ ls -la /home/username
lrwxrwxrwx root /home/username -> /data00/home/username

  1. Confirm $HOME resolves to the symlink path:

$ echo $HOME
/home/username

  1. Place a CLAUDE.md file at ~/.claude/CLAUDE.md (i.e., /home/username/.claude/CLAUDE.md)
  1. Open Claude Code in any project directory.
  1. Run /context and observe the "Memory files" section.

Expected: ~/.claude/CLAUDE.md appears once.
Actual: The file appears twice:

  • ~/.claude/CLAUDE.md
  • /data00/home/username/.claude/CLAUDE.md

Both entries point to the same inode, confirmed via:
$ stat /home/username/.claude/CLAUDE.md
Inode: 18350327
$ stat /data00/home/username/.claude/CLAUDE.md
Inode: 18350327

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

2.1.45

Claude Code Version

2.1.45

Platform

Other

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

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