claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[FEATURE] Add ToolRejected / PermissionDenied Hook Event to Capture User Rejection Feedbac

Open turbo-soft opened this issue 1 month ago • 0 comments

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

When a user rejects a tool use via the permission dialog and provides feedback, there is no hook event that captures this rejection. The user's feedback (e.g., "don't do that, try X instead") goes directly to Claude's conversation context but bypasses the hook system entirely.

Current behavior:

  1. PermissionRequest fires when the permission dialog is shown (before user decides)
  2. If user clicks Yes → PostToolUse fires
  3. If user clicks No with feedback → no hook fires

The rejection message ("The user doesn't want to proceed... the user said: [feedback]") is passed to Claude but is not exposed to any hook.

Current Workaround

The only workaround I found is:

  1. Use PermissionRequest to track pending permission requests
  2. Use UserPromptSubmit to capture the user's next message as proxy feedback
  3. If PostToolUse never fires for the pending tool, assume it was rejected

This is unreliable because:

  • The next message may not be related to the rejection
  • Inline rejection feedback is lost entirely
  • Race conditions with multiple tool calls

Proposed Solution

Add a new hook event: ToolRejected (or PermissionDenied)

Trigger: Fires when user clicks "No" on a permission dialog

Hook Input (stdin): { "session_id": "abc123", "transcript_path": "/path/to/transcript.jsonl", "cwd": "/path/to/project", "hook_event_name": "ToolRejected", "tool_name": "Write", "tool_input": { "file_path": "/path/to/file.txt", "content": "..." }, "user_feedback": "don't create new files, edit the existing one instead", "timestamp": "2025-12-21T13:45:00.000Z" }

Key field: user_feedback - The text the user typed in the rejection dialog (or empty string if none provided)

Alternative Solutions

No response

Priority

Medium - Would be very helpful

Feature Category

CLI commands and flags

Use Case Example

I'm building the script that that can capture the tool errors in the log file.

Later I want to run /learn command that will scan the errors and claude code instructions and make changes based on the errors if needed

Additional Context

No response

turbo-soft avatar Dec 21 '25 13:12 turbo-soft