You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: [Windows] Claude Code agent hooks are written as "<path> || echo {}", which Windows PowerShell 5.1 fails to parse — every hook event fails #23877
Claude Code: v2.1.284, native Windows install (npm)
What happened
After Orca sets up the Claude Code integration, ~/.claude/settings.json gets hook entries for every event (SessionStart, PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, UserPromptSubmit, Stop, StopFailure, SubagentStart, SubagentStop, PostCompact, SessionEnd, TeammateIdle), each with a command of the form:
Every one of them fails. On startup Claude Code prints:
SessionStart:startup hook error
Failed with non-blocking status code: At line:1 char:50
+ C:/Users/<USER>/.orca/agent-hooks/claude-hook.cmd || echo {}
+ ~~
The token '||' is not a valid statement separator in this version.
(Error text is localized on this machine; English equivalent shown.)
Root cause
On native Windows, Claude Code executes hook command strings via powershell.exe — Windows PowerShell 5.1. || as a statement separator is PowerShell 7+ / POSIX / cmd syntax; PS 5.1 only accepts ;. The command fails at parse time, before claude-hook.cmd is ever invoked.
Reproduction without Orca:
C:\> powershell.exe -NoProfile -Command "C:/Users/<USER>/.orca/agent-hooks/claude-hook.cmd || echo {}"
At line:1 char:50
+ C:/Users/<USER>/.orca/agent-hooks/claude-hook.cmd || echo {}
+ ~~
The token '||' is not a valid statement separator in this version.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : InvalidEndOfLine
The suffix is generated by the hook-command builder in out/main/chunks/managed-agent-hook-controls-*.js (as shipped in app.asar):
`${e.replaceAll("\\","/")} || echo {}`
Impact
Not limited to SessionStart — all hook events Orca registers carry the same command string, so every event fails with the same parse error and exits non-zero. Orca receives no Claude Code events at all on native Windows; the integration is effectively dead, not degraded.
claude-hook.cmd itself is fine: it writes {} to stdout and exit /b 0 unconditionally, so the || echo {} fallback is redundant even in shells where it parses.
Suggested fix
Drop the || echo {} suffix for the Windows hook command. A bare forward-slash path to a .cmd executes correctly in Windows PowerShell 5.1, cmd.exe, and POSIX shells alike, and the cmd itself already guarantees {} on stdout and exit code 0. A ; separator would parse in PS 5.1 but not in cmd, so the bare path is the only form portable across every shell a Claude Code install may use to run hooks.
Possibly related history from earlier iterations of the Windows hook wrapper: #15797, #18875.
Activity