AI Coding Agent Hooks

A hook is a shell script your AI coding agent runs automatically at a defined event — before a tool call, after a file edit, before a shell command executes. Used well, hooks enforce the policy you can't rely on a prompt alone to guarantee: block a secret before it's committed, log every tool call for an audit trail, or require a second check before a production command runs. Every hook below is real, copy-paste code — not a concept.

100 hooks · Written for Claude Code's documented hook contract
New to agent hooks? Read the security risks first →

🔒 Secrets & Credentials

8 hooks

Stop a secret from ever leaving your machine — block it before a commit, or block the agent from reading the file in the first place.

🛑 Production Guardrails

8 hooks

Force a human-in-the-loop check before a command that touches production infrastructure, or block a destructive command outright.

🧩 MCP & Config Safety

9 hooks

Defensive hooks against the exact pattern behind real CVEs: a cloned repo's own config file silently auto-approving tools or servers.

Block Elicitation From an Unlisted MCP Server
Security
Declines a user-input request from any MCP server not in an explicit allowlist.
Elicitation · Claude Code
Warn on Auto-Approved MCP Servers
Security
The defensive counterpart to CVE-2025-59536 — flags a repo's own settings before you trust it.
SessionStart · Claude Code
Warn on MCP Server Tool-List Drift ("Rug-Pull" Detection)
Security
Flags when a previously-trusted MCP server's declared tool set changes mid-project.
PreToolUse · Claude Code
Block MCP Tool Calls Outside an Allowlist
Security
Denies any mcp__ tool call whose server prefix isn't on an explicit allowlist.
PreToolUse · Claude Code
Log Every Elicitation Decision for an MCP Trust Register
Security
A durable record of every elicitation request shown, and whether it was accepted or declined.
Elicitation · Claude Code
Log Skills Registry Reload Events
Security
Records when the skills registry changes mid-session — a cloned repo's skill is also an attack surface.
ConfigChange · Claude Code
Require Allowlist Entry on an MCP Server's First Tool Call
Security
Denies the first call to a brand-new MCP server until it's explicitly added to a persistent allowlist file.
PreToolUse · Claude Code
Require Redaction Review Before an Elicitation Response Is Sent
Security
Blocks an elicitation response if the user's filled-in form content matches a secret or PII pattern.
ElicitationResult · Claude Code
Warn on Un-Pinned MCP Server Command Drift at Startup
Security
Compares each configured MCP server's launch command against a pinned baseline every session start.
SessionStart · Claude Code

🏦 Financial & Model-Risk Controls

11 hooks

Controls built for the exact things a bank, insurer, or asset manager's own model-risk, SOX, and information-barrier reviews ask about — not generic security hygiene.

Block Outbound Calls From an MNPI-Touched Session
Security
Once a session has touched an MNPI path, blocks any email, post, or external MCP call for the rest of that se…
PreToolUse · Claude Code
Block Trade/Order MCP Calls Outside a Notional Limit
Security
Denies an order/trade-execution MCP tool call if its notional amount exceeds a configured ceiling.
PreToolUse · Claude Code
Enforce Segregation of Duties on a Valuation File
Security
Blocks an agent from both writing a valuation file and later marking it approved in the same session.
PreToolUse · Claude Code
Flag PII-and-External-MCP Cross-Contamination in One Session
Security
Flags any external MCP tool call made in a session that has also touched a customer PII file.
PreToolUse · Claude Code
Log Every Access to an MNPI-Tagged Path
Security
A dedicated register of every read/write touching a material non-public information path.
PostToolUse · Claude Code
Require Dual Control on a Payment-Initiation MCP Tool
Security
Blocks a wire/payment-initiation MCP tool call unless a second, distinct reviewer flag is already set.
PreToolUse · Claude Code
Require a Change-Ticket Reference Before Editing the Model Inventory
Security
Blocks edits to a model-risk inventory file unless the command references a ticket ID.
PreToolUse · Claude Code
Block Marking a Filing Draft Final Without a Reviewer Tag
Security
Blocks writing FINAL or APPROVED into a filing/report draft unless a REVIEWER= tag is also present.
PreToolUse · Claude Code
Log Every Touch of a Regulatory-Filing Path
Security
A dedicated evidence trail for anything read or written under a 10-K, call-report, or filings directory.
PostToolUse · Claude Code
Rate-Limit Market-Data MCP Queries
Security
Blocks a market-data MCP tool once it's been called more than N times in a rolling minute.
PreToolUse · Claude Code
Require a Validation Reference Before Overwriting a Model Output File
Security
Blocks overwriting a configured model-output path unless the write references its validation ID.
PreToolUse · Claude Code

🕵️ Data Privacy & PII

8 hooks

Catch customer PII before it leaves the machine, gets logged in the clear, or ends up re-identified across two datasets that were never supposed to be joined.

Block Re-Identification Joins Across Two Anonymized Datasets
Security
Flags a command that references two different anonymized dataset files in the same session.
PreToolUse · Claude Code
Mask PII in MCP Arguments Instead of Blocking the Call
Security
Replaces SSN- and account-number-shaped values in an outbound MCP call's arguments rather than denying it out…
PreToolUse · Claude Code
Redact PII From Audit Logs
Security
Masks SSN- and account-number-shaped strings before they're written to any local log file.
PostToolUse · Claude Code
Block Copying PII Columns to a Non-Encrypted Destination
Security
Blocks a cp/export command referencing a known PII table name unless the destination path is under an encrypt…
PreToolUse · Claude Code
Block Reads of Customer Data Exports Outside Working Hours
Security
Only allows reading a customer data export path during a configured working-hours window.
PreToolUse · Claude Code
Block Writing Raw Account Numbers to a Shared Scratch Path
Security
Blocks a Write whose content contains an account-number-shaped string unless the target is a private scratchp…
PreToolUse · Claude Code
Log Every PII-Pattern Match for a DSAR Register
Security
A separate, dedicated log of PII-pattern matches, built to feed a Data Subject Access Request register.
PostToolUse · Claude Code
Require a PII-Reviewed Session Tag Before Reading a Tagged Path
Security
Blocks reading any path with ssn or dob in the name unless the session is explicitly tagged as PII-reviewed.
PreToolUse · Claude Code
Need a hook that isn’t here?

Tell us what you want enforced automatically and we’ll build it — free and public.

Request a hook →
FEEDBACK