# Navigating Claude Code: Hooks That Guard Your Code > [!question] Lingering Questions > - Hook schemas and supported lifecycle events are version-specific — recheck against current docs. > - The article warns hook scripts can themselves introduce security defects — what's the actual review discipline recommended for a hook script itself (code review, sandboxing, both)? Not detailed in the deep-read. > [!tip] Article Ideas > - "A hook that exits with code 2 blocks the tool call — full stop" is a clean, quotable technical fact worth a short reference post on Claude Code hook exit-code semantics. > [!link] Cross Reference > - Part 8 of Oleg Efimov's 10-article HackerNoon series; see [[3. Resources/Literature Notes/Navigating Claude Code - The Full Workflow]] for series context. > - [[3. Resources/Permanent Notes/A Control Is Enforceable Only When the Actor Cannot Reclassify It]] — the article's own warning ("hooks run your code" — a convenience hook is not an OS security boundary) is a second instance of this claim > [!quote] Vocabulary > - **Pre-tool / post-tool hook** — a Claude Code lifecycle hook that runs before a tool call (can block it via exit code) or after (used for formatting/tests) > - **Matcher** — the pattern that determines which tool calls a given hook applies to; overly broad matchers can block safe work or repeatedly run expensive commands ## Bibliographic capsule Article, HackerNoon, 2026-08-04. Eighth installment of Oleg Efimov's Claude Code series. ## Author's thesis (Adler Q1+Q2) **What is the article about?** How Claude Code hooks turn selected project policies into deterministic lifecycle checks, and where that mechanism's limits are. **What is being argued?** Hooks are genuinely deterministic (a pre-tool hook exiting with code 2 blocks the call, full stop) and should be used narrowly — block unsafe operations pre-tool, run formatting/tests post-tool — but a hook is still code the developer wrote and runs; it is not a substitute for stronger access controls where real harm is possible, and broad matchers create their own failure mode (blocking safe work, running expensive commands repeatedly). ## Key arguments (≤3) 1. **Use pre-tool hooks to block, post-tool hooks to check** — the two hook types solve different problems and shouldn't be conflated. 2. **Handle stdin, matchers, and exit codes precisely** — hook behavior is deterministic exactly because these mechanics are precise; sloppy matcher scope undermines that. 3. **A hook is not an OS security boundary** — "hooks run your code," meaning a hook's reliability is bounded by the same trust and review the rest of the codebase gets, not by some special enforced status. ## Claim atoms ### Hooks are deterministic where prose instructions are not > [!quote] ID:rw_01kz7stmmmkx6axcgn2b6cyjrg > deterministic Where/why: names the property that distinguishes a hook from a CLAUDE.md instruction. ### An exit code of 2 blocks the tool call unconditionally > [!quote] ID:rw_01kz7stnbzdrcd2sh5njjh9btj > A hook that exits with code 2 blocks the tool call — full stop. Where/why: the article's concrete mechanics claim — the actual enforcement primitive. ### A convenience hook is not an operating-system security boundary > [!quote] ID:rw_01kz7stp3dsty71yd2p05yhwk5 > Hooks run your code Where/why: the article's caution against over-trusting hooks as a hard security control. ## Permanent candidates - **A hook's determinism is a mechanics property, not a trust property** — genuine, distinct claim (exit-code-2 blocking is deterministic *and* still just code the developer wrote and must review); worth its own Permanent note since it sharpens, rather than restates, the series' generic enforceable-layer candidate. ## Processing checklist - [x] Checked for an existing Permanent note on the generic series candidate — exists, linked - [x] Created a new Permanent note for this article's sharper "deterministic ≠ trustworthy" distinction - [x] Connect into the relevant MOC — [[3. Resources/MOCs/AI Agent Safety MOC]] ## Links - [[3. Resources/MOCs/AI Agent Safety MOC]] — hooks are a concrete agent-control mechanism directly relevant to this MOC - [[3. Resources/Permanent Notes/A Control Is Enforceable Only When the Actor Cannot Reclassify It]] — because evidence-for; the article's "hooks run your code" warning is the same claim applied to a mechanism that IS technically deterministic but still author-trust-bounded - Metadata: [[3. Resources/Readwise/Articles/Navigating Claude Code Hooks That Guard Your Code|Navigating Claude Code - Hooks That Guard Your Code]]