meta-hook-creator

Create event hooks for Claude Code that trigger on tool calls, prompts, and lifecycle events. Use when automating workflows, blocking dangerous commands, protecting files, or adding notifications. Use for hooks, PreToolUse, PostToolUse, event handling, automation.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "meta-hook-creator" with this command: npx skills add oakoss/agent-skills/oakoss-agent-skills-meta-hook-creator

Hook Creator

Overview

Claude Code hooks are user-defined shell commands, LLM prompts, or agent evaluations that execute automatically at specific lifecycle points. Hooks receive JSON context via stdin, take action, and communicate results through exit codes, stdout, and stderr.

When to use: Blocking dangerous commands, auto-formatting after writes, protecting sensitive files, custom notifications, environment setup, enforcing project conventions, auto-approving safe tools, running tests after changes.

When NOT to use: Static context injection (use CLAUDE.md), simple permission rules (use allowlist settings), one-time setup (use shell scripts directly).

Quick Reference

PatternEventMatcherKey Points
Block tool callPreToolUseTool nameExit 2 or JSON permissionDecision: "deny"
Auto-approve toolPreToolUseTool nameJSON permissionDecision: "allow"
Modify tool inputPreToolUseTool nameJSON updatedInput with modified parameters
Format after writePostToolUseWrite|EditRun formatter, exit 0
Log tool failuresPostToolUseFailureTool nameFires when tool throws error or returns failure
Handle permissionPermissionRequestTool nameJSON decision.behavior: "allow" or "deny"
Validate user promptUserPromptSubmitNo matcherExit 2 blocks prompt, stdout adds context
Desktop notificationNotificationNotification typepermission_prompt, idle_prompt, etc.
Force continueStopNo matcherJSON decision: "block" with reason
Subagent lifecycleSubagentStopAgent typeSame decision control as Stop
Environment setupSessionStartSource typeWrite to CLAUDE_ENV_FILE to persist env vars
Session cleanupSessionEndExit reasonCannot block termination
Pre-compact contextPreCompactmanual|autoFires before context compaction
Background tasksAny post-eventAnySet async: true on command hooks
LLM evaluationSupported eventsAnyUse type: "prompt" for single-turn LLM check
Multi-turn verificationSupported eventsAnyUse type: "agent" for subagent with tool access

Common Mistakes

MistakeCorrect Pattern
Exit 1 expecting to block a tool callUse exit 2 to block in PreToolUse and PermissionRequest
Printing JSON on exit 2JSON output is only processed on exit 0; stderr is used on exit 2
Complex inline bash in settings.jsonExtract to a script file, reference with $CLAUDE_PROJECT_DIR
Missing timeout on slow hooksSet timeout field; defaults are 600s command, 30s prompt, 60s agent
Not quoting $CLAUDE_PROJECT_DIRAlways quote: "$CLAUDE_PROJECT_DIR"/.claude/hooks/script.sh
Expecting CLAUDE_ENV_FILE in all hooksOnly available in SessionStart hooks
Adding matcher to Stop or UserPromptSubmitThese events ignore matchers; they always fire
Using decision/reason at top level for PreToolUseUse hookSpecificOutput.permissionDecision and permissionDecisionReason
Not checking stop_hook_active in Stop hooksCheck this field to prevent infinite continuation loops
Mixing exit codes and JSON decisionsChoose one approach per hook: exit codes alone or exit 0 with JSON

Delegation

  • Hook pattern discovery: Use Explore agent to find existing hooks in the project
  • Hook testing and verification: Use Task agent to validate hook behavior
  • Code review: Delegate to code-reviewer agent for hook script review

References

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

github-cli

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tanstack-cli

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

typescript-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tanstack-devtools

No summary provided by upstream source.

Repository SourceNeeds Review