[FEATURE] Preserve symlink path for CLAUDE.md parent directory lookup
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When Claude Code starts from a symlinked directory, it resolves the symlink to the real path before determining which parent CLAUDE.md files to load. This prevents CLAUDE.md files in parent directories of the symlink from being discovered.
I maintain a multi-repo workspace:
my-workspace/
├── CLAUDE.md # General practices: git conventions, model selection,
│ # cross-repo coordination, pre-modification checklist
├── backend/ # Backend repo (symlink → ~/repos/frontend)
│ └── CLAUDE.md # Backend-specific guidance
└── frontend/ # Frontend repo (symlink → ~/repos/frontend)
└── CLAUDE.md # Frontend-specific guidance
Why symlinks? Each repo has its own git history and may be used independently. The workspace aggregates them for coordinated work. There are other repos in the ~/repos directory that I do not want Claude to have access to.
Desired workflows:
| Starting directory | CLAUDE.md files loaded | Use case |
|--------------------|------------------------|----------|
| my-workspace/ | workspace + both repos | Cross-repo work |
| my-workspace/frontend/ | workspace + frontend | Frontend-only with shared practices |
| my-workspace/backend/ | workspace + backend | Backend-only with shared practices |
Current problem: Starting from my-workspace/frontend/ only loads frontend/CLAUDE.md because the symlink resolves to ~/repos/frontend, losing the workspace parent.
The workspace CLAUDE.md contains guidance that applies to all work (git practices, commit attribution, model selection for sub-agents). Without it, I must either:
- Duplicate content in every repo's CLAUDE.md (maintenance burden, drift risk)
- Always start from workspace root even for single-repo work
Proposed Solution
When determining the working directory for CLAUDE.md parent traversal, use the path as invoked (preserving symlinks) rather than the resolved real path.
Evidence that the symlink path is available: running pwd from within Claude returns the symlink-preserving path (my-workspace/frontend/), while the environment metadata shows the resolved path (~/repos/frontend). The CLAUDE.md lookup should use the former.
Alternative Solutions
- Duplicate shared CLAUDE.md content into each repo - creates maintenance burden and drift risk
- Always start from workspace root - loses benefit of repo-specific working directory
- Add "Session Start" instructions in repo CLAUDE.md to manually load parent - doesn't work because Claude doesn't execute instructions before loading CLAUDE.md files
Priority
Medium - Would be very helpful
Feature Category
Configuration and settings
Use Case Example
(Combined in Problem Statement).
Additional Context
Related issues:
- #764 - Symlink resolution for ~/.claude directory
- #12962 - Parent directory traversal for settings.json
- #14015 - workingDirectory setting (closed as duplicate of #12962)
Current behavior:
- Environment metadata shows: ~/repos/frontend (resolved path)
- Shell
pwdreturns: my-workspace/frontend (symlink path) - CLAUDE.md lookup searches parents of resolved path
- Does NOT find my-workspace/CLAUDE.md
Expected behavior:
- CLAUDE.md lookup should use symlink-preserving path (matching pwd)
- my-workspace/CLAUDE.md should be discovered and loaded
(This issue was written with Claude's assistance)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗