Bash tool unnecessarily adds -C <dir> flags when cwd already matches target
Description
Claude systematically adds -C <dir> (or equivalent directory flags like make's -directory) to shell commands even when the current working directory already matches the target. This adds noise to every command invocation and triggers unnecessary permission prompts when the user has directory-specific allow rules.
Root cause
The Bash tool system prompt includes:
"Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of cd."
Claude interprets "use absolute paths" as "always explicitly specify the target directory," which manifests as -C <dir> on git, make, and any other tool that accepts a directory flag — even when the cwd is already correct.
Examples
When working in /home/user/project:
| Expected | Actual |
|---|---|
| git status | git -C /home/user/project status |
| make -j8 | make -C /home/user/project -j8 |
Suggested fix
Qualify the system prompt instruction, e.g.:
"Try to maintain your current working directory throughout the session by using absolute paths for file arguments. Do not add directory flags (-C,-directory, etc.) to commands when the working directory already matches the target."
Workaround
Adding an explicit override in CLAUDE.md:
- Shell commands: when the current working directory is already
the target directory, run the command directly — do not pass
`-C <dir>` to git, `-C` or `-directory` to make, or any
equivalent flag to other tools. Do not prefix with
`cd <dir> &&` either; that triggers an unnecessary permission
prompt for no benefit. Only specify an alternate directory
when the command genuinely needs to run somewhere else.This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗