Skip to content

[FEATURE] User Interrupt Hook #9516

Open

Description

@arhgap11b

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • 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 (Stop hook)
  • 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

  1. Feature parity: Completes the lifecycle coverage (start → working → end/interrupt)
  2. Better UX: Enables context-aware notifications and state management
  3. Debugging: Helps track user interaction patterns and interruption frequency
  4. Resource cleanup: Allows proper cleanup of resources when operations are interrupted vs. completed

Workarounds (and why they don't work)

  1. Timeout-based detection: Unreliable, creates false positives for long-running tasks
  2. Heartbeat with PreToolUse: Fires on every tool call, creates noise and complexity
  3. Process monitoring: External to Claude Code, fragile and platform-specific

Related Documentation

Activity

  1. arhgap11b commented on Oct 14, 2025

    @arhgap11b
    Author

    Would be great if we could have hook on context limit (when auto-compact turned off)!

  2. github-actions commented on Dec 8, 2025

    @github-actions

    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.

  3. mpercy commented on Dec 24, 2025

    @mpercy

    Would be nice to see this fixed for edge-triggered status / notification purposes

  4. CharlonTank commented on Dec 29, 2025

    @CharlonTank

    I need that too!

  5. jeffc-dev commented on Jan 14, 2026

    @jeffc-dev

    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.

  6. bernarduh commented on Jan 21, 2026

    @bernarduh

    I could use the Interrupted hook too 🙏

  7. maxisme commented on Jan 24, 2026

    @maxisme

    Very keen for this feature it is leaving my Claude code wrapper in very strange states.

  8. alvarolb commented on Jan 24, 2026

    @alvarolb

    I need this one too ;)

  9. johnrobinsn commented on Jan 24, 2026

    @johnrobinsn

    Pretty please 🙏 Thanks!

  10. mwurm293 commented on Feb 8, 2026

    @mwurm293

    please

  11. XciD commented on Feb 10, 2026

    @XciD

    Would love to see this one too

  12. 14 remaining items

  13. ro0mquy commented on Jul 8, 2026

    @ro0mquy

    +1

  14. zhenghan3852 commented on Jul 8, 2026

    @zhenghan3852

    +1

  15. 3Spiders commented on Aug 3, 2026

    @3Spiders

    +1

  16. ZhenyaUsenko commented on Sep 28, 2026

    @ZhenyaUsenko

    +1

  17. pleahmacaka commented on Oct 1, 2026

    @pleahmacaka

    +1, use case: a plugin that sends "continue" when you press Enter twice on an empty prompt after interrupting.

  18. MaxShymko commented on Oct 28, 2026

    @MaxShymko

    I need this as well!

  19. CTSDM commented on Nov 8, 2026

    @CTSDM

    We run several Claude Code sessions in tmux and show each one's state (working/idle) from hooks: UserPromptSubmit --> working, Stop --> idle. When a turn is interrupted by the user with escape or control c, no hook fires, so the session shows "working" indefinitely while it sits idle. It's worst when the interrupt comes before any output: the prompt goes back to the input box and there's nothing on screen we could detect the interrupt from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions