claude-code-hooks

A guide to configuring Claude Code hooks, which are scripts that run automatically when specific events occur during an agent session.

In plain words
What is it for?
It is for creating hooks, validating tool use, running formatters or linters, triggering external services, and enforcing workflow rules.
Why use it?
It explains how to check inputs, automate repeated work, add project context, connect outside tools, and control which actions need approval.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/emdashcodes/claude-code-plugins/claude-code-hooks
Any agent
npx skills add emdashcodes/claude-code-plugins --skill claude-code-hooks
Clone the repo
git clone --depth 1 https://github.com/emdashcodes/claude-code-plugins

Made for: Claude Code, Codex.

Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,791 The whole file, excluding the scripts and references it only reads on demand.
Security scan D 2 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00054 $0.02791
Opus 5 $0.00027 $0.01396
Sonnet 5 $0.00011 $0.00558
Haiku 4.5 $0.00005 $0.00279

Measured 2d ago against content hash e67c13d26f2e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade D, and why

claude-code-hooks scanned grade D with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

**User hooks:** `~/.claude/settings.json` - Personal preferences, cross-project automation

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- "Should the hook allow sudo/rm -rf commands, or block them entirely?"
plugins/claude-code-meta/skills/claude-code-hooks/SKILL.md · 371 lines

How it starts

The opening of the file, as written. The whole thing — 371 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Claude Code Hooks

This skill provides assistance for working with Claude Code hooks to enable automation of workflows and integration of external tools through an event-driven system.

About Hooks

Hooks are event-driven automation scripts that execute automatically when specific events occur during Claude Code's operation. Think of them as "middleware" for Claude's actions—they intercept events to validate inputs, enrich context, automate workflows, or integrate external tools, transforming Claude from a general assistant into a policy-aware, context-enriched agent.

What Hooks Provide

  1. Input validation - Block dangerous operations, enforce security policies, prevent path traversal
  2. Workflow automation - Auto-format code, run linters, backup files, send notifications
  3. Context enrichment - Load git status, inject project context, add session information
  4. External integration - Connect to APIs, trigger CI/CD, log to external systems
  5. Decision control - Auto-approve safe operations, require confirmation for sensitive actions

Anatomy of a Hook

Every hook consists of configuration in settings.json and an optional validation script:

.claude/
├── settings.json         - Hook configuration (required)
│   └── hooks:
│       └── EventName:    - Which event to hook (PreToolUse, PostToolUse, etc.)
│           └── matcher:  - Which tools to match (regex pattern)
│               └── command: - What to execute (shell command or script)
└── hooks/                - Hook scripts (optional)
    └── script-name.py    - Validation/automation logic
Configuration (required)

Hooks are configured in settings.json with event type, tool matcher, and command:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/validate-bash.py",
            "timeout": 60
          }
        ]
      }
    ]
  }
}

Read the full file on GitHub · 371 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 371 lines · 54 tokens per session scan D e67c13d26f2e

Subscribe to this mod's changes

claude-code-hooks is a skill published in the GitHub repository emdashcodes/claude-code-plugins (13 stars, last pushed 1mo ago), licensed MIT. It adds 54 tokens to every session and 2,791 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it D with 2 findings (reads agent configuration directories, recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

weekly-digests

Generate a serial week-by-week narrative digest of a project's full claude-mem timeline. Splits the timeline into per-ISO-week files, then runs one consecutive subagent per week — each receiving the prior week's carry-forward block — to produce one chapter per ISO week of data. Use when asked for "weekly digests"…

thedotmack/claude-mem · 93 tokens

agentmail

Use when an agent needs AgentMail CLI email inboxes.

NousResearch/hermes-agent · 15 tokens

skill-template

Template for creating new Agent Skills for context engineering. Use this template when adding new skills to the collection.

muratcankoylan/Agent-Skills-for-Context-Engineering · 24 tokens

Agent Development

This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development…

anthropics/claude-code · 80 tokens

skill-creator

Scaffold a new yoyo skill when a human or community issue asks for one ("add a skill for X", "create a skill that does Y"). Generates correct frontmatter, validates, writes to disk.

yologdev/yoyo-evolve · 46 tokens

subagent-delegation

Canonical protocol for delegating GSD work to native Antigravity subagents — when to delegate, how to invoke, workspace isolation modes, and the inline fallback for older IDE versions.

toonight/get-shit-done-for-antigravity · 42 tokens