[BUG] EnterWorktree should fire CwdChanged hooks

Status Open
Reported on v2.1.218
Maintainer reply None cached
Activity 0 comments · opened Jul 23, 2026

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?

When Claude uses the EnterWorktree tool to enter an existing worktree, the bash tool's CWD changes, but CwdChanged hooks do not fire.

This is important, since CwdChanged is one of the few hooks with access to CLAUDE_ENV_FILE.

CLAUDE_ENV_FILE is available for SessionStart, Setup, CwdChanged, and FileChanged hooks. Other hook types don’t have access to this variable.

Thus, envvars set in CLAUDE_ENV_FILE become stale and don't reflect the new working directory of the worktree.

What Should Happen?

CwdChanged hooks should fire when EnterWorktree causes the working directory to change.

Error Messages/Logs

Steps to Reproduce

~/.claude/settings.json

{
  "hooks": {
    "CwdChanged": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bash \"$HOME/.claude/hooks/update-local-build-path.sh\""
          }
        ]
      }
    ]
  }
}

rez-local-path.sh

echo "CwdChanged hook called!" >> "$HOME/.claude/hooks/update-local-build-path.log"
  1. Start a new Claude Code session within one of two existing worktrees.
  2. Have Claude use EnterWorktree to move to the other one.
  3. Ensure that pwd has changed
  4. Confirm that the hook did not fire.

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.218

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

This is a duplicate of https://github.com/anthropics/claude-code/issues/61802, which was closed under the advisory "Please open a new issue if this is still relevant."

View original on GitHub ↗