[BUG] Claude ignores working directory from <env> and uses hardcoded absolute paths to wrong directories
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?
Claude consistently ignores the working directory provided in <env> and instead uses hardcoded absolute paths to directories outside the current project, despite:
- Clear working directory in <env>
- Explicit project CLAUDE.md instructions stating "ALWAYS use working directory from <env> as base"
- Multiple user corrections during the session
What Should Happen?
Expected Behavior (worked in previous versions):
- Claude respects <env> working directory
- Uses relative paths from working directory
- Only works in the specified project directory
Error Messages/Logs
Actual Behavior (regression in current version):
- Claude uses hardcoded absolute paths like /home/user/projects/system_a/...
- Edits files in WRONG directory (system_b) instead of current working directory (system_a)
- Continues this pattern even after corrections
- Ignores project-specific CLAUDE.md instructions
Steps to Reproduce
- Session starts in: /home/user/projects/system_a/templates
- <env> clearly shows: Working directory: /home/user/projects/system_a/templates
- Project CLAUDE.md contains:
## Repository Locations
ALWAYS use the working directory from <env> as base:
- Module/feature:
module/feature/(relative from working dir) - Templates:
templates/(relative from working dir)
NEVER use hardcoded paths
- User requests: "fix sorting in grid"
- Claude edits files in BOTH:
- /home/user/projects/system_a/... (correct)
- /home/user/projects/system_b/... (WRONG - different project!)
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
<2.0.1
Claude Code Version
2.0.1
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Concrete Examples from Session:
User repeatedly had to correct:
- "wrong directory again! it's system_a"
- "you edited system_b again! check this"
- "this should be in system_a only!"
- "why do you keep editing both dirs!"
Each time Claude acknowledged but continued the same pattern.
Impact:
- Files edited in wrong project directories
- Wasted time reverting incorrect changes
- User frustration
- Loss of trust in Claude respecting project boundaries
Previous Behavior:
User confirms this never happened in previous Claude versions - this is a regression.
Root Cause (suspected):
Claude appears to be using pattern matching from earlier in conversation instead of actively checking <env> working directory for each operation. It creates a mental model of "these two directories need to be kept in sync" and applies it incorrectly.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗