hookify
Create hooks to prevent unwanted behaviors from conversation analysis or explicit instructions
- 0
- Installs
- —
- Rating
- —
- Success rate
- 1
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 85c2652ee66b5092… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
hookify.md
Hookify - Create Hooks from Unwanted Behaviors
FIRST: Load the hookify:writing-rules skill using the Skill tool to understand rule file format and syntax.
Create hook rules to prevent problematic behaviors by analyzing the conversation or from explicit user instructions.
Your Task
You will help the user create hookify rules to prevent unwanted behaviors. Follow these steps:
Step 1: Gather Behavior Information
If $ARGUMENTS is provided:
- User has given specific instructions:
$ARGUMENTS - Still analyze recent conversation (last 10-15 user messages) for additional context
- Look for examples of the behavior happening
If $ARGUMENTS is empty:
- Launch the conversation-analyzer agent to find problematic behaviors
- Agent will scan user prompts for frustration signals
- Agent will return structured findings
To analyze conversation: Use the Task tool to launch conversation-analyzer agent:
{
"subagent_type": "general-purpose",
"description": "Analyze conversation for unwanted behaviors",
"prompt": "You are analyzing a Claude Code conversation to find behaviors the user wants to prevent.
Read user messages in the current conversation and identify:
1. Explicit requests to avoid something (\"don't do X\", \"stop doing Y\")
2. Corrections or reversions (user fixing Claude's actions)
3. Frustrated reactions (\"why did you do X?\", \"I didn't ask for that\")
4. Repeated issues (same problem multiple times)
For each issue found, extract:
- What tool was used (Bash, Edit, Write, etc.)
- Specific pattern or command
- Why it was problematic
- User's stated reason
Return findings as a structured list with:
- category: Type of issue
- tool: Which tool was involved
- pattern: Regex or literal pattern to match
- context: What happened
- severity: high/medium/low
Focus on the most recent issues (last 20-30 messages). Don't go back further unless explicitly asked."
}
Step 2: Present Findings to User
After gathering behaviors (from arguments or agent), present to user using AskUserQuestion:
Question 1: Which behaviors to hookify?
- Header: "Create Rules"
- multiSelect: true
- Options: List each detected behavior (max 4)
- Label: Short description (e.g., "Block rm -rf")
- Description: Why it's problematic
Question 2: For each selected behavior, ask about action:
- "Should this block the operation or just warn?"
- Options:
- "Just warn" (action: warn - shows message but allows)
- "Block operation" (action: block - prevents execution)
Question 3: Ask for example patterns:
- "What patterns should trigger this rule?"
- Show detected patterns
- Allow user to refine or add more
Step 3: Generate Rule Files
For each confirmed behavior, create a .claude/hookify.{rule-name}.local.md file:
Rule naming convention:
- Use kebab-case
- Be descriptive:
block-dangerous-rm,warn-console-log,require-tests-before-stop - Start with action verb: block, warn, prevent, require
File format:
---
name: {rule-name}
enabled: true
event: {bash|file|stop|prompt|all}
pattern: {regex pattern}
action: {warn|block}
---
{Message to show Claude when rule triggers}
Action values:
warn: Show message but allow operation (default)block: Prevent operation or stop session
For more complex rules (multiple conditions):
---
name: {rule-name}
enabled: true
event: file
conditions:
- field: file_path
operator: regex_match
pattern: \.env$
- field: new_text
operator: contains
pattern: API_KEY
---
{Warning message}
Step 4: Create Files and Confirm
IMPORTANT: Rule files must be created in the current working directory's .claude/ folder, NOT the plugin directory.
Use the current working directory (where Claude Code was started) as the base path.
-
Check if
.claude/directory exists in current working directory- If not, create it first with:
mkdir -p .claude
- If not, create it first with:
-
Use Write tool to create each
.claude/hookify.{name}.local.mdfile- Use relative path from current working directory:
.claude/hookify.{name}.local.md - The path should resolve to the project's .claude directory, not the plugin's
- Use relative path from current working directory:
-
Show user what was created:
Created 3 hookify rules: - .claude/hookify.dangerous-rm.local.md - .claude/hookify.console-log.local.md - .claude/hookify.sensitive-files.local.md These rules will trigger on: - dangerous-rm: Bash commands matching "rm -rf" - console-log: Edits adding console.log statements - sensitive-files: Edits to .env or credentials files -
Verify files were created in the correct location by listing them
-
Inform user: "Rules are active immediately - no restart needed!"
The hookify hooks are already loaded and will read your new rules on the next tool use.
Event Types Reference
- bash: Matches Bash tool commands
- file: Matches Edit, Write, MultiEdit tools
- stop: Matches when agent wants to stop (use for completion checks)
- prompt: Matches when user submits prompts
- all: Matches all events
Pattern Writing Tips
Bash patterns:
- Match dangerous commands:
rm\s+-rf|chmod\s+777|dd\s+if= - Match specific tools:
npm\s+install\s+|pip\s+install
File patterns:
- Match code patterns:
console\.log\(|eval\(|innerHTML\s*= - Match file paths:
\.env$|\.git/|node_modules/
Stop patterns:
- Check for missing steps: (check transcript or completion criteria)
Example Workflow
User says: "/hookify Don't use rm -rf without asking me first"
Your response:
- Analyze: User wants to prevent rm -rf commands
- Ask: "Should I block this command or just warn you?"
- User selects: "Just warn"
- Create
.claude/hookify.dangerous-rm.local.md:--- name: warn-dangerous-rm enabled: true event: bash pattern: rm\s+-rf --- ⚠️ **Dangerous rm command detected** You requested to be warned before using rm -rf. Please verify the path is correct. - Confirm: "Created hookify rule. It's active immediately - try triggering it!"
Important Notes
- No restart needed: Rules take effect immediately on the next tool use
- File location: Create files in project's
.claude/directory (current working directory), NOT the plugin's .claude/ - Regex syntax: Use Python regex syntax (raw strings, no need to escape in YAML)
- Action types: Rules can
warn(default) orblockoperations - Testing: Test rules immediately after creating them
Troubleshooting
If rule file creation fails:
- Check current working directory with pwd
- Ensure
.claude/directory exists (create with mkdir if needed) - Use absolute path if needed:
{cwd}/.claude/hookify.{name}.local.md - Verify file was created with Glob or ls
If rule doesn't trigger after creation:
- Verify file is in project
.claude/not plugin.claude/ - Check file with Read tool to ensure pattern is correct
- Test pattern with:
python3 -c "import re; print(re.search(r'pattern', 'test text'))" - Verify
enabled: truein frontmatter - Remember: Rules work immediately, no restart needed
If blocking seems too strict:
- Change
action: blocktoaction: warnin the rule file - Or adjust the pattern to be more specific
- Changes take effect on next tool use
Use TodoWrite to track your progress through the steps.
Files
1- hookify.md
7560e58edc7.5 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from anthropics/claude-plugins-official8
Cancel active Ralph Loop
Cleans up all git branches marked as [gone] (branches that have been deleted on the remote but still exist locally), including removing associated worktrees.
Code review a pull request
Create a git commit
Commit, push, and open a PR
Enable or disable hookify rules interactively
Stand up an Anthropic MCP tunnel locally with Docker Compose so Claude can call a private MCP server (manual-credentials quickstart).
Guided end-to-end plugin creation workflow with component design, implementation, and validation
Related knowledge skillsscan passed
Explain Stripe error codes and provide solutions with code examples
Simplify code for clarity and maintainability — reduce complexity without changing behavior
Creates Semgrep rules with test-first methodology
Generate a single wiki page with dark-mode Mermaid diagrams, source citations, and first-principles depth
Run Sanity TypeGen and troubleshoot type generation issues.
Generate comprehensive market opportunity analysis with TAM/SAM/SOM calculations