Skip to content

Conversation

@MaxmaxmaximusFree
Copy link

Summary

  • Block mode: Added permissionDecisionReason field to the deny response so Claude sees why a command was blocked
  • Warn mode: Added additionalContext field to the allow response so Claude sees the warning before executing

Problem

Hookify rules define a message body that should be shown when a rule triggers. Previously, this message was only sent via systemMessage, which is displayed in the UI to the user but is not injected into the model's context. This means Claude cannot see:

  • Why a blocked command was denied (it only sees generic "Blocked by hook")
  • Warning text for warn-mode rules (warnings are silently swallowed)

This defeats the purpose of hookify messages — Claude keeps retrying blocked commands without understanding why, or ignores warnings entirely.

Fix

Two additions to rule_engine.py evaluate_rules():

  1. For action: block (deny): add permissionDecisionReason to hookSpecificOutput — this field is documented as "shown to Claude" for deny decisions
  2. For action: warn (allow): add additionalContext to hookSpecificOutput — this field injects context visible to Claude before tool execution

Both fields are part of the official Claude Code hooks API. systemMessage is preserved for backward compatibility (still shows in UI).

Test plan

  • Create a hookify rule with action: block — verify Claude sees the reason text in the denial message
  • Create a hookify rule with action: warn — verify Claude sees the warning as system-reminder context
  • Tested on Windows (Git Bash) with a redirect detection rule

🤖 Generated with Claude Code

Previously, hookify used only `systemMessage` to communicate rule
messages. This field is shown to the user in the UI but is NOT
injected into the model's context, making Claude unable to see
why a command was blocked or what the warning was about.

- Block mode: add `permissionDecisionReason` to deny output so
  Claude sees the reason for denial
- Warn mode: add `additionalContext` to allow output so Claude
  sees the warning before executing

Tested on Windows with Git Bash. Both block and warn messages
now reach the model as expected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

Thanks for your interest! This repo only accepts contributions from Anthropic team members. If you'd like to submit a plugin to the marketplace, please submit your plugin here.

@github-actions github-actions bot closed this Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant