← ClaudeAtlas

hookslisted

Author, register, and optimize Claude Code hooks — choosing the event and matcher, keeping the per-invocation cost down, and the never-raise contract every hook script owes the harness. TRIGGER when: writing or editing a hook script, adding or changing a `hooks` entry in `settings.json`, diagnosing a hook that never fires or fires too often, or deciding whether something should be a hook at all. DO NOT TRIGGER when: the subject is git hooks (pre-commit, pre-push), React hooks, or Win32 hooks — unrelated senses of the word.
AnotherSava/claude-code-common · ★ 0 · AI & Automation · score 69
Install: claude install-skill AnotherSava/claude-code-common
# Claude Code hook authoring Every hook is a process spawn on somebody's critical path. This skill exists so that cost is chosen deliberately rather than discovered later. Read `references/performance.md` before picking an interpreter or an event — it carries the measured cost table. Read `references/events-and-payloads.md` for the event catalog, matcher semantics, exit codes, and the stdin payload shape. ## 1. First decide it should be a hook A hook is the right tool when the behaviour must happen *without anyone remembering to ask for it*, and the trigger is an event the harness already emits. It is the wrong tool when a guideline or an on-demand check would do. - **Never register a hook that runs on every prompt**, and least of all a blocking one — see `~/.claude/memory/feedback_no_per_prompt_hooks.md`. The cost is paid most often in exactly the case where the hook does nothing. - Enforcement at generation time (a `PostToolUse` lint hook) beats a convention that relies on remembering — but only once it is narrowed per §2. - If the work is "do X when the user asks", that is a skill or a slash command, not a hook. ## 2. Narrow before you spawn — the ladder Apply the cheapest gate that expresses the condition. Each rung avoids the entire cost of the one below it. 1. **`if` field** — pattern-gates on tool *arguments* and costs **zero process startup** when it does not match. `"if": "Write(//**/SKILL.md)"`. The `//` root anchor is required; without it the ru