You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows: Hook commands cause brief console window flash #19012
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.
Adding windowsHide: true to the spawn options for SessionStart (and other detached hooks) would:
Eliminate the need for Windows-specific workarounds
Allow the same cross-platform command to work everywhere
Simplify hook configuration for Windows users
The fact that statusLine already doesn't flash suggests the infrastructure supports it - it may just need to be applied to SessionStart and similar hooks.
When Claude Code spawns hooks with child_process.spawn(..., {shell: true}), Node.js invokes cmd.exe via the COMSPEC environment variable. The console window flash happens at CreateProcess time—before any JavaScript executes—which is why windowsHide: true doesn't help.
The Solution
Create a GUI subsystem wrapper (no automatic console allocation)
Name it cmd.exe and place it in a user directory (e.g., C:\Users\<user>\.claude\cmd.exe)
Set COMSPEC to point to this wrapper before launching Claude Code
The wrapper spawns the real cmd.exe with CREATE_NO_WINDOW flag and forwards stdio
⚠️ Critical Discovery: The Wrapper MUST Be Named cmd.exe
Node.js uses this regex to detect cmd.exe: /^(?:.*\\)?cmd(?:\.exe)?$/i
If you name it hiddencmd.exe, Node.js will:
Use -c instead of /d /s /c (breaking cmd.exe syntax)
When Claude Code spawns hooks with child_process.spawn(..., {shell: true}), Node.js invokes cmd.exe via the COMSPEC environment variable. The console window flash happens at CreateProcess time—before any JavaScript executes—which is why windowsHide: true doesn't help.
The Solution
Create a GUI subsystem wrapper (no automatic console allocation)
Name it cmd.exe and place it in a user directory (e.g., C:\Users\<user>\.claude\cmd.exe)
Set COMSPEC to point to this wrapper before launching Claude Code
The wrapper spawns the real cmd.exe with CREATE_NO_WINDOW flag and forwards stdio
⚠️ Critical Discovery: The Wrapper MUST Be Named cmd.exe
Node.js uses this regex to detect cmd.exe: /^(?:.*\\)?cmd(?:\.exe)?$/i
If you name it hiddencmd.exe, Node.js will:
Use -c instead of /d /s /c (breaking cmd.exe syntax)
✅ Survives Claude Code updates (lives in your launcher)
✅ Scoped to Claude Code only (other apps unaffected)
✅ Preserves stdout/stderr (hooks can output normally)
✅ Preserves exit codes
What Doesn't Work
Approach Why It Fails windowsHide: true Window created before option is read NODE_OPTIONS preload Same—too late nodew.exe Can't write to stdout
Patching cli.js Reverted on updates, still flashes
Job Objects Can't enforce CREATE_NO_WINDOW on children
PATH-based shim Windows resolves cmd.exe from System32 first
For me, the fix came when they updated claude-mem plugin.
For me, the fix came when they updated claude-mem plugin.
Is it Claude-mem? - That actually sounds right because it happened when I installed Claude-mem. I can't remember what fixed it completely at first, but all I remember is that I put in this prompt to my AI and then it was fixed in 2 mins.
Either way there has to be a way to use Claude-mem because it didn't get that popular without it working.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
github-actions commentedon Jan 18, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
gsa9 commentedon Jan 18, 2026
Update: Findings from Testing
After testing various approaches, discovered that different hook types behave differently:
Key Finding
node -eFlash?Working Workarounds
For statusLine -
node -eworks without flash:For SessionStart on Windows - requires
mshtatrick:Request
Adding
windowsHide: trueto the spawn options for SessionStart (and other detached hooks) would:The fact that statusLine already doesn't flash suggests the infrastructure supports it - it may just need to be applied to SessionStart and similar hooks.
Related
Working solution documented in gsd-build/get-shit-done#144
topemalheiro commentedon Jan 19, 2026
Anthropic please fix this, it's really annoying and we want to use claude-mem.
Airflyctl commentedon Jan 21, 2026
Not only do the windows flash, but the main CC window also sometimes crashes when using claude-mem.
jthweny commentedon Jan 27, 2026
I've found a bulletproof solution that completely eliminates the console flash without modifying Claude Code's source. Full research report with technical details: https://claude.ai/public/artifacts/0cd072dd-5e18-4362-9a5b-a184d9dde894
The Root Cause
When Claude Code spawns hooks with
child_process.spawn(..., {shell: true}), Node.js invokescmd.exevia theCOMSPECenvironment variable. The console window flash happens atCreateProcesstime—before any JavaScript executes—which is whywindowsHide: truedoesn't help.The Solution
cmd.exeand place it in a user directory (e.g.,C:\Users\<user>\.claude\cmd.exe)COMSPECto point to this wrapper before launching Claude Codecmd.exewithCREATE_NO_WINDOWflag and forwards stdiocmd.exeNode.js uses this regex to detect cmd.exe:
/^(?:.*\\)?cmd(?:\.exe)?$/iIf you name it
hiddencmd.exe, Node.js will:-cinstead of/d /s /c(breaking cmd.exe syntax)Implementation
hiddencmd.cpp (compile as GUI subsystem):
Build (MSVC):
cl /nologo /O2 /W4 /DUNICODE /D_UNICODE hiddencmd.cpp /link /SUBSYSTEM:WINDOWS /OUT:C:\Users\%USERNAME%\.claude\cmd.exeBuild (MinGW-w64):
g++ -O2 -municode -Wl,-subsystem,windows -o C:\Users\%USERNAME%\.claude\cmd.exe hiddencmd.cppLauncher integration (set COMSPEC before launching Claude Code):
Why This Works
What Doesn't Work
windowsHide: trueNODE_OPTIONSpreloadnodew.exeCREATE_NO_WINDOWon childrentopemalheiro commentedon Jan 28, 2026
For me, the fix came when they updated claude-mem plugin.
jthweny commentedon Jan 28, 2026
Is it Claude-mem? - That actually sounds right because it happened when I installed Claude-mem. I can't remember what fixed it completely at first, but all I remember is that I put in this prompt to my AI and then it was fixed in 2 mins.
Either way there has to be a way to use Claude-mem because it didn't get that popular without it working.
jthweny commentedon Jan 28, 2026
It also happened before I installed Claude-mem too, it's actually funny how you mentioned that.
topemalheiro commentedon Jan 28, 2026
Oh, you got it fixed, cool.
github-actions commentedon Feb 28, 2026
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
github-actions commentedon Mar 9, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
/usr/bin/bashon Windows, ignoringshellsetting #32930 as a duplicate of this issue