hook-authoring
Installation
SKILL.md
Hook Authoring
Hooks live in claude/hooks/ and are triggered by Claude Code lifecycle events.
Shell Hooks
- Shebang:
#!/usr/bin/env bash - Always:
set -euo pipefail - Quote all variables:
"$VAR", never bare$VAR - Conditionals:
[[ ... ]], not[ ... ] - Validate after writing:
shellcheck claude/hooks/<name>.sh
Python Hooks
- Shebang:
#!/usr/bin/env python3 - Target Python 3.14; use
uv runto execute - Type-hint all public functions
- No
subprocess.shell=True; usesubprocess.run([...], check=True)with a list - Validate after writing:
uv run ruff check claude/hooks/<name>.py