Skip to content

SessionStart run-hook.cmd command fails under PowerShell without call operator #1751

@tusharjainnaulakha-svg

Description

@tusharjainnaulakha-svg

Summary

On Windows with Claude Code 2.1.177, the superpowers@claude-plugins-official 5.1.0 SessionStart hook can fail before run-hook.cmd executes when the command is run through PowerShell. The current hook command begins with a quoted string followed by session-start; in PowerShell that leading quoted string is parsed as an expression, not as a command invocation, so the following bareword becomes an unexpected token.

Environment

  • OS: Windows
  • Claude Code CLI: 2.1.177 (Claude Code)
  • Plugin: superpowers@claude-plugins-official 5.1.0
  • Local plugin package metadata: { "name": "superpowers", "version": "5.1.0" }

Observed behavior

A persisted Claude Code SessionStart non-blocking hook error for this host contains:

hookName: SessionStart:startup
At line:1 char:101
Unexpected token 'session-start' in expression or statement.
ParserError: UnexpectedToken

The underline in the persisted error points at session-start.

Current manifest command

Local hooks/hooks.json for Superpowers 5.1.0 contains:

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

hooks/run-hook.cmd exists locally.

Why this fails under PowerShell

In PowerShell, a statement starting with a quoted string is treated as a string expression. The subsequent bareword session-start is not passed as an argument to that string, so PowerShell reports UnexpectedToken before the .cmd wrapper runs.

Suggested fix

If the hook command may be executed by PowerShell, use PowerShell's call operator:

& "${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd" session-start

Alternatively, have Claude Code invoke .cmd hooks through CMD explicitly, e.g. cmd /c, when running Windows plugin hooks.

Superpowers' own Windows polyglot hook documentation says Windows hooks run through CMD and gives a cmd /c simulation. This host's persisted error indicates the command is instead being interpreted by PowerShell, so either the plugin manifest needs to be PowerShell-safe or the host invocation shell should match the documented CMD path.

I did not find an existing matching issue in obra/superpowers for run-hook.cmd session-start PowerShell UnexpectedToken char 101; the only search hit was unrelated issue #101.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions