[Bug] Grok Build on Windows ParserErrors the POSIX hook command

Author: 0xenzymeCreated Sep 26, 2026Updated Sep 26, 2026
Labelsneeds triage

PR #833 already implements a draft fix and was marked policy: needs issue. This is the missing report. I will not push further changes until a maintainer approves the direction here.

What happened?

On Windows, Grok Build runs hook command strings through its session shell. With GROK_SHELL unset, that shell is pwsh when it is installed, otherwise powershell.exe. Git Bash is only selected when powershell.exe is missing. GROK_SHELL can force pwsh, powershell, bash, or cmd. PowerShell is invoked as pwsh|powershell.exe -NoProfile -NonInteractive -Command <command>, and cmd as cmd /C <command>.

The Grok hook schema has a command field and no per-platform sibling. Current Impeccable installs write the POSIX guard into .grok/hooks/impeccable.json for both PostToolUse and Stop:

[ ! -f ".grok/skills/impeccable/scripts/impeccable" ] || ".grok/skills/impeccable/scripts/impeccable" hook

PowerShell cannot parse [ ! -f ... ]. Each Stop reports stop hook (project/settings) failed, ignored: exit code 1, and the same string fails on PostToolUse. The design hook never runs. A global install rewrites that command to an absolute path and still uses the POSIX guard.

The Codex form from #452, if exist "<path>" ("<path>" hook & exit /b), is also invalid PowerShell. Copying it into Grok's command does not fix this. Grok's published hook example only has command: https://docs.x.ai/build/features/hooks

Steps to reproduce

  1. On Windows, install the Impeccable skill for Grok so .grok/hooks/impeccable.json exists. Trust the folder with /hooks-trust or grok --trust.
  2. Leave GROK_SHELL unset.
  3. Run a turn that edits a file, or end a turn so the Stop hook fires.
  4. The hook fails before impeccable hook runs. The session records stop hook (project/settings) failed, ignored: exit code 1.

The same command string is what buildGrokHooksManifest() writes today, and github_manifests_pass_through_and_grok_is_rewritten asserts that the rewritten .grok entry has no commandWindows.

Expected behavior

Under the default PowerShell invocation, GROK_SHELL=cmd, and Git Bash, the hook runs impeccable.cmd hook when the launcher exists and exits 0 when it does not. The launcher's exit code is preserved. A Unix install keeps the POSIX guard.

Provider & environment

  • Provider: Grok Build
  • Provider version:
  • OS: Windows. Default shell is PowerShell (pwsh, else powershell.exe), from xai-org/grok-build crates/codegen/xai-grok-config/src/shell.rs.

Additional context

#452 / #453 covered Codex, which has a commandWindows field. #848 is the follow-up for that Codex field: Codex still parses the cmd.exe if exist (...) string in the session PowerShell. This report is the Grok manifest, which has nowhere to put a second command.

A candidate that parses in PowerShell, cmd /C, and Git Bash is:

cmd /c if exist "<path>\impeccable.cmd" "<path>\impeccable.cmd" hook

Backslash paths, no extra wrapping quotes. Relative paths with / are split by PowerShell after cmd /c.

Willing to work on a fix?

Yes. #833 already contains a draft of this and is marked policy: needs issue. I will wait for maintainer approval on this issue before pushing further changes to that PR.

AI assistance: this report was drafted with AI assistance. The manifest command and the "no commandWindows" assertion were checked against current main. The shell order was checked against xai-org/grok-build shell.rs. The Stop failure string is the one recorded on #833.