claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Windows: Hook commands cause brief console window flash

Open gsa9 opened this issue 1 month ago • 2 comments

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

  1. VBS wrapper (for hooks that don't need stdout):

    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run "node script.js", 0, False
    
  2. 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.).

gsa9 avatar Jan 18 '26 12:01 gsa9