Automated summary
This skill provides Claude Code hook patterns for automating validation, workflow gates, state management, and external integration.
Strengths
- Maps the main hook events (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Stop, SubagentStop) and which ones can block actions.
- Separates gate, side-effect, state-manager, external-integrator, and context-injector roles with concrete examples.
- Documents exit codes, JSON responses, quick registration, and common misconfigurations.
Limitations
- Targets Claude Code 1.0.40+ and does not address other agent runtimes.
- Advanced orchestration details live in linked reference files rather than this SKILL.md.
- Incorrect hook configuration can block tools or sessions, and settings changes may require a new session.
Use when building or debugging Claude Code hooks for validation, automation, workflow gating, or external service integration.
Avoid when working outside Claude Code hooks or when no automation or validation logic is needed.
Security analysis
SafeThe skill is documentation-focused and provides hook templates, event references, exit codes, and debugging guidance. It declares Bash/Write tools, but contains no instructions to exfiltrate data, delete files, disable safety, or execute obfuscated payloads. The examples are standard Claude Code hook configurations.
No concerns found
How this analysis is madeExamples
Create a Claude Code PreToolUse hook for Bash commands that blocks rm -rf and force pushes, exits with code 2, writes a clear message to stderr, and add the settings.json registration.Write a PostToolUse hook that runs Prettier after Edit or Write on JavaScript and TypeScript files, and show me the hooks configuration to register it.Add a SessionStart hook that injects the current git branch, recent commits, and package manager into Claude's context.name: hook-templates description: Comprehensive Claude Code hook patterns for automation, state management, and external integration. Use when implementing hooks for validation, workflow gates, MCP integration, or state machines. allowed-tools: ["Read", "Write", "Bash", "Grep", "Glob"]
Hook Patterns
Production-tested patterns for Claude Code hooks (1.0.40+).
Hook Roles (Beyond Just Validation)
| Role | Hook Event | Example | |------|------------|---------| | Gate | PreToolUse | Block dangerous commands, require prerequisites | | Side Effect | PostToolUse | Auto-format, auto-commit, lint | | State Manager | PostToolUse | Create/delete state files, track workflow phase | | External Integrator | Any | MCP calls, HTTP APIs, WebSocket | | Context Injector | SessionStart | Load project context, activate services |
Event Reference
| Event | Trigger | Can Block | Use For | |-------|---------|-----------|---------| | SessionStart | Session begins | No | Context loading, service activation | | UserPromptSubmit | User sends message | Yes | Prompt validation, skill suggestion | | PreToolUse | Before tool | Yes | Validation, workflow gates | | PostToolUse | After tool | No | State updates, side effects | | Stop | Claude stops | Yes | Quality gates, cleanup | | SubagentStop | Subagent stops | Yes | Subagent quality gates |
Exit Codes
| Code | PreToolUse/Stop | Others | |------|-----------------|--------| | 0 | Allow | Continue | | 2 | Block (stderr→Claude) | Logged | | 1, 3+ | Block | Logged |
JSON Response (Advanced)
{
"decision": "approve|block",
"reason": "Shown to user/Claude",
"continue": true,
"suppressOutput": false
}
Quick Registration
{
"hooks": {
"PreToolUse": [{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "script.sh", "timeout": 5 }]
}]
}
}
Pattern Selection
| Need | Pattern | Reference | |------|---------|-----------| | Force skill/agent activation | Orchestration | orchestration-templates.md | | Block dangerous actions | Gate Pattern | gate-patterns.md | | Auto-format/lint/commit | Side Effect Pattern | side-effect-patterns.md | | Full working examples | Examples | full-examples.md |
Orchestration Patterns (NEW)
Hook-based skill/agent activation with reliability stats:
| Pattern | Success | Use Case | |---------|---------|----------| | Forced Evaluation | 84% | Force Claude to evaluate and use skills | | Agent Router | 100% | Route to plugin agents via Task tool | | Context Injection | 100% | Load project context at session start |
See orchestration-templates.md for templates.
Debugging
Common issues and solutions in debugging-guide.md.
Quick checklist:
- Hook executable? (
chmod +x) - Using
INPUT=$(cat)to read stdin? - Using
exit 2for blocking (not exit 1)? - Debug to stderr (
>&2), output to stdout? - New session after settings.json change?
Common Mistakes
- Missing nested
hooksarray - Missing
"type": "command" - Using exit 1 instead of exit 2 for blocking
- Object matcher (not supported) - use script parsing instead
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/claude-code-hook-patterns-mmbizjn7/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/claude-code-hook-patterns-mmbizjn7' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/claude-code-hook-patterns-mmbizjn7/download' --output '.skill-downloads/claude-code-hook-patterns-mmbizjn7/SKILL.md.part' && mv '.skill-downloads/claude-code-hook-patterns-mmbizjn7/SKILL.md.part' '.skill-downloads/claude-code-hook-patterns-mmbizjn7/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/claude-code-hook-patterns-mmbizjn7/SKILL.md' && test -s '.skill-downloads/claude-code-hook-patterns-mmbizjn7/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/hook-templates' && cp -R '.skill-downloads/claude-code-hook-patterns-mmbizjn7' '.claude/skills/hook-templates'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/claude-code-hook-patterns-mmbizjn7'openskills read 'claude-code-hook-patterns-mmbizjn7'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/claude-code-hook-patterns-mmbizjn7/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.