Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/hookify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ Ensure credentials are not hardcoded and file is in .gitignore.

- **`bash`**: Triggers on Bash tool commands
- **`file`**: Triggers on Edit, Write, MultiEdit tools
- **`read`**: Triggers on Read, Glob, Grep, LS tools (file reads, not modifications)
- **`stop`**: Triggers when Claude wants to stop (for completion checks)
- **`prompt`**: Triggers on user prompt submission
- **`all`**: Triggers on all events
Expand Down
8 changes: 7 additions & 1 deletion plugins/hookify/hooks/posttooluse.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ def main():
# Read input from stdin
input_data = json.load(sys.stdin)

# Determine event type based on tool
# Map tools to event types for rule filtering:
# - 'bash': Bash commands
# - 'file': File modifications (Edit, Write, MultiEdit)
# - 'read': File reads (Read, Glob, Grep, LS) - should NOT trigger file rules
# - None: Other tools - only 'all' rules fire
tool_name = input_data.get('tool_name', '')
event = None
if tool_name == 'Bash':
event = 'bash'
elif tool_name in ['Edit', 'Write', 'MultiEdit']:
event = 'file'
elif tool_name in ['Read', 'Glob', 'Grep', 'LS']:
event = 'read'

# Load rules
rules = load_rules(event=event)
Expand Down
7 changes: 7 additions & 0 deletions plugins/hookify/hooks/pretooluse.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ def main():
# For PreToolUse, we use tool_name to determine "bash" vs "file" event
tool_name = input_data.get('tool_name', '')

# Map tools to event types for rule filtering:
# - 'bash': Bash commands
# - 'file': File modifications (Edit, Write, MultiEdit)
# - 'read': File reads (Read, Glob, Grep, LS) - should NOT trigger file rules
# - None: Other tools - only 'all' rules fire
event = None
if tool_name == 'Bash':
event = 'bash'
elif tool_name in ['Edit', 'Write', 'MultiEdit']:
event = 'file'
elif tool_name in ['Read', 'Glob', 'Grep', 'LS']:
event = 'read'

# Load rules
rules = load_rules(event=event)
Expand Down
2 changes: 2 additions & 0 deletions plugins/hookify/skills/writing-rules/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Can include markdown formatting, warnings, suggestions, etc.
**event** (required): Which hook event to trigger on
- `bash`: Bash tool commands
- `file`: Edit, Write, MultiEdit tools
- `read`: Read, Glob, Grep, LS tools (file reads, not modifications)
- `stop`: When agent wants to stop
- `prompt`: When user submits a prompt
- `all`: All events
Expand Down Expand Up @@ -361,6 +362,7 @@ Warning message
**Event types:**
- `bash` - Bash commands
- `file` - File edits
- `read` - File reads (Read, Glob, Grep, LS)
- `stop` - Completion checks
- `prompt` - User input
- `all` - All events
Expand Down