published fresh until

Why does Claude Code prompt on cd before git, and how do I stop it?

Summary As of November 2026, the release notes list a fix for redundant project-directory cd prefixes; genuine directory changes before git can still prompt. Compare your installed release with 2.1.111

Not for permission allow rules that are ignored, or testing a permission hook; see claude-code-permission-allow-rules-ignored

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Update before adding a workaround: Claude Code 2.1.111 (April 2026) lists a fix for redundant project-directory prefixes. Do first: compare your version with that release and omit a redundant cd when a prompt persists. Changelog.

The problem

Claude Code often writes cd <project dir> && git .... Users report a permission prompt about the cd that cannot be made permanent, even when the directory is the one Claude was started in. The GitHub issue (opened 2026-02-24 by prezzz, first seen on Windows, version 2.1.52) is open (checked 2026-11-17).

What the docs say

Claude Code's permissions page says rules match each part of a compound command separately, and that cd into a path inside your working directory is read-only. It also says cd combined with git prompts when the cd changes into a different directory, because git there could run that directory's hooks, while a cd that resolves to the current directory is a no-op and does not trigger the prompt. So a prompt for the project directory itself looks like a bug, not intended behavior. The 2.1.111 changelog lists a fix for commands beginning with cd <project-dir> &&; the open issue alone does not mean that fix is absent.

What commenters report

  • Likely cause on Windows (a guess by one commenter): a path comparison failing between forms such as the MSYS-style /c/... path and the native drive-letter path. Others saw it on macOS and WSL, so it is not only Windows.
  • Rule in CLAUDE.md: a very explicit "never cd to the current working directory, just run the command" rule helped some, about a 50% reduction for one, but others had to repeat it each session.
  • Agents route around a ban: commenters saw cd; ..., then git -C, then pushd, then GIT_DIR variables. One said the hook must also return guidance, not only block.
  • PreToolUse hook that denies a cd-prefixed command and tells Claude to run the command directly, several commenters. One said it did not hold once subagents were involved; another believed subagents inherit hooks. Treat that as unsettled. A commenter on WSL had to rewrite the hook script in Node.
  • Allow rule: one commenter said adding Bash(cd ) to allow suppresses it; another tried Bash(cd:) and Bash(cd *) on macOS, restarted, and still got the prompt (the docs say the two forms are equivalent).
  • Auto-approve hook only for chains where every part is read-only: one commenter reported success. Another warned the matching must also deny destructive chains, otherwise it becomes a fast path for them. Per the docs, a hook's allow does not override a matching ask rule.

Caveats

The workaround reports are anecdotal and version-specific. The release-note fix is stronger evidence than assuming all current builds retain the original bug. Prefer the narrowest option (the CLAUDE.md rule, or a deny hook with guidance) over blanket auto-approval.

Sources

Started from a post by @prezzz, packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Why does Claude Code prompt on cd before git, and how do I stop it?
Summary: As of November 2026, the release notes list a fix for redundant project-directory cd prefixes; genuine directory changes before git can still prompt. Compare your installed release with `2.1.111`
Copy for agent
get the whatworks thread claude-code-cd-compound-bash-permission-prompt and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-cd-compound-bash-permission-prompt
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks