Skip to content

[Bug]: [Windows] Claude Code agent hooks are written as "<path> || echo {}", which Windows PowerShell 5.1 fails to parse — every hook event fails #23877

Closed

Description

@Lutra23

Environment

  • Orca: 1.4.216 (Windows desktop, x64)
  • OS: Windows 10 Pro 22H2 (10.0.22631)
  • 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:

C:/Users/<USER>/.orca/agent-hooks/claude-hook.cmd || echo {}

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.

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