[Bug] Hook Command: Incorrect Path Resolution with $CLAUDE_PROJECT_DIR

Resolved 💬 6 comments Opened Oct 6, 2025 by KJ7LNW Closed Jan 8, 2026

Bug Description
Issue: Hook command fails to resolve script path when Claude's working directory changes to a subdirectory

Hook Configuration:
"command": "npx tsx $CLAUDE_PROJECT_DIR/scripts/claude-hooks.ts"

Error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module
'/path/to/project/apps/app-name/apps/app-name/scripts/claude-hooks.ts'

Expected Behavior:
$CLAUDE_PROJECT_DIR should resolve to /path/to/project, making the full path:
/path/to/project/scripts/claude-hooks.ts

Actual Behavior:
The path is being constructed as if $CLAUDE_PROJECT_DIR wasn't expanded, and instead scripts/claude-hooks.ts
is being resolved relative to the current working directory:
/path/to/project/apps/app-name/apps/app-name/scripts/claude-hooks.ts

Additional Context:

  • The working directory appears to have a duplicated path segment: apps/app-name/apps/app-name/
  • This suggests either $CLAUDE_PROJECT_DIR is not being expanded by the shell, or npx tsx is not receiving the

expanded variable

  • Related to issue #3583 about relative hook paths not being resolved to absolute paths when cwd changes

Environment Info

  • Platform: linux
  • Terminal: vte-based
  • Version: 2.0.8
  • Feedback ID: b3c37a96-9481-496b-b2da-6c951f7a12bd

Errors

[]

View original on GitHub ↗

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