Claude Code Hook Development
Design, configure, validate, and debug event-driven hooks for Claude Code plugins.
The material emphasizes input validation, path safety, quoting, timeouts, and user confirmation, and warns against logging sensitive information. However, examples for Slack, databases, metrics, and audit logging transmit or persist tool inputs, commands, user data, or environment data without consent, least-privilege, redaction, access-control, or rollback guidance. validate-write.sh also interpolates an unescaped path into JSON, risking malformed output or injection. Points are deducted for incomplete data-flow transparency, isolation, and recovery.
The skill covers configuration, events, inputs, exit codes, and debugging, with several example scripts. However, it first says plugin hooks.json requires a hooks wrapper, while a later plugin configuration example uses top-level events, creating a key configuration contradiction. The prompt-hook supported-event list conflicts with the PostToolUse prompt example. Several referenced validation and test scripts are not included in the supplied material. Examples also use fragile string matching, omit symlink and path-boundary handling, and the linter may terminate early under set -e because of ((warnings++)). Static evidence is insufficient, so the score is conservative.
The audience, trigger phrases, major events, and command/prompt scenarios are reasonably clear. Boundaries, non-fit cases, dependency installation, permission prerequisites, and Claude Code version differences are not systematically stated. The material is primarily English and Bash/Unix-oriented, with no Chinese guidance or examples; it relies on Claude Code, bash, jq, and potentially overseas model/services, without explaining mainland-China reachability or fallback behavior.
The skill has a name, description, version, layered sections, examples, references, and a debugging workflow. Repository material supplies Apache-2.0 licensing, official maintenance provenance, and installation guidance. Points are deducted because there is no changelog, compatibility matrix, dependency-installation guidance, explicit support/update channel, or complete troubleshooting coverage. Several referenced references, examples, and utility scripts are not fully verifiable from the supplied files, and some configuration examples are inconsistent.
It provides directly adaptable configurations and script patterns for common PreToolUse, Stop, and SessionStart hooks, so the core task is plausible on the happy path. However, prompt-hook decision reliability, parallel-execution semantics, output formats, and permission behavior lack observed results; the security examples can produce false positives or false negatives, and some scripts should not be treated as production-ready without review. Static calibration caps effectiveness at 7.
The material includes concrete configurations, scripts, test commands, a linter, and auditable repository CI and license evidence, providing limited reproducibility. No scripts were executed, and there are no real test outputs, coverage results, CI tests covering this skill's key paths, or independent corroborating sources. The listed CI mainly concerns repository plugins and MCP URL liveness, not this skill's behavior. Static calibration caps verifiability at 5.
- Do not deploy the Slack, database, metrics, or audit-log examples directly; establish consent, data minimization, redaction, credential protection, and access controls first.
- Resolve the hooks.json wrapper-versus-top-level format conflict and verify event support, fields, decision outputs, and parallel semantics for the installed Claude Code version.
- Treat the scripts as instructional examples: add JSON escaping, canonical path and symlink protection, robust command parsing, dependency checks, and recoverable failure handling.
- The supplied material does not prove that validate-hook-schema.sh, test-hook.sh, and other referenced utilities exist or run; verify them at the exact revision before installation.
- For mainland-China users, confirm reachability of Claude Code, model services, and external integrations, and provide a no-external-service fallback.
What it does & when to use it
Hook Development is the hook-development skill under the repository’s plugin-dev plugin. It provides implementation guidance for Claude Code plugin hooks, including prompt-based and command hooks, event matchers, structured input and output, security checks, and lifecycle behavior. It fits developers who need to validate tool calls, block risky operations, load project context, or verify completion. Because it relies on Claude Code hook configuration and CLI debugging, other clients require adaptation.
It explains how to configure hooks in hooks/hooks.json or .claude/settings.json; define matchers for PreToolUse, PostToolUse, Stop, SubagentStop, UserPromptSubmit, SessionStart, SessionEnd, PreCompact, and Notification; configure prompt and command hooks; read JSON event data from stdin; and produce structured JSON decisions, feedback, or system messages. It also references Bash, jq, ${CLAUDE_PLUGIN_ROOT}, claude --debug, and supplied schema-validation, testing, and lint scripts.
- A Claude Code plugin developer needs to check path traversal, credentials, or sensitive files before Write or Edit runs.
- A team wants Stop or SubagentStop hooks to verify tests, builds, and task completeness.
- A developer needs SessionStart to load project context and persist environment variables.
- A plugin needs matcher-based policies for MCP tools, Bash commands, or file operations.
- A maintainer wants to enable strict validation temporarily through a flag file or configuration file.
Pros & cons
- Covers major hook events, configuration formats, input and output structures, and exit codes.
- Explains both recommended prompt hooks and deterministic command hooks.
- Includes practical guidance on path safety, input validation, quoting, timeouts, and parallel execution.
- Documents supplied validation, testing, linting, and example scripts.
- It is specifically oriented toward Claude Code plugin hooks rather than a general Agent Skills hook standard.
- Hooks load at session start, so configuration or script changes require restarting Claude Code.
- Matching hooks run in parallel without shared output or guaranteed ordering.
- The supplied material provides no cross-platform test results and does not establish that every example works in every environment.
How to install
The skill is located at plugins/plugin-dev/skills/hook-development/SKILL.md. The repository README says plugins can be installed in Claude Code with /plugin install {plugin-name}@claude-plugins-official or discovered through /plugin > Discover; the supplied material does not specify a standalone installation command or exact plugin name for this skill.
How to use
In Claude Code, ask for tasks such as “create a hook,” “add a PreToolUse hook,” “block dangerous commands,” or “implement prompt-based hooks.” Choose a prompt or command hook, edit hooks/hooks.json, use ${CLAUDE_PLUGIN_ROOT} in command paths, then run scripts/validate-hook-schema.sh hooks/hooks.json and scripts/test-hook.sh; use claude --debug for runtime testing. Restart Claude Code after hook configuration changes.