Claude Code hooks

Security scanning inside Claude Code

Run checks from the host lifecycle instead of relying on a prompt. gate scans edits and inspects shell commands. turn answers at Stop: which of these did this turn just do?

Checks attached to host events

  1. 01 PostToolUsegate scans the file after Edit, Write, or MultiEdit
  2. 02 PreToolUsegate fails closed before a Bash command executes
  3. 03 Stopturn reports only what this turn introduced
host event, local check, finding or clean result
npm i -D owlwarden
npx owlwarden init --claude-code

What that writes

EventScopeVerdict
PostToolUse (Edit, Write, MultiEdit)the file that was writtengate blocks with the rule, the line, and the fix
PreToolUse (Bash)the command stringgate blocks the command when the check fails
Stopeverything changed since the turn beganturn --hook claude-code --record: only what this turn introduced

Per-edit and pre-command hooks stay on gate: those must be cheap and have no meaningful base to compare against. turn at Stop is a different question. An agent told "there are eighteen findings" triages a backlog nobody asked it to touch.

No repository SessionStart hook

The generated config does not add a SessionStart entry. agent-hook-autoexec reports repository configuration that runs when the workspace is opened, at high severity, because anyone who clones the repository and opens it runs that command. owlwarden scan would report a generated repository hook of that shape.

The session digest belongs in user settings, which a cloned repository cannot write. The same reasoning is why the MCP entry is node_modules/.bin/owlwarden rather than npx -y owlwarden: that shape is a finding too.

MCP for manual scans

Hooks run checks automatically. MCP handles prompted requests such as explain this rule or scan packages/api. The server is read-only and static-only.

Before you open an unfamiliar repository

npx owlwarden vet ./cloned-repo

What vet refuses to trust / what lives in .claude/ / every rule.

Keep reading