Claude Code should warn when primary and additional working directories point to different project locations

Resolved 💬 3 comments Opened Feb 10, 2026 by techdozor Closed Feb 14, 2026

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

  1. Detect mismatch: When primary and additional working directories have different root paths, warn the user
  2. Prompt for clarification: Ask which directory is the active project before making changes
  3. Visual indicator: Show the active working directory prominently when there's ambiguity

Environment

  • Platform: Linux (WSL2)
  • Claude Code CLI

View original on GitHub ↗

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