Hooks with shell commands cause 5+ minute hangs/crashes on Windows
Bug Report
Claude Code version: 2.1.73
OS: Windows 11 (MINGW64_NT-10.0-26200, build 26200)
Node: v24.14.0
Python: 3.14.3
Shell: Git Bash (MSYS2/MINGW64)
Description
Project-level hooks that spawn shell commands cause Claude Code to hang for 5+ minutes or crash entirely on the second message of a conversation. The first message in a session works fine; subsequent messages either freeze indefinitely or crash without registering user input.
Reproduction
- Create
.claude/settings.jsonwith any combination of hooks that spawn shell processes:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "if echo \"$CLAUDE_FILE_PATH\" | grep -qE '\.py$'; then python -m ruff check --fix --quiet \"$CLAUDE_FILE_PATH\" 2>/dev/null; python -m ruff format --quiet \"$CLAUDE_FILE_PATH\" 2>/dev/null; fi",
"timeout": 15000
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "if echo \"$CLAUDE_BASH_COMMAND\" | grep -qE '(git commit|git push)'; then cd \"$CLAUDE_WORKING_DIRECTORY\" && python -m pytest tests/ -x -q --timeout=30 2>&1 | tail -5; fi",
"timeout": 300000
}
]
}
]
}
}
- Start a Claude Code session in that project directory
- Send any message — first response works
- Send a second message — hangs for 5+ minutes or crashes
Isolation steps performed
We systematically isolated the issue by disabling components one at a time:
| Component | Disabled | Hang resolved? |
|-----------|----------|---------------|
| Claude Preview MCP (deny rules) | ✅ | ❌ No |
| scheduled-tasks MCP (deny rules) | ✅ | ❌ No |
| OMC plugin | ✅ | ❌ No |
| All plugins | ✅ | ❌ No |
| .claude/agents/ directory | ✅ | ❌ No |
| .claude/docs/ directory | ✅ | ❌ No |
| Entire .claude/ directory | ✅ | ❌ No |
| settings.json hooks only | ✅ | ✅ Yes |
The issue is 100% reproducible and isolated to hooks.
Additional findings
- The hooks themselves execute fast when tested manually (~200ms for ruff check + format)
- Setting
"async": trueon hooks does NOT fix the issue - Changing
"matcher": "Bash"to"Bash(git commit:*)"does NOT fix the issue - Reducing timeouts does NOT fix the issue
- The issue does NOT occur in other project directories without hooks
- The issue does NOT occur on the same project with hooks removed
- Memory is not a factor (44GB free of 62GB)
- Network is not a factor (12ms to Anthropic API)
- Only 1 Node.js process running (OMC MCP server, 45MB)
Expected behavior
Hooks should execute their shell commands and return results without blocking or crashing the Claude Code session, as they do on macOS/Linux.
Actual behavior
On Windows (Git Bash/MSYS2), hooks that spawn shell subprocesses cause the session to deadlock after the first message. The subprocess appears to hang or the stdio pipe between Claude Code and the hook process deadlocks. This manifests as:
- 5+ minute freezes where no response is generated
- Complete crashes where user input is never registered
- Pattern of "every second message" hanging (first works, second deadlocks)
Workaround
Remove all hooks from .claude/settings.json. Quality checks can still be triggered manually via CLAUDE.md instructions directing Claude to run linters/tests via the Bash tool.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗