Skip to content

PostToolUse hook breaks on Windows when CLAUDE_PLUGIN_ROOT contains spaces #7

Closed

Description

@phantomsecurityandfire

Bug

The PostToolUse and SessionStart hooks in hooks/hooks.json fail on Windows when the user's home directory contains spaces (e.g., C:\Users\Nate Evans\...).

Root Cause

The hook commands don't quote ${CLAUDE_PLUGIN_ROOT}:

"command": "bash ${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-hook.sh"

When CLAUDE_PLUGIN_ROOT expands to a path with spaces, bash word-splits it:

$ bash -c "bash ${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-hook.sh"
bash: /c/Users/Nate: No such file or directory

Since the PostToolUse hook has no matcher, this error fires on every single tool use, not just Bash commands.

Impact

  • Every tool call in Claude Code produces a hook error (exit code 127)
  • Affects any Windows user whose username contains a space (very common default)

Fix

Quote the variable in hooks/hooks.json:

{
    "PostToolUse": [
        {
            "hooks": [
                {
                    "type": "command",
                    "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/post-tool-hook.sh\""
                }
            ]
        }
    ],
    "SessionStart": [
        {
            "hooks": [
                {
                    "type": "command",
                    "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/session-start-hook.sh\""
                }
            ]
        }
    ]
}

For reference, the superpowers plugin handles this correctly:

"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start"

Environment

  • Windows 11 Pro
  • Claude Code CLI
  • remember plugin v0.1.0
  • User home directory: C:\Users\Nate Evans (space in path)

Activity

  1. fdaviddpt commented on Apr 2, 2026

    @fdaviddpt
    Contributor

    Fixed in 4d50166 — added quotes around ${CLAUDE_PLUGIN_ROOT} in hooks.json.

    Thanks for the clear bug report and the fix suggestion, Nate! The superpowers plugin reference was exactly the right call. Appreciate you taking the time.

    — Max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions