Windows: Hook commands cause brief console window flash
Problem
On Windows, hook commands (both SessionStart and statusLine) cause a brief console window flash when they spawn Node.js or other console applications.
This happens because the child process is spawned without the windowsHide option.
Expected Behavior
Hook commands should run invisibly without any visible window flash.
Suggested Fix
When spawning hook commands on Windows, use the windowsHide: true option in Node.js spawn/exec:
const { spawn } = require('child_process');
spawn(command, args, {
windowsHide: true, // Hides the console window on Windows, ignored on other platforms
// ... other options
});
This option is cross-platform safe - it's ignored on macOS/Linux.
Current Workarounds
-
VBS wrapper (for hooks that don't need stdout):
Set WshShell = CreateObject("WScript.Shell") WshShell.Run "node script.js", 0, False -
Using .cmd files - reduces but doesn't eliminate the flash
Neither workaround fully solves the problem for statusLine which requires stdout capture.
Environment
- OS: Windows 11
- Claude Code version: v2.1.12
- Shell: PowerShell
Related
This affects any Windows user with custom hooks that run console applications (Node.js, Python, etc.).