Generate production-ready Claude Code hooks with interactive Q&A, automated installation, and enhanced validation.

MITAuto-check passedAgent Workflows

Install Hook Factory

skills CLI
$ npx skills add alirezarezvani/claude-code-skill-factory --skill hook-factory -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install alirezarezvani/claude-code-skill-factory hook-factory --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/alirezarezvani/claude-code-skill-factory.git skills-src && mkdir -p .claude/skills && cp -r skills-src/generated-skills/hook-factory .claude/skills/hook-factory && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
hook-factory
GitHub stars
880
Token cost
~3.1k tokens
SKILL.md length
1,084 words
Files
32
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

Generate production-ready Claude Code hooks with interactive Q&A, automated installation, and enhanced validation.

  • Works in 3 steps: Interactive Mode (NEW!) - 7-question… → Natural Language - Describe what you… → Template Mode - Direct generation from…
  • Tasks that involve Hooks and plugins
  • SKILL.md covers What This Skill Does, When to Use This Skill, Capabilities and How to Invoke, plus 7 more sections
  • Calls python3

What it does

Hook Factory is an agent skill from alirezarezvani/claude-code-skill-factory. 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.

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 38 other files (for example `README.md`, `examples/auto-format-python/README.md` and `examples/auto-format-python/hook.json`).

It sits in Agent Workflows, covering Hooks and plugins and Workflow automation. It works with Git and Python. The repository describes itself as: Claude Code Skill Factory — A powerful open-source toolkit for building and deploying production-ready Claude Skills, Code Agents, custom Slash Commands, and LLM Prompts at… The licence is MIT.

When your agent uses it

  • Tasks that involve Hooks and plugins
  • Tasks that involve Workflow automation

Example prompts

  • “/hook-factory”

Requirements

  • Python 3

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. Interactive Mode (NEW!) - 7-question guided flow with smart defaults
  2. Natural Language - Describe what you want in plain English
  3. Template Mode - Direct generation from 10 production templates

What it can do on your machine

Read from SKILL.md and the folder at commit ba18b31. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.claude.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Hook Factory loads about 3.1k tokens when it runs. Until then it costs about 52 tokens; SKILL.md has 1,084 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~52
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from alirezarezvani/claude-code-skill-factory at commit ba18b31, republished under its MIT licence (© alirezarezvani). 1,084 words, ~3,146 tokens.

Download SKILL.mdSave it as .claude/skills/hook-factory/SKILL.md (or your agent's skills folder). This skill also uses 31 other files; get the full folder from GitHub.
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

Hook Factory v2.0

Generate production-ready Claude Code hooks with interactive Q&A, automated installation, and enhanced validation.

What This Skill Does

Hook Factory v2.0 is a comprehensive hook generation system with three modes:

  1. Interactive Mode (NEW!) - 7-question guided flow with smart defaults
  2. Natural Language - Describe what you want in plain English
  3. Template Mode - Direct generation from 10 production templates

Key Features:

  • Interactive Q&A - 7 questions with validation and smart defaults
  • Automated Installation - Python and Bash installers with backup/rollback
  • Enhanced Validation - Secrets detection, event-specific rules, command validation
  • 10 Templates - Covering 7 event types (PostToolUse, SubagentStop, SessionStart, PreToolUse, UserPromptSubmit, Stop, PrePush)
  • Comprehensive Safety - Tool detection, silent failure, atomic operations
  • macOS/Linux Support - Production-ready for Unix environments

When to Use This Skill

Use hook-factory when you want to:

  • Auto-format code after editing
  • Automatically stage files with git
  • Run tests when agents complete
  • Load project context at session start
  • Create custom workflow automation
  • Learn how hooks work through examples

Capabilities

Three Generation Modes

1. Interactive Mode (Recommended)

bash
python3 hook_factory.py -i
  • 7-question guided flow
  • Smart defaults based on event type
  • Input validation and safety warnings
  • Optional auto-install

2. Natural Language Mode

bash
python3 hook_factory.py -r "auto-format Python files after editing"
  • Simple keyword matching
  • Quick generation for common patterns

3. Template Mode (Advanced)

bash
python3 hook_factory.py -t post_tool_use_format -l python
  • Direct template selection
  • Full customization control
Supported Hook Templates (10 Total)

Formatting & Code Quality:

  1. post_tool_use_format - Auto-format after editing (Python, JS, TS, Rust, Go)
  2. post_tool_use_git_add - Auto-stage files with git

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

Languages Supported
  • Python (black formatter, pytest)
  • JavaScript (prettier, jest)
  • TypeScript (prettier, jest)
  • Rust (rustfmt, cargo test)
  • Go (gofmt, go test)
Enhanced Validation (v2.0)

4-Layer Validation System:

  1. Structure Validation - JSON syntax, required fields, types
  2. Safety Validation - No destructive ops, tool detection, silent failure
  3. Matcher Validation - Valid glob patterns, tool names, file paths
  4. Event-Specific Validation - Rules per event type (PreToolUse, SessionStart, etc.)

NEW in v2.0:

  • ✅ Secrets Detection - AWS keys, JWT tokens, API keys, private keys (20+ patterns)
  • ✅ Event-Specific Rules - PreToolUse must have tool matcher, SessionStart read-only, etc.
  • ✅ Command Validation - Bash syntax, Unix commands, path validation, dangerous operations
  • ✅ macOS/Linux Validation - Platform-specific command checks
Safety Features

Every generated hook includes:

  • ✅ Tool detection (checks if required tools are installed)
  • ✅ Silent failure mode (never interrupts your workflow)
  • ✅ Appropriate timeout settings (5s-120s based on event type)
  • ✅ No destructive operations
  • ✅ Comprehensive validation before generation
  • ✅ Clear documentation and troubleshooting guides
  • ✅ Automatic backup during installation

How to Invoke

Natural Language Requests

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"
Explicit Template Selection

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"
List Available Templates
"Show me all available hook templates"
"List hook templates"

Example Interactions

Example 1: Auto-Format Python

You: "I need a hook to auto-format my Python code after editing"

Hook Factory:

  • Detects template: post_tool_use_format
  • Detects language: Python
  • Generates hook with black formatter
  • Validates configuration
  • Saves to generated-hooks/auto-format-code-after-editing-python/
  • Creates hook.json and README.md
Example 2: Git Auto-Add

You: "Automatically stage files with git when I edit them"

Hook Factory:

  • Detects template: post_tool_use_git_add
  • Generates git auto-add hook
  • Validates git commands
  • Saves to generated-hooks/auto-add-files-to-git-after-editing/
Example 3: Test Runner

You: "Run my JavaScript tests after the agent finishes coding"

Hook Factory:

  • Detects template: subagent_stop_test_runner
  • Detects language: JavaScript
  • Configures jest/npm test
  • Saves to generated-hooks/run-tests-when-agent-completes-javascript/

Output Structure

For each hook, Hook Factory creates:

generated-hooks/
└── [hook-name]/
    ├── hook.json        # Complete hook configuration (validated)
    └── README.md        # Installation guide, usage, troubleshooting
hook.json

Valid JSON configuration ready to copy into your Claude Code settings:

json
{
  "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
    }
  ]
}
README.md

Comprehensive documentation including:

  • Overview and how it works
  • Prerequisites
  • Installation instructions (manual)
  • Configuration options
  • Safety notes
  • Troubleshooting guide
  • Advanced customization tips

Installation of Generated Hooks

Automated Installation (NEW in v2.0!)

Using Python Installer:

bash
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):

bash
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:

  • Answer 'y' to Q7 (Auto-Install)
  • Hook is automatically installed
  • No manual steps required
Show full SKILL.md (461 more words)Show less
Manual Installation (Legacy)
  1. Review Generated Files

    bash
    cd generated-hooks/[hook-name]
    cat README.md
    cat hook.json
  2. Manual Installation

    • Open .claude/settings.json (project) or ~/.claude/settings.json (user)
    • Copy the hook configuration from hook.json
    • Add to the appropriate event type array
    • Save and restart Claude Code
  3. Verify

    • Check Claude Code logs: ~/.claude/logs/
    • Test the hook by performing the trigger action

Validation

Every hook is validated for:

  • JSON Syntax: Valid, parseable JSON
  • Structure: Required fields present and correct types
  • Safety: No destructive operations (rm -rf, etc.)
  • Tool Detection: External tools have detection checks
  • Silent Failure: Commands won't interrupt workflow
  • Timeouts: Appropriate for event type
  • Matchers: Valid glob patterns and tool names

Best Practices

  1. Start Simple: Use natural language requests for common patterns
  2. Review Before Installing: Always read the generated README.md
  3. Test in Isolation: Try hooks in a test project first
  4. Customize Gradually: Start with defaults, customize later
  5. Monitor Logs: Check ~/.claude/logs/ if hooks aren't working

Limitations

Platform Support:

  • ✅ macOS and Linux fully supported
  • ❌ Windows not supported (Unix commands, bash-specific syntax)

Customization:

  • Interactive mode provides smart defaults but limited deep customization
  • Advanced users should use template mode + manual editing
  • No GUI - CLI only

Template System:

  • 10 templates cover common patterns
  • Custom templates require manual addition to templates.json
  • No template composition yet (combining multiple patterns)

Technical Details

Files in This Skill

Core Files:

  • SKILL.md - This manifest file
  • hook_factory.py - Main orchestrator with CLI interface (687 lines)
  • generator.py - Template substitution and hook generation
  • validator.py - Enhanced validation engine (700+ lines)
  • templates.json - 10 production hook templates
  • README.md - Skill usage guide and examples

NEW 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)
Dependencies
  • Python 3.7+
  • Standard library only (no external dependencies)
Architecture (v2.0)

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)

Troubleshooting

"Could not determine hook type from request"
  • Use more specific keywords (format, test, git add, load)
  • Or use explicit template selection
  • Or list templates to see what's available
Generated hook not working
  • Check Claude Code logs
  • Verify required tools are installed
  • Test command manually in terminal
  • Review README.md troubleshooting section
Validation errors
  • Review error messages and fix suggestions
  • Common issues: missing tool detection, destructive commands
  • Modify template if needed

Examples Directory

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.

Contributing

To add new hook patterns:

  1. Add template to templates.json
  2. Update keyword matching in generator.py
  3. Add example to examples/
  4. Update this SKILL.md

Version History

  • 1.0.0 (2025-10-30): Initial release
    • 4 core hook patterns
    • Natural language generation
    • Comprehensive validation
    • Simple keyword matching

Support


Generated by Claude Code Skills Factory Last Updated: 2025-10-30

© alirezarezvani, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 31 other files in generated-skills/hook-factory of alirezarezvani/claude-code-skill-factory.

  • SKILL.md
  • README.md
  • examples/auto-format-python/README.md
  • examples/auto-format-python/hook.json
  • examples/desktop-notify/README.md
  • examples/desktop-notify/hook.json
  • examples/git-auto-add/README.md
  • examples/git-auto-add/hook.json
  • examples/load-context/README.md
  • examples/load-context/hook.json
  • examples/pre-push-check/README.md
  • examples/pre-push-check/hook.json
  • examples/pre-tool-validation/README.md
  • examples/pre-tool-validation/hook.json
  • … and 18 more

Open the folder on GitHubat commit ba18b31

Compare with similar skills

Hook Factory next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Hook Factory compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Hook Factory this skillalirezarezvani/claude-code-skill-factory880—~3.1kAutomated safety check: PassMIT
Publish Plugins Version Bumpvinta/hal-9000138—~1kAutomated safety check: PassMIT
Rule Catalogathola/claude-night-market341—~1.6kAutomated safety check: PassMIT
Faq Shortcutskishormorol/cli-faq-shortcuts127—~1.4kAutomated safety check: PassApache-2.0
Rpa Initcoddy-project/coddy-agent167—~728Automated safety check: PassMIT
Hns Moaiadk Dev Referencemodu-ai/moai-adk1.2k—~937Automated safety check: PassApache-2.0

Similar skills

  • Finds which plugins in the repository changed, bumps only the ones not already bumped since origin/main, and checks that each plugin's two manifests stay in sync.

    138 GitHub stars~1k tokensUpdated yesterday
    Agent WorkflowsAuto-check passed
  • Rule Catalog

    athola/claude-night-market

    Browse hookify rule catalog. An agent skill from athola/claude-night-market.

    341 GitHub stars~1.6k tokensUpdated 3 days ago
    Agent WorkflowsAuto-check passed
  • Faq Shortcuts

    kishormorol/cli-faq-shortcuts

    Turn the questions and instructions a user keeps typing into a project into short slash-command skills, mined from their real Claude Code, Codex and Cursor session history and git log.

    127 GitHub stars~1.4k tokensUpdated 5 days ago
    Sales & SupportAuto-check passed
  • Rpa Init

    coddy-project/coddy-agent

    Run when the user invokes /rpa-init or asks to onboard or warm up context on a repository.

    167 GitHub stars~728 tokensUpdated today
    Productivity & AutomationAuto-check passed
  • moai-adk-go local dev reference — version management/release process (sec 5), shell-script hook development (sec 7), build & dev commands (sec 10).

    1.2k GitHub stars~937 tokensUpdated today
    DevelopmentAuto-check passed
  • Prep

    AIOSAI/AIPass

    Session wrap-up. An agent skill from AIOSAI/AIPass.

    288 GitHub stars~880 tokensUpdated 4 days ago
    Agent WorkflowsAuto-check passed

More from alirezarezvani/claude-code-skill-factory

All 12 skills in this repo
  • App Store Optimization

    alirezarezvani/claude-code-skill-factory

    Complete App Store Optimization (ASO) toolkit for researching, optimizing, and tracking mobile app performance on Apple App Store and Google Play Store

    880 GitHub starsUsed in 8 repos~4.1k tokens
    Auto-check passed
  • Claude Md Enhancer

    alirezarezvani/claude-code-skill-factory

    Analyzes, generates, and enhances CLAUDE.md files for any project type using best practices, modular architecture support, and tech stack customization.

    880 GitHub stars~4.1k tokensUpdated 11 mo ago
    Auto-check passed
  • Content Trend Researcher

    alirezarezvani/claude-code-skill-factory

    Advanced content and topic research skill that analyzes trends across Google Analytics, Google Trends, Substack, Medium, Reddit, LinkedIn, X, blogs, podcasts, and YouTube to generate data-driven…

    880 GitHub starsUsed in 1 repo~2.1k tokens
    Auto-check passed
  • TDD Guide

    alirezarezvani/claude-code-skill-factory

    Comprehensive Test Driven Development guide for engineering subagents with multi-framework support, coverage analysis, and intelligent test generation

    880 GitHub starsUsed in 1 repo~2.7k tokens
    Auto-check passed
  • Agent Factory

    alirezarezvani/claude-code-skill-factory

    Claude Code agent generation system that creates custom agents and sub-agents with enhanced YAML frontmatter, tool access patterns, and MCP integration support following proven production patterns

    880 GitHub stars~2k tokensUpdated 11 mo ago
    Auto-check passed
  • Codex CLI Bridge

    alirezarezvani/claude-code-skill-factory

    Bridge between Claude Code and OpenAI Codex CLI - generates AGENTS.md from CLAUDE.md, provides Codex CLI execution helpers, and enables seamless interoperability between both tools

    880 GitHub stars~2.2k tokensUpdated 11 mo ago
    Auto-check passed

Works with

Questions about Hook Factory

What does Hook Factory do?

Generate production-ready Claude Code hooks with interactive Q&A, automated installation, and enhanced validation. Hook Factory is an agent skill from alirezarezvani/claude-code-skill-factory. Generate production-ready Claude Code hooks with interactive Q&A, automated installation, and enhanced validation.

When should I use Hook Factory?

Hook Factory fits situations like: tasks that involve Hooks and plugins; tasks that involve Workflow automation.

How do I install Hook Factory in Claude Code?

Run `npx skills add alirezarezvani/claude-code-skill-factory --skill hook-factory -a claude-code`. Or copy the skill folder (generated-skills/hook-factory in alirezarezvani/claude-code-skill-factory) into .claude/skills/hook-factory in your project. Claude Code loads it when a task matches its description.

How do I install Hook Factory in Codex?

Run `npx skills add alirezarezvani/claude-code-skill-factory --skill hook-factory -a codex`. Or copy the skill folder (generated-skills/hook-factory in alirezarezvani/claude-code-skill-factory) into .agents/skills/hook-factory in your project. Codex loads it when a task matches its description.

Can I use Hook Factory in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add alirezarezvani/claude-code-skill-factory --skill hook-factory -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/hook-factory, .gemini/skills/hook-factory, .github/skills/hook-factory and .opencode/skills/hook-factory in your project.

What does Hook Factory need to run?

Going by SKILL.md and its folder, Hook Factory needs the command-line tools its instructions call (python3). Our summary lists: Python 3.

Does Hook Factory access the network?

SKILL.md names 1 domain. As links in the text: docs.claude.com. This is read from the text; nothing was executed.

Is Hook Factory safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Hook Factory use?

Hook Factory is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Hook Factory use?

About 3.1k tokens (SKILL.md is roughly 13k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Hook Factory?

Skills that share tags, products or a category with Hook Factory: Publish Plugins Version Bump (vinta/hal-9000, 138 stars), Rule Catalog (athola/claude-night-market, 341 stars), Faq Shortcuts (kishormorol/cli-faq-shortcuts, 127 stars) and Rpa Init (coddy-project/coddy-agent, 167 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Hook Factory?

alirezarezvani (a GitHub user) maintains it in alirezarezvani/claude-code-skill-factory, which has 880 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on November 12, 2025.

Source: alirezarezvani/claude-code-skill-factory on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.