author-claude-hooklisted
Install: claude install-skill Ronnasayd/aipp
# Author a Claude Code Hook
Create a hook that matches the existing ~40 hooks in `hooks/scripts/`, wire it in `claude/settings.json`, add an eval.
## Phase 1 — Understand the trigger
Clarify with the user (use `grilling` if ambiguous):
- **Event**: `PreToolUse` (can block/allow), `PostToolUse` (inject context after), `SessionStart`, `Stop`, `UserPromptSubmit`, `SubagentStart`/`SubagentStop`, `PreCompact`.
- **Matcher**: tool regex (`Edit|Write`, `Bash`, `Read`) or `""` for all.
- **Effect**: inject `additionalContext` (most common), or gate a tool (`exit 2` = deny, with reason on stderr).
- **Dedup need**: should it re-announce every call, or back off (`NOTIFY_EVERY` pattern)?
Read 1–2 nearby hooks of the same event type before writing (`dir_context_refs.py` for PreToolUse+context, `impact_surface_hint.py` for PostToolUse+context, `protect_files.py` for gating, `start_context.py` for SessionStart).
## Phase 2 — Write the script
Follow `references/conventions.md` exactly: shebang `#!/usr/bin/python3`, `utils` import via `sys.path`, `get_hooks_logger("Name")`, read stdin with a `MAX_STDIN` cap, parse JSON defensively (exit 0 on any failure), use `get_by_key` for payload access, resolve project via `CLAUDE_PROJECT_DIR` env, wrap `main()` in `try/except logger.exception; sys.exit(0)`. A hook must never crash the tool call — every failure path is `sys.exit(0)`.
Output shape for context injection:
```python
json.dumps({"hookSpecificOutput": {
"hookEventName": "PreToolU