claude-code - 💡(How to fix) Fix [Windows] Statusline and hook commands spawn bash.exe without CREATE_NO_WINDOW, causing visible console flash every ~10 seconds [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51867Fetched 2026-04-23 07:42:46
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×5commented ×1

On Windows, Claude Code runs statusline commands and hook commands (e.g. Stop hook) by spawning bash.exe as an intermediary shell. That bash process is created without the CREATE_NO_WINDOW flag, so a console window (managed by conhost.exe) briefly flashes on screen every time the status bar updates — typically every 10 seconds.

Root Cause

Every time Claude Code updates the status bar, a brief dark console window flashes on screen. The flash lasts for the entire execution time of the command (~200ms for a typical Python script; even bash -c "cat file.txt" produces a ~76ms flash because bash itself creates and destroys a console window).

Code Example

{
  "statusLine": {
    "type": "command",
    "command": "C:/path/to/pythonw.exe C:/path/to/statusline.py"
  }
}

---

claude.exe
  └── bash.exe  (Windows creates conhost.exe for this — the flash)
        └── pythonw.exe statusline.py

---

SPAWN  conhost.exe  PID=12456
       parent=<statusline runner>
       cmd: \??\C:\WINDOWS\system32\conhost.exe 0x4

SPAWN  bash.exe  PID=21940
       parent=<statusline runner>
       cmd: C:\Program Files\Gitinash.exe -c <statusline command>

---

// child_process.spawn / exec / execFile
const child = spawn(shell, ['-c', command], {
  windowsHide: true,   // sets CREATE_NO_WINDOW on Windows — one line fix
  // ... other options
});
RAW_BUFFERClick to expand / collapse

Summary

On Windows, Claude Code runs statusline commands and hook commands (e.g. Stop hook) by spawning bash.exe as an intermediary shell. That bash process is created without the CREATE_NO_WINDOW flag, so a console window (managed by conhost.exe) briefly flashes on screen every time the status bar updates — typically every 10 seconds.

Environment

  • OS: Windows 11 Home 10.0.26200
  • Claude Code: latest (autoUpdatesChannel: latest)
  • Shell: Git Bash (bash.exe from C:\Program Files\Gitin\)
  • Settings: statusLine type command, Stop hook type command

Steps to reproduce

Configure a statusline command in .claude/settings.json:

{
  "statusLine": {
    "type": "command",
    "command": "C:/path/to/pythonw.exe C:/path/to/statusline.py"
  }
}

Every time Claude Code updates the status bar, a brief dark console window flashes on screen. The flash lasts for the entire execution time of the command (~200ms for a typical Python script; even bash -c "cat file.txt" produces a ~76ms flash because bash itself creates and destroys a console window).

Root cause (confirmed via WMI process monitoring)

Claude Code spawns the following chain on every statusline tick:

claude.exe
  └── bash.exe  (Windows creates conhost.exe for this — the flash)
        └── pythonw.exe statusline.py

WMI __InstanceCreationEvent monitoring captures this on every tick:

SPAWN  conhost.exe  PID=12456
       parent=<statusline runner>
       cmd: \??\C:\WINDOWS\system32\conhost.exe 0x4

SPAWN  bash.exe  PID=21940
       parent=<statusline runner>
       cmd: C:\Program Files\Gitinash.exe -c <statusline command>

If bash.exe were spawned with CREATE_NO_WINDOW (Win32 flag 0x08000000), Windows would create a hidden console host and no window would flash. The same issue occurs with hook commands (Stop hook, etc.).

What I tried

  • Switching from python.exe to pythonw.exe (GUI subsystem) — flash persists because bash.exe itself creates the console
  • Minimising script execution time (reducing from ~400ms to ~200ms) — reduces flash duration but does not eliminate it
  • Compiled a .NET 6 binary to replace Python — same result (~200ms), since the bash overhead is the bottleneck
  • Minimum achievable with current architecture: bash -c "cat file" = ~76ms, still visible

Expected behaviour

Console commands invoked for statusline / hooks should not produce any visible window. This is standard practice for background processes on Windows.

Proposed fix

In the Node.js code that spawns statusline/hook subprocesses, add windowsHide: true to the spawn options:

// child_process.spawn / exec / execFile
const child = spawn(shell, ['-c', command], {
  windowsHide: true,   // sets CREATE_NO_WINDOW on Windows — one line fix
  // ... other options
});

windowsHide: true is a built-in Node.js option that internally sets CREATE_NO_WINDOW when calling CreateProcess on Windows. This single flag change would eliminate all console flashing for statusline and hook commands.

extent analysis

TL;DR

To fix the console window flashing issue, add windowsHide: true to the spawn options in the Node.js code that spawns statusline and hook subprocesses.

Guidance

  • Identify the Node.js code responsible for spawning subprocesses for statusline and hook commands.
  • Modify the spawn options to include windowsHide: true, which sets the CREATE_NO_WINDOW flag on Windows.
  • Verify that the console window no longer flashes after applying the fix.
  • Test the fix with different types of commands, such as bash -c "cat file.txt", to ensure the issue is fully resolved.

Example

const child = spawn('bash', ['-c', 'statusline command'], {
  windowsHide: true, // sets CREATE_NO_WINDOW on Windows
  // ... other options
});

Notes

The proposed fix relies on the windowsHide option being supported in the Node.js version used by Claude Code. If the version does not support this option, an alternative solution may be needed.

Recommendation

Apply the workaround by adding windowsHide: true to the spawn options, as it is a built-in Node.js option that directly addresses the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING