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 →

9 results Clear filters →

🧩 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
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