Generate production-ready Claude Code hooks with interactive Q&A, automated installation, and enhanced validation. Supports 10 templates across 7 event types for comprehensive workflow automation.
npx skills add https://github.com/alirezarezvani/claude-code-skill-factory --skill hook-factory
Generate production-ready Claude Code hooks with interactive Q&A, automated installation, and enhanced validation.
Hook Factory v2.0 is a comprehensive hook generation system with three modes:
Key Features:
Use hook-factory when you want to:
1. Interactive Mode (Recommended)
python3 hook_factory.py -i
2. Natural Language Mode
python3 hook_factory.py -r "auto-format Python files after editing"
3. Template Mode (Advanced)
python3 hook_factory.py -t post_tool_use_format -l python
Formatting & Code Quality:
Testing & Validation:
Session Management:
User Interaction:
Security:
10. security_scan_code - Security scanning with semgrep/bandit
4-Layer Validation System:
NEW in v2.0:
Every generated hook includes:
Simply describe what you want the hook to do:
"I want to auto-format Python files after editing"
"Create a hook that runs tests when agents complete"
"Auto-add files to git after editing"
"Load my TODO.md at session start"
If you know which template you want:
"Generate a hook using the post_tool_use_format template for JavaScript"
"Create a test runner hook for Rust"
"Show me all available hook templates"
"List hook templates"
You: "I need a hook to auto-format my Python code after editing"
Hook Factory:
post_tool_use_formatgenerated-hooks/auto-format-code-after-editing-python/hook.json and README.mdYou: "Automatically stage files with git when I edit them"
Hook Factory:
post_tool_use_git_addgenerated-hooks/auto-add-files-to-git-after-editing/You: "Run my JavaScript tests after the agent finishes coding"
Hook Factory:
subagent_stop_test_runnergenerated-hooks/run-tests-when-agent-completes-javascript/For each hook, Hook Factory creates:
generated-hooks/
└── [hook-name]/
├── hook.json # Complete hook configuration (validated)
└── README.md # Installation guide, usage, troubleshooting
Valid JSON configuration ready to copy into your Claude Code settings:
{
"matcher": {
"tool_names": ["Write", "Edit"]
},
"hooks": [
{
"type": "command",
"command": "if ! command -v black &> /dev/null; then\n exit 0\nfi\n\nif [[ \"$CLAUDE_TOOL_FILE_PATH\" == *.py ]]; then\n black \"$CLAUDE_TOOL_FILE_PATH\" || exit 0\nfi",
"timeout": 60
}
]
}
Comprehensive documentation including:
Using Python Installer:
cd generated-skills/hook-factory
# Install to user level (~/.claude/settings.json)
python3 installer.py install generated-hooks/[hook-name] user
# Install to project level (.claude/settings.json)
python3 installer.py install generated-hooks/[hook-name] project
# Uninstall
python3 installer.py uninstall [hook-name] user
# List installed hooks
python3 installer.py list user
Using Bash Script (macOS/Linux):
cd generated-skills/hook-factory
# Install
./install-hook.sh generated-hooks/[hook-name] user
# Features:
# - Automatic backup with timestamp
# - JSON validation before/after
# - Atomic write operations
# - Rollback on failure
# - Keeps last 5 backups
Auto-Install from Interactive Mode:
cd generated-hooks/[hook-name]
cat README.md
cat hook.json
.claude/settings.json (project) or ~/.claude/settings.json (user)hook.json~/.claude/logs/Every hook is validated for:
~/.claude/logs/ if hooks aren't workingPlatform Support:
Customization:
Template System:
Core Files:
SKILL.md - This manifest filehook_factory.py - Main orchestrator with CLI interface (687 lines)generator.py - Template substitution and hook generationvalidator.py - Enhanced validation engine (700+ lines)templates.json - 10 production hook templatesREADME.md - Skill usage guide and examplesNEW in v2.0:
installer.py - Automated installation system (536 lines)install-hook.sh - Bash installation script (148 lines)examples/ - 10 reference examples (10 folders × 2 files)Interactive Mode Flow:
User: python3 hook_factory.py -i
↓
[7-Question Flow with Smart Defaults]
↓
[Template Selection]
↓
[Variable Substitution]
↓
[4-Layer Validation]
↓
[File Generation]
↓
[Optional: Auto-Install via installer.py]
↓
Generated Hook in generated-hooks/ + Installed
Natural Language Flow:
User Request
↓
[Keyword Matching]
↓
[Template Selection]
↓
[Variable Substitution]
↓
[4-Layer Validation]
↓
[File Generation]
↓
Generated Hook in generated-hooks/
Installation Flow:
Hook Folder
↓
[installer.py or install-hook.sh]
↓
[Backup settings.json]
↓
[Load + Validate JSON]
↓
[Merge Hook]
↓
[Atomic Write (temp → rename)]
↓
[Validate Result]
↓
✅ Installed (or ❌ Rollback)
The examples/ directory contains reference implementations:
examples/
├── auto-format-python/ # PostToolUse format example
├── git-auto-add/ # PostToolUse git example
├── test-runner/ # SubagentStop test example
└── load-context/ # SessionStart context example
Each example includes working hook.json and README.md files you can copy directly.
To add new hook patterns:
templates.jsongenerator.pyexamples/Generated by Claude Code Skills Factory
Last Updated: 2025-10-30
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.
Build agentic applications with GitHub Copilot SDK. Use when embedding AI agents in apps, creating custom tools, implementing streaming responses, managing sessions, connecting to MCP servers, or creating custom agents. Triggers on Copilot SDK, GitHub SDK, agentic app, embed Copilot, programmable agent, MCP server, custom agent.
Coding Agent Session Search - unified CLI/TUI to index and search local coding agent history from Claude Code, Codex, Gemini, Cursor, Aider, ChatGPT, Pi-Agent, Factory, and more. Purpose-built for AI agent consumption with robot mode.
Destructive Command Guard - High-performance Rust hook for Claude Code that blocks dangerous commands before execution. SIMD-accelerated, modular pack system, whitelist-first architecture. Essential safety layer for agent workflows.
Makepad UI development skills for Rust apps: setup, patterns, shaders, packaging, and troubleshooting.
Secure environment variable management ensuring secrets are never exposed in Claude sessions, terminals, logs, or git commits
Prompt for generating an AGENTS.md file for a repository
Take alirezarezvani/hook-factory from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.