mirror of
https://github.com/anthropics/claude-code.git
synced 2026-01-30 04:02:03 +00:00
Adds the hookify plugin to public marketplace. Enables users to create custom hooks using simple markdown configuration files instead of editing JSON. Key features: - Define rules with regex patterns to warn/block operations - Create rules from explicit instructions or conversation analysis - Pattern-based matching for bash commands, file edits, prompts, stop events - Enable/disable rules dynamically without editing code - Conversation analyzer agent finds problematic behaviors Changes from internal version: - Removed non-functional SessionStart hook (not registered in hooks.json) - Removed all sessionstart documentation and examples - Fixed restart documentation to consistently state "no restart needed" - Changed license from "Internal Anthropic use only" to "MIT License" - Kept test blocks in core modules (useful for developers) Plugin provides: - 4 commands: /hookify, /hookify:list, /hookify:configure, /hookify:help - 1 agent: conversation-analyzer - 1 skill: writing-rules - 4 hook types: PreToolUse, PostToolUse, Stop, UserPromptSubmit - 4 example rules ready to use All features functional and suitable for public use. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
129 lines
2.8 KiB
Markdown
129 lines
2.8 KiB
Markdown
---
|
|
description: Enable or disable hookify rules interactively
|
|
allowed-tools: ["Glob", "Read", "Edit", "AskUserQuestion", "Skill"]
|
|
---
|
|
|
|
# Configure Hookify Rules
|
|
|
|
**Load hookify:writing-rules skill first** to understand rule format.
|
|
|
|
Enable or disable existing hookify rules using an interactive interface.
|
|
|
|
## Steps
|
|
|
|
### 1. Find Existing Rules
|
|
|
|
Use Glob tool to find all hookify rule files:
|
|
```
|
|
pattern: ".claude/hookify.*.local.md"
|
|
```
|
|
|
|
If no rules found, inform user:
|
|
```
|
|
No hookify rules configured yet. Use `/hookify` to create your first rule.
|
|
```
|
|
|
|
### 2. Read Current State
|
|
|
|
For each rule file:
|
|
- Read the file
|
|
- Extract `name` and `enabled` fields from frontmatter
|
|
- Build list of rules with current state
|
|
|
|
### 3. Ask User Which Rules to Toggle
|
|
|
|
Use AskUserQuestion to let user select rules:
|
|
|
|
```json
|
|
{
|
|
"questions": [
|
|
{
|
|
"question": "Which rules would you like to enable or disable?",
|
|
"header": "Configure",
|
|
"multiSelect": true,
|
|
"options": [
|
|
{
|
|
"label": "warn-dangerous-rm (currently enabled)",
|
|
"description": "Warns about rm -rf commands"
|
|
},
|
|
{
|
|
"label": "warn-console-log (currently disabled)",
|
|
"description": "Warns about console.log in code"
|
|
},
|
|
{
|
|
"label": "require-tests (currently enabled)",
|
|
"description": "Requires tests before stopping"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
**Option format:**
|
|
- Label: `{rule-name} (currently {enabled|disabled})`
|
|
- Description: Brief description from rule's message or pattern
|
|
|
|
### 4. Parse User Selection
|
|
|
|
For each selected rule:
|
|
- Determine current state from label (enabled/disabled)
|
|
- Toggle state: enabled → disabled, disabled → enabled
|
|
|
|
### 5. Update Rule Files
|
|
|
|
For each rule to toggle:
|
|
- Use Read tool to read current content
|
|
- Use Edit tool to change `enabled: true` to `enabled: false` (or vice versa)
|
|
- Handle both with and without quotes
|
|
|
|
**Edit pattern for enabling:**
|
|
```
|
|
old_string: "enabled: false"
|
|
new_string: "enabled: true"
|
|
```
|
|
|
|
**Edit pattern for disabling:**
|
|
```
|
|
old_string: "enabled: true"
|
|
new_string: "enabled: false"
|
|
```
|
|
|
|
### 6. Confirm Changes
|
|
|
|
Show user what was changed:
|
|
|
|
```
|
|
## Hookify Rules Updated
|
|
|
|
**Enabled:**
|
|
- warn-console-log
|
|
|
|
**Disabled:**
|
|
- warn-dangerous-rm
|
|
|
|
**Unchanged:**
|
|
- require-tests
|
|
|
|
Changes apply immediately - no restart needed
|
|
```
|
|
|
|
## Important Notes
|
|
|
|
- Changes take effect immediately on next tool use
|
|
- You can also manually edit .claude/hookify.*.local.md files
|
|
- To permanently remove a rule, delete its .local.md file
|
|
- Use `/hookify:list` to see all configured rules
|
|
|
|
## Edge Cases
|
|
|
|
**No rules to configure:**
|
|
- Show message about using `/hookify` to create rules first
|
|
|
|
**User selects no rules:**
|
|
- Inform that no changes were made
|
|
|
|
**File read/write errors:**
|
|
- Inform user of specific error
|
|
- Suggest manual editing as fallback
|