Skip to content

fix(hooks): quote ${CLAUDE_PLUGIN_ROOT} so hooks work when the install path has spaces - #54

Merged
Galaxy-Dawn merged 1 commit into
Galaxy-Dawn:mainfrom
hotungchang:fix/quote-hook-plugin-root
Oct 19, 2026
Merged

Galaxy-Dawn merged 1 commit into
Galaxy-Dawn:mainfrom
hotungchang:fix/quote-hook-plugin-root

Conversation

@hotungchang

Copy link
Copy Markdown
Contributor

Problem

Every command in hooks/hooks.json passes an unquoted plugin root to node:

"command": "node ${CLAUDE_PLUGIN_ROOT}/hooks/security-guard.js"

When the plugin is installed under a path with spaces (common on Windows, where the home folder is often C:\Users\First Last\), the shell splits the path and Node receives only the first fragment:

Error: Cannot find module 'C:\Users\First'
  code: 'MODULE_NOT_FOUND'

All five hooks (security-guard, session-start, skill-forced-eval, stop-summary, session-summary) fail on every event. Users get a hook error on each Bash/Write/Edit call and each prompt, and features such as forced skill evaluation silently never run.

Change

Wrap the path in double quotes in all five commands:

"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/security-guard.js\""

This is the form the Claude Code plugin docs recommend for shell-form hook commands, and claude plugin validate warns about the unquoted form. No other files change. Paths without spaces behave exactly as before.

Testing

On Windows 11 with Node v24 and a home folder containing spaces:

  • Before: SessionEnd hook [...] failed: Error: Cannot find module 'C:\Users\...'.
  • After: all hooks load. security-guard.js returns {"continue":true} for a Bash payload, and skill-forced-eval.js emits the skill list on prompt submit, which I confirmed in a live session.
  • The patched file is byte-identical to this branch's hooks/hooks.json (git blob 62d2430). The original matches main (d1c932f).

Note: several skill docs (skills/hook-development, skills/command-development, skills/plugin-structure) show the same unquoted pattern in examples. I left them alone to keep this PR to the runtime fix.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YYpHr4VNP2fCe3H1Bq1Ffw

When the plugin is installed under a path containing spaces (common on
Windows, e.g. C:\Users\First Last\.claude\...), the shell split the
unquoted path and node received only the first fragment, so every hook
failed with MODULE_NOT_FOUND on each event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYpHr4VNP2fCe3H1Bq1Ffw
@Galaxy-Dawn
Galaxy-Dawn merged commit 83efeac into Galaxy-Dawn:main Oct 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants