/build-hook - Build Custom Claude Code Hooks banner
alirezarezvani alirezarezvani

/build-hook - Build Custom Claude Code Hooks

Productivity community intermediate

Description

**Interactive guide for creating custom hooks with Q&A workflow and automatic validation.** > **Note**: This command is also available as `/build hook` for consistency with other factories (skills, ag

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

Repository README

This is the README for alirezarezvani/claude-code-skill-factory, shared by 13 entries in this directory. It describes the repository, not this entry specifically.

/build-hook - Build Custom Claude Code Hooks

**Interactive guide for creating custom hooks with Q&A workflow and automatic validation.**

**Note**: This command is also available as `/build hook` for consistency with other factories (skills, agents, prompts). Both work identically - use whichever you prefer!

  • Consistent pattern: /build hook (recommended)
  • Alias: /build-hook (this command)

Usage

/build-hook
/build-hook notification
/build-hook formatting
/build-hook testing
/build-hook git

What This Command Does

**Two Ways to Build Hooks**:

1. Agent-Guided (Recommended for Beginners)

**Without arguments** (`/build-hook`):

  • Invokes the hooks-guide agent for interactive Q&A
  • Asks 5-7 straightforward questions about your hook needs
  • Generates complete hook configuration with validation
  • Creates README.md with installation guide
  • Validates safety (no destructive ops, proper error handling)
  • Saves to generated-hooks/[hook-name]/

**With argument** (`/build-hook [type]`):

  • Suggests hook template based on type
  • Continues with interactive questions
  • Customizes template for your needs

2. Direct CLI (Advanced Users)

**Interactive Mode**:

cd generated-skills/hook-factory
python3 hook_factory.py -i
  • 7-question guided flow with smart defaults
  • Comprehensive input validation
  • Optional auto-install to user/project level
  • Faster workflow for experienced users

**Template Mode**:

python3 hook_factory.py -t post_tool_use_format -l python
  • Direct template generation
  • Requires template knowledge
  • Manual installation needed

Examples

Build Any Hook (Interactive)

/build-hook

**Output**:

Welcome to the Claude Code Hooks Factory! 🔧

I'll help you build a custom hook through 5-7 straightforward questions.

Hooks are workflow automation that run when events occur:
- SessionStart: Load context when Claude starts
- PostToolUse: Auto-format code after editing
- SubagentStop: Run tests when agents complete
- And 4 more event types...

Let's get started!

Question 1: What should this hook do?
Examples:
- Auto-format Python files
- Run tests automatically
- Send notifications
- Auto-commit to git

Your answer: ___

Build Notification Hook (Suggested)

/build-hook notification

**Output**:

Great! Building a notification hook.

I'll ask you a few questions to customize it:

Question 1: When should notifications be sent?
1. When any agent completes (SubagentStop)
2. When specific agent completes (SubagentStop + filter)
3. After every file edit (PostToolUse)
4. At session start (SessionStart)

Your choice (1-4): ___

→ Continues with hooks-guide Q&A → Generates notification hook with macOS/Linux support


Build Auto-Format Hook (Suggested)

/build-hook formatting

**Output**:

Perfect! Building an auto-formatting hook.

Question 1: Which language should be formatted?
1. Python (black)
2. JavaScript/