// 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.
| name | hook-factory |
| description | 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. |
| version | 2.0.0 |
| author | Claude Code Skills Factory |
| tags | ["hooks","automation","code-generation","workflow","productivity","interactive","installer"] |
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: 3. subagent_stop_test_runner - Run tests when agent completes 4. pre_tool_use_validation - Validate before tool execution 5. pre_push_validation - Check before git push
Session Management: 6. session_start_load_context - Load context at session start 7. stop_session_cleanup - Cleanup at session end
User Interaction: 8. user_prompt_submit_preprocessor - Pre-process user prompts 9. notify_user_desktop - Desktop notifications (macOS/Linux)
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:
Review Generated Files
cd generated-hooks/[hook-name]
cat README.md
cat hook.json
Manual Installation
.claude/settings.json (project) or ~/.claude/settings.json (user)hook.jsonVerify
~/.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