fix: handle 'prompt' key for UserPromptSubmit and deduplicate rule loading - #2
Open
kmmwren wants to merge 1 commit into
Open
fix: handle 'prompt' key for UserPromptSubmit and deduplicate rule loading#2kmmwren wants to merge 1 commit into
kmmwren wants to merge 1 commit into
Conversation
…ading Claude Code's UserPromptSubmit hook sends the user's message under the key 'prompt', not 'user_prompt'. The rule engine was always reading an empty string for the user_prompt field, causing all prompt-event rules (use-superpowers, decision-capture, meetsync-reminder, etc.) to silently never fire. Also fixes duplicate rule loading: when the hook runs with cwd=$HOME, the project-level pattern (.claude/hookify.*.local.md) and the global pattern (~/.claude/hookify.*.local.md) resolve to the same files. Added deduplication by resolved absolute path before loading. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two bugs causing prompt-event hookify rules to silently never fire:
1. Wrong key for UserPromptSubmit input
rule_engine.pyreadsinput_data.get('user_prompt', '')but Claude Code'sUserPromptSubmithook sends the user's message under the keyprompt, notuser_prompt. The result: any rule withfield: user_promptalways receives an empty string and never matches.Affected rules: all prompt-event rules (
use-superpowers,decision-capture,meetsync-reminder, etc.).2. Duplicate rule loading when cwd is home
config_loader.pysearches two glob patterns:.claude/hookify.*.local.md(project-level, relative to cwd)~/.claude/hookify.*.local.md(global)When the hook runs with
cwd=$HOME(which Claude Code does), both patterns resolve to the same files. Every rule is loaded twice, causing duplicatesystemMessageoutput.Fix
rule_engine.py: fall back topromptwhenuser_promptis absent:config_loader.py: deduplicate by resolved absolute path before loading:Test
Should now return a non-empty
systemMessagefor any matching prompt-event rule.🤖 Generated with Claude Code