[BUG] CLAUDE_PROJECT_DIR in a worktree with claude -w is not the worktree folder.

Resolved 💬 2 comments Opened Feb 21, 2026 by netram-netizen Closed Mar 21, 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?

I was creating a new hook with Claude in a worktree via claude -w. The command defined in settings.json looked like "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/stop-hook.sh".

What I get is:

Stop hook error: Failed with non-blocking status code: /bin/sh: /path/to/project/.claude/hooks/stop-hook.sh: No such file or directory

What Should Happen?

I would expect $CLAUDE_PROJECT_DIR to be /path/to/project/.claude/worktrees/worktree-name

Error Messages/Logs

Ran 1 stop hook (ctrl+o to expand)
⎿  Stop hook error: Failed with non-blocking status code: /bin/sh: /path/to/project/.claude/hooks/stop-hook.sh: No such file or directory

Steps to Reproduce

  1. Start Claude with claude -w
  2. In the worktree create a script for a hook. E.g. .claude/hooks/stop-hook.sh
  3. In the worktree define the hook in settings.json:

``json
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/stop-hook.sh",
"statusMessage": "Checking if Claude can stop..."
}
]
}
],
}
}
``

  1. Chat with the Claude in the worktree
  2. See

``shell
Ran 1 stop hook (ctrl+o to expand)
⎿  Stop hook error: Failed with non-blocking status code: /bin/sh: /path/to/project/.claude/hooks/stop-hook.sh: No such file or directory
``

Claude Model

None

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.49

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

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