Claude Code hook

Claudecode Rule2hook

Transform natural language project rules into Claude Code automation hooks - Write rules in plain English and let Claude automatically generate powerful hooks for code formatting, testing, validation and more

403 stars 59 forksHooks Source

Install

From source
git clone https://github.com/zxdxjtu/claudecode-rule2hook.git

From the README

claudecode-rule2hook 🪝

Convert natural language project rules into Claude Code hooks automatically! Write rules in plain English, and let Claude transform them into powerful automation hooks.

✨ Features

- 🎯 Natural Language Processing - Write rules in plain English
- 🔄 Automatic Hook Generation - Converts rules to proper hook configurations
- 🧠 Smart Detection - Intelligently identifies events, tools, and commands
- 📝 CLAUDE.md Integration - Reads from existing project memory files
- 🛡️ Safe Configuration - Backs up existing hooks before applying changes
- 🚀 Zero Dependencies - Works directly with Claude Code

📦 Installation

Option 1: Project-Specific Installation (Recommended)

To use the rule2hook command in your own project:

Option 2: Global Installation

To make the command available in all projects:

Option 3: Use Directly in This Repository

How it works

Claude Code discovers slash commands by scanning:
1. ~/.claude/commands/ for global commands (accessible as /commandname)
2. .claude/commands/ in the current project for project-specific commands (accessible as /project:commandname)

Important: You must be in the correct directory when using Claude Code for the commands to be available.

🚀 Quick Start

After installation, in Claude Code, type:

📚 How It Works

1. Input - Provide rules as text or let Claude read from CLAUDE.md
2. Analysis - Claude analyzes rules to determine:
   - Trigger events (before/after actions)
   - Target tools (Edit, Write, Bash, etc.)
   - Commands to execute
3. Generation - Creates proper hook configurations
4. Application - Saves hooks to ~/.claude/hooks.json

🎯 Examples

Example 1: Code Formatting

Input:

Generated Hook:

Example 2: Git Workflow

Input:

Generated Hook:

📋 Supported Rule Patterns

- Formatting:…
Read the full README on GitHub

How hooks work

  • Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
  • They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
  • A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Claude Code docs

Details

Type
Hooks
Language
Python
License
MIT
Last updated
1 July 2025

FAQ

What is Claudecode Rule2hook?

Transform natural language project rules into Claude Code automation hooks - Write rules in plain English and let Claude automatically generate powerful hooks for code formatting, testing, validation and more It is a hook for Claude Code, from zxdxjtu/claudecode-rule2hook on GitHub.

How do I install Claudecode Rule2hook?

Clone zxdxjtu/claudecode-rule2hook from GitHub and follow the setup steps in its README.

Is Claudecode Rule2hook popular?

zxdxjtu/claudecode-rule2hook has 403 GitHub stars and 59 forks. It was last updated on 1 July 2025.

More hooks

Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.