[BUG] Windows: hooks spawn bash with -i flag creating visible console window on every hook execution
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
On Windows, Claude Code spawns hook commands via bash --login -i -c "command".
The -i flag creates a visible console window on every hook execution — every
user prompt (UserPromptSubmit) and every file edit (PostToolUse).
Environment
- OS: Windows 11 Home 10.0.26200
- Claude Code: 2.1.87 (VS Code extension)
- Shell: Git Bash MINGW64
Root Cause
Hooks are spawned as: bash --login -i -c "<command>"
The -i flag + no CREATE_NO_WINDOW flag = visible console window every time.
The Fix (one line)
Add windowsHide: true to the hook spawn options in Node.js:
child_process.spawn('bash', ['--login', '-i', '-c', command], {
windowsHide: true, // <-- this is all it needs
...existingOptions
})
Or remove the -i flag — hooks don't need an interactive shell.
Related: #18469, #18856, #19294, #19057
What Should Happen?
Hook commands should execute without creating any visible console window.
The hook output should be captured silently in the background.
Error Messages/Logs
2026-03-30T11:15:58.684Z [DEBUG] Getting matching hook commands for SessionEnd with query: other
/usr/bin/bash --login -i -c bash $CLAUDE_PROJECT_DIR/.claude/hooks/skill-activation-prompt.sh
Window title observed: /usr/bin/bash --login -i -c bash $CLAUDE_PROJECT_DIR/.claude/hooks/skill-activation-prompt.sh
Steps to Reproduce
- Configure any hook in .claude/settings.json:
{ "hooks": { "UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "echo hello" }] }] } }
- Send any message in Claude Code
- A visible CMD/bash console window flashes on screen for every message sent
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
unknown (hooks may have always behaved this way on Windows
Claude Code Version
2.1.87
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
Root cause: hooks are spawned via bash --login -i -c "command".
The -i flag + no CREATE_NO_WINDOW = visible window every hook call.
Fix: add windowsHide: true to the Node.js spawn options for hooks.
This is a one-line change.
Related: #18469, #18856, #19294, #19057
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗