Claude Code should warn when primary and additional working directories point to different project locations
Description
When Claude Code is invoked with a primary working directory that differs from the additional working directories, it may silently work on the wrong project without warning. This can lead to unintended file modifications, potential exposure of sensitive information, or work being done in an outdated/incorrect codebase.
Scenario
User's environment context showed:
Primary working directory: /path/to/project-name
Additional working directories:
- /different/path/to/project-name/frontend/src/components/layout
- /different/path/to/project-name/frontend/src/hooks
- /different/path/to/project-name/frontend/src/components/analysis
... etc
These were two separate projects with similar structures but at different locations. Claude defaulted to the primary working directory and made extensive edits there, while the user was running their dev server from the other location. The mismatch was only discovered after multiple failed attempts to see changes reflected.
Security/Privacy Concern
This behavior could lead to:
- Reading/exposing credentials or API keys from unintended projects
- Committing sensitive data to the wrong repository
- Leaking code or configuration between projects
- Modifying files in a project the user didn't intend
Suggested Improvement
- Detect mismatch: When primary and additional working directories have different root paths, warn the user
- Prompt for clarification: Ask which directory is the active project before making changes
- Visual indicator: Show the active working directory prominently when there's ambiguity
Environment
- Platform: Linux (WSL2)
- Claude Code CLI
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗