[FEATURE] User Interrupt Hook
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Summary
Add a new hook event that fires when the user manually interrupts Claude Code's response (e.g., by clicking Stop or pressing Ctrl+C).
Problem
Currently, Claude Code provides a Stop hook that fires when the agent finishes responding normally. However, according to the documentation:
"Does not run if the stoppage occurred due to a user interrupt."
This creates a gap: there is no way to detect when the user manually interrupts the agent. This prevents implementing features that need to differentiate between:
- Normal completion (agent finished its work)
- User interrupt (user manually stopped the agent)
Proposed Solution
Add a new hook event: UserInterrupt (or AgentInterrupted, Stop:Interrupted, etc.)
This hook should fire when:
- User clicks the Stop button during agent response
- User presses keyboard interrupt (Ctrl+C or equivalent)
- User manually cancels agent operation through any UI mechanism
Example Configuration
{
"hooks": {
"Stop": [{
"hooks": [{
"type": "command",
"command": "my-script.py --event normal_completion"
}]
}],
"UserInterrupt": [{
"hooks": [{
"type": "command",
"command": "my-script.py --event user_interrupted"
}]
}]
}
}
Alternative Solutions
_No response_
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
We're implementing an audio notification system that plays background noise while Claude works and plays a completion sound when finished. We need to:
- Play a "work complete" sound when the agent finishes normally (
Stophook) - Play a different "interrupted" sound when the user manually stops the agent
- Currently impossible because there's no hook for user interrupts
Additional Context
Benefits
- Feature parity: Completes the lifecycle coverage (start → working → end/interrupt)
- Better UX: Enables context-aware notifications and state management
- Debugging: Helps track user interaction patterns and interruption frequency
- Resource cleanup: Allows proper cleanup of resources when operations are interrupted vs. completed
Workarounds (and why they don't work)
- Timeout-based detection: Unreliable, creates false positives for long-running tasks
- Heartbeat with PreToolUse: Fires on every tool call, creates noise and complexity
- Process monitoring: External to Claude Code, fragile and platform-specific
Related Documentation
- Hooks Reference
- Current
Stophook explicitly excludes interrupts
25 Comments
Would be great if we could have hook on context limit (when auto-compact turned off)!
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Would be nice to see this fixed for edge-triggered status / notification purposes
I need that too!
Consider me another vote for this.
I'm working on a utility that watches Claude activity and is effectively 'stuck' if it can't detect manual interuption.
I could use the Interrupted hook too 🙏
Very keen for this feature it is leaving my Claude code wrapper in very strange states.
I need this one too ;)
Pretty please 🙏 Thanks!
please
Would love to see this one too
Also shopping for this.
+1
Do not interrupt this issue !
I need it to ! ✨
Confirming this affects session status monitoring tools as well.
Use case: Agent Console Dashboard (ACD) — a TUI that tracks Claude Code session status by listening to hook events. When a session is active, ACD sets status to
working. It relies on theStophook to transition the status back toattention(idle). BecauseStopdoes not fire on user interrupt, any session where the user presses ESC or Ctrl+C is permanently stuck showingworkinguntil the next hook event fires.Why workarounds fail for this case:
PreToolUseheartbeat: only fires during tool execution, not during the initial inference phase when interrupts most commonly happenEnvironment:
| Component | Version |
|-----------|---------|
| Claude Code | latest |
| Platform | macOS 15.x (Darwin) |
The
Stophook gap is documented in the official hook reference ("Does not run if the stoppage occurred due to a user interrupt") but there is no alternative hook that covers this case. AUserInterruptorStop:interruptedhook event would close this gap cleanly.There's no native
UserInterrupthook yet, but you can approximate interrupt detection with existing hooks:External watcher (run in a separate terminal):
Not a perfect substitute for a native
UserInterruptevent, but these patterns cover the main use cases: recovery after interrupt, logging interrupt vs clean exit, and real-time stall detection.Very curious why this hasn't been implemented yet. It seems trivial to implement, and its absence plays havoc with tracking internal Claude state.
Throwing in another request for this. Seems like a pretty major hole in Claude Code hooks coverage, and an annoyance for multi-agent workflows
+1 — this gap affects out-of-process integrations badly.
I maintain a local sidecar service that mirrors Claude Code's session state
to a hardware status indicator (LED). Without a hook for user interrupts,
the indicator gets stuck in "processing" forever after the user presses Esc
— there's no event to clear it until the next
UserPromptSubmit, which maynever come if the user walks away.
Inferring interrupts by tracking unpaired
PreToolUse/PostToolUseworks for the "interrupt then continue" case but completely misses
"interrupt then idle/close window", and forces every integrator to
reimplement the same pairing logic.
A dedicated
UserInterrupt(orInterrupted) hook event withsession_id,cwd, and the cancelledtool_use_id(s) would solve this cleanly withoutoverloading
Stop's existing semantics. Would love to see this prioritized.I need this feature added asap.
As Claude Code doesn't support any other file encoding other than UTF-8, I'm using hooks on Read/Edit/Write to convert my files to UTF-8, then parse the edited file back to my encoding. However, if I don't accept a change, I can't detect that the file needs to be converted back.
+1
+1
+1
+1
+1