Bug: Hooks stop executing after ~2.5 hours in session
Bug: Hooks Stop Executing After ~2.5 Hours (Session Lifecycle Bug)
Description
Claude Code hooks execute successfully at session start but silently stop working after approximately 2.5 hours in the same session. No errors are logged - they simply stop firing.
Environment
- OS: Windows 11
- Shell: Git Bash (MINGW64)
- Claude Code Version: Latest (as of 2026-01-02)
- Hooks Config: Valid
.claude/hooks.json(2683 bytes, 8 hooks configured)
Reproduction Steps
- Start a fresh Claude Code session with hooks configured in
.claude/hooks.json - Verify hooks are working:
``bash``
# Perform an Edit operation
# Check C:\Users\{user}\.claude\hooks.log for new entries ✅
- Continue working in the same session for ~2.5 hours
- Perform another Edit operation that should trigger PreToolUse hook
- Check hooks.log again
``bash``
# Expected: New log entry
# Actual: No new entry ❌ (timestamp doesn't update)
Evidence
Session 1 (2026-01-02 afternoon)
- 16:28: Hooks executing normally
- Edit operations triggered PreToolUse hooks
- TodoWrite triggered PostToolUse hooks
- All logged successfully in hooks.log
- 18:48: Hooks stopped firing (gap: ~2.5 hours)
Session 2 (2026-01-02 evening) - Confirmed reproduction
- 16:27-16:28: Hooks executing normally
````
2026-01-02 16:27:59 - standards_validator - INFO - Validating Edit operation
2026-01-02 16:28:05 - instruction_matcher - INFO - SUCCESS: Applied 1 instructions
2026-01-02 16:28:21 - todo_sync - INFO - Todo sync complete
- 16:50:47: Last hook entry (suspicious)
````
2026-01-02 16:50:47 - standards_validator - INFO - No stdin data, allowing operation
Note: "No stdin data" suggests hook invoked but didn't receive tool use data
- 19:15: Performed Edit operation - NO hook fired
- hooks.log not updated
- Last modified timestamp still 16:50:47
- Gap: 2 hours 25 minutes
Expected Behavior
Hooks should continue executing throughout the entire session, from start to termination.
Actual Behavior
Hooks work correctly at session start, then silently stop after ~2.5 hours with no error messages, warnings, or indication of failure.
Impact
Critical - All hook-based functionality stops mid-session:
- ❌ Code validation hooks stop working
- ❌ Auto-documentation hooks stop working
- ❌ Database sync hooks stop working
- ❌ Custom automation breaks
Users lose all automated quality controls without any warning.
Related Issue: /hooks Command Not Working
Running claude hooks or /hooks does NOT display hook configuration. Instead, it returns an AI-generated response:
I can see you've typed "hooks" - how can I help you with the Claude Family hooks system?
Expected: Display configured hooks from .claude/hooks.json
Actual: AI interprets it as a user message
This suggests Claude Code may not be properly loading/maintaining hook configuration state.
Minimal Test Case
// .claude/hooks.json
{
"hooks": {
"PreToolUse": [{
"hooks": [{
"type": "command",
"command": "echo $(date) Hook fired >> C:/temp/hook_test.log",
"timeout": 5
}],
"matcher": "Edit"
}]
}
}
- Start Claude Code
- Perform Edit → Check hook_test.log (should have timestamp) ✅
- Wait 2.5+ hours in same session
- Perform Edit → Check hook_test.log (no new timestamp) ❌
Current Workaround
Restart Claude Code every ~2 hours to re-enable hooks.
Hypothesis
Possible root causes:
- Event listener detachment - Hook event handlers unbound after timeout/idle
- Process lifecycle bug - Hook subprocess management fails over time
- Session state corruption - Hook registration lost after certain time threshold
- Memory/garbage collection - Hook execution context cleaned up incorrectly
The "No stdin data" log entry at 16:50:47 suggests the hook execution framework may be degrading - hooks are being invoked but not receiving tool use data properly.
Additional Context
- All hook scripts exist and are executable
- hooks.json is valid JSON (verified)
- Hook scripts work when manually invoked
- Same hooks.json works perfectly at session start
- Bug is reproducible across multiple sessions
- No errors in Claude Code console/logs
Files for Reference
If helpful for debugging, I can provide:
- Full hooks.json configuration
- Hook script source code
- Complete hooks.log showing the degradation
- Transcript showing tool use without hook execution
---
This is a critical bug affecting production use of Claude Code hooks. Any guidance on debugging or fixes would be greatly appreciated.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗