Use when creating Claude Code hooks - covers hook patterns, composition, testing, progressive enhancement from simple to advanced
View on GitHubwithzombies/hyperpowers
withzombies-hyper
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/withzombies/hyperpowers/blob/main/skills/building-hooks/SKILL.md -a claude-code --skill building-hooksInstallation paths:
.claude/skills/building-hooks/<skill_overview> Hooks encode business rules at application level; start with observation, add automation, enforce only when patterns clear. </skill_overview> <rigidity_level> MEDIUM FREEDOM - Follow progressive enhancement (observe → automate → enforce) strictly. Hook patterns are adaptable, but always start non-blocking and test thoroughly. </rigidity_level> <quick_reference> | Phase | Approach | Example | |-------|----------|---------| | 1. Observe | Non-blocking, report only | Log edits, display reminders | | 2. Automate | Background tasks, non-blocking | Auto-format, run builds | | 3. Enforce | Blocking only when necessary | Block dangerous ops, require fixes | **Most used events:** UserPromptSubmit (before processing), Stop (after completion) **Critical:** Start Phase 1, observe for a week, then Phase 2. Only add Phase 3 if absolutely necessary. </quick_reference> <when_to_use> Use hooks for: - Automatic quality checks (build, lint, format) - Workflow automation (skill activation, context injection) - Error prevention (catching issues early) - Consistent behavior (formatting, conventions) **Never use hooks for:** - Complex business logic (use tools/scripts) - Slow operations that block workflow (use background jobs) - Anything requiring LLM reasoning (hooks are deterministic) </when_to_use> <hook_lifecycle_events> | Event | When Fires | Use Cases | |-------|------------|-----------| | UserPromptSubmit | Before Claude processes prompt | Validation, context injection, skill activation | | Stop | After Claude finishes | Build checks, formatting, quality reminders | | PostToolUse | After each tool execution | Logging, tracking, validation | | PreToolUse | Before tool execution | Permission checks, validation | | ToolError | When tool fails | Error handling, fallbacks | | SessionStart | New session begins | Environment setup, context loading | | SessionEnd | Session closes | Cleanup, logging | | Error | Unhandled error | Error recovery, notifications | </hoo