plugins/plugin-dev/skills/hook-development/scripts/README.md
These scripts help validate, test, and lint hook implementations before deployment.
Validates hooks.json configuration files for correct structure and common issues.
Usage:
./validate-hook-schema.sh path/to/hooks.json
Checks:
Example:
cd my-plugin
./validate-hook-schema.sh hooks/hooks.json
Tests individual hook scripts with sample input before deploying to Claude Code.
Usage:
./test-hook.sh [options] <hook-script> <test-input.json>
Options:
-v, --verbose - Show detailed execution information-t, --timeout N - Set timeout in seconds (default: 60)--create-sample <event-type> - Generate sample test inputExample:
# Create sample test input
./test-hook.sh --create-sample PreToolUse > test-input.json
# Test a hook script
./test-hook.sh my-hook.sh test-input.json
# Test with verbose output and custom timeout
./test-hook.sh -v -t 30 my-hook.sh test-input.json
Features:
Checks hook scripts for common issues and best practices violations.
Usage:
./hook-linter.sh <hook-script.sh> [hook-script2.sh ...]
Checks:
set -euo pipefail usageExample:
# Lint single script
./hook-linter.sh ../examples/validate-write.sh
# Lint multiple scripts
./hook-linter.sh ../examples/*.sh
Write your hook script
vim my-plugin/scripts/my-hook.sh
Lint the script
./hook-linter.sh my-plugin/scripts/my-hook.sh
Create test input
./test-hook.sh --create-sample PreToolUse > test-input.json
# Edit test-input.json as needed
Test the hook
./test-hook.sh -v my-plugin/scripts/my-hook.sh test-input.json
Add to hooks.json
# Edit my-plugin/hooks/hooks.json
Validate configuration
./validate-hook-schema.sh my-plugin/hooks/hooks.json
Test in Claude Code
claude --debug
-v) to debug hook behaviorCheck:
#!/bin/bash)chmod +x)${CLAUDE_PLUGIN_ROOT})>&2)"$variable"set -euo pipefail