generate-hook

Generate PreToolUse or PostToolUse hook skeletons from CLAUDE.md correction rules.

8|5|Updated Feb 18, 2026
One-click install
npx skills add https://github.com/shenxingy/Clade --skill generate-hook
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: generate-hook
Source: https://github.com/shenxingy/Clade/tree/main/configs/skills/generate-hook
Command: npx skills add https://github.com/shenxingy/Clade --skill generate-hook

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Generate-hook converts mature Claude Code correction rules into practical hook skeletons so you can automatically warn or block problematic tool behavior without manually writing boilerplate.

Core Features & Use Cases

  • Rule-to-hook generation: Creates a PreToolUse or PostToolUse hook template from a selected rule text or rule number.
  • Smart hook-type selection: Infers hook type and matcher (Edit/Write vs Bash) based on rule patterns like “never use…”, “don’t run…”, or “always check…”.
  • Local deployment instructions: Produces a ready-to-add settings.json snippet and places the generated hook script into the expected hooks directory.

Example use case: If your CLAUDE.md rule says “Before deploying, verify tests passed,” generate-hook can scaffold a PreToolUse hook that inspects the relevant deploy-related tool inputs and returns warning feedback by default.

Quick Start

Ask an AI editor to run generate-hook with your rule text or the rule number, then copy the shown settings.json entry into your ~/.claude/settings.json.

Frequently Asked Questions about generate-hook

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I turn CLAUDE.md correction rules into enforceable Claude Code hooks?

Yes, you can automatically enforce bash safety rules in Claude Code by generating a PreToolUse hook from your existing correction rules. The hook inspects Bash tool inputs and returns warning feedback by default to prevent problematic commands from executing.

How do I generate a settings.json hook entry from a specific rule number?

To generate a settings.json hook entry from a specific rule number, provide the rule number to the hook generator. It infers the correct hook type and matcher, then produces a ready-to-add settings.json snippet and places the generated script into the expected hooks directory.

Does Claude Code hook generation support warn-only enforcement for Edit and Write tools?

Yes, Claude Code hook generation supports warn-only enforcement by default for Edit and Write tools. It creates a PostToolUse or PreToolUse hook skeleton that inspects tool inputs and returns warning feedback rather than hard-blocking the operation.

What is the best way to automate rule checking for Claude Code tool usage?

The best way to automate rule checking for Claude Code tool usage is converting mature correction rules into PreToolUse or PostToolUse hooks. This approach automatically inspects Edit, Write, or Bash tool inputs against your defined rules and provides immediate feedback.

Why are my Claude Code hooks not matching Bash or Edit tool calls correctly?

If your Claude Code hooks are not matching Bash or Edit tool calls correctly, the matcher in your settings.json may be misconfigured. Hook generation tools infer the correct matcher based on rule patterns like “don’t run…” or “never use…” to ensure proper tool targeting.