A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
Transform natural language project rules into Claude Code automation hooks - Write rules in plain English and let Claude
Convert natural language project rules into Claude Code hooks automatically! Write rules in plain English, and let Claude transform them into powerful automation hooks.
To use the rule2hook command in your own project:
# 1. Clone this repository
git clone https://github.com/zxdxjtu/claudecode-rule2hook.git
# 2. Copy the command to your project
mkdir -p your-project/.claude/commands
cp claudecode-rule2hook/.claude/commands/rule2hook.md your-project/.claude/commands/
# 3. Use in your project
cd your-project
# Now /project:rule2hook is available when using Claude Code in this directory
To make the command available in all projects:
# Clone the repository
git clone https://github.com/zxdxjtu/claudecode-rule2hook.git
# Copy to global Claude commands directory
mkdir -p ~/.claude/commands
cp claudecode-rule2hook/.claude/commands/rule2hook.md ~/.claude/commands/
# Now /rule2hook is available globally (without /project: prefix)
# Clone and use directly
git clone https://github.com/zxdxjtu/claudecode-rule2hook.git
cd claudecode-rule2hook
# The /project:rule2hook command is available in this directory only
Claude Code discovers slash commands by scanning:
~/.claude/commands/ for global commands (accessible as /commandname).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.
After installation, in Claude Code, type:
# If using project-specific installation (Option 1)
/project:rule2hook "Format Python files with black after editing"
# If using global installation (Option 2)
/rule2hook "Format Python files with black after editing"
# Convert rules from CLAUDE.md
/project:rule2hook # or /rule2hook if global
# Convert multiple rules
/project:rule2hook "Run tests after editing, Format code before committing"
~/.claude/hooks.jsonInput:
Format Python files with black after editing
Generated Hook:
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|MultiEdit|Write",
"hooks": [{
"type": "command",
"command": "black ."
}]
}]
}
}
Input:
Run git status when finishing a task
Generated Hook:
{
"hooks": {
"Stop": [{
"hooks": [{
"type": "command",
"command": "git status"
}]
}]
}
}
"Format [language] files after editing""Run tests when modifying test files""Execute git [command] when [event]""Check/Validate [something] before [action]""Alert/Notify when [condition]"Create a CLAUDE.md file with your project rules:
# Project Rules
- Format Python files with black after editing
- Run tests before committing
- Check for TODO comments before pushing
Then run: /project:rule2hook
/project:rule2hook "Run 'npm run lint && npm test' after editing source files"
/project:rule2hook "Validate JSON schema before saving .json files"
Use the included test tools:
# Interactive testing
./quick-test.sh
# Validate generated hooks
python3 validate-hooks.py
# Test specific rules
cat test-rules.txt
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by the Claude Code community
Give Claude Code memory that evolves with your codebase via hooks and LLM-compiled knowledge
Blocks dangerous git and shell commands from being executed by AI coding agents
Rule enforcement plugin — save rules with natural language, enforce with 17 lifecycle hooks
MCP server plugin for voice input and output in Claude Code