claude-code-hooks

claude-code-hooks is a skill for Claude Code from daymade/claude-code-skills. It costs 90 tokens per session (23,456 once invoked), scanned C, original, MIT.

A guide to Claude Code hooks, which are shell commands that run around tool calls or session events and can allow or block an action.

In plain words
What is it for?
It helps create, test, register, and debug guards for events such as PreToolUse, PostToolUse, SessionStart, and Stop.
Why use it?
It helps enforce rules that written instructions may be ignored, especially before irreversible actions such as deleting files or publishing data.

Skill for Claude Code

Written for Claude Code: PreToolUse hook event. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions subagents.

Part of the daymade-claude-code plugin — 21 skills shipped together

Good fit It helps create, test, register, and debug guards for events such as PreToolUse, PostToolUse, SessionStart, and Stop.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/daymade/claude-code-skills/claude-code-hooks
About the project

Claude Code Skills Marketplace is a collection and marketplace of skills, plugins, agents, and instructions that extend Claude Code with specialized development workflows. It is for developers who want to install existing workflows or create, validate, and package their own Claude Code skills.

daymade/claude-code-skills · 1,516 stars · on GitHub

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.

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

Made for: Claude Code.

Or install daymade-claude-code, the plugin that ships this one along with the rest of its 21 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for claude-code-hooks

README.md
[![agentmods](https://agentmods.dev/badge/skills/daymade/claude-code-skills/claude-code-hooks/github.svg)](https://agentmods.dev/skills/daymade/claude-code-skills/claude-code-hooks)
Your own site
<a href="https://agentmods.dev/skills/daymade/claude-code-skills/claude-code-hooks"><img src="https://agentmods.dev/badge/skills/daymade/claude-code-skills/claude-code-hooks/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for claude-code-hooks

Your own site · 80×15
<a href="https://agentmods.dev/skills/daymade/claude-code-skills/claude-code-hooks"><img src="https://agentmods.dev/badge/skills/daymade/claude-code-skills/claude-code-hooks.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 90 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 23,456 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 3 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 8 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Agent Snooping · line 360
    Skill reads from agent configuration directories (.claude/, .codex/, .gemini/). These directories may contain API keys, personal settings, and other credentials that the skill has no legitimate need to access.
    Fix: Remove all code or instructions that access agent configuration directories (.claude/, .codex/, .gemini/). If configuration values are needed, pass them explicitly as parameters or environment variabl
  • medium Rogue Agent · line 6
    Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
    Fix: Remove any persistence mechanisms (cron jobs, startup scripts, state files). Skills should not maintain state across sessions without explicit user consent.
  • medium Privilege Escalation · line 239
    Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
    Fix: Avoid sudo/root unless strictly required. Prefer least-privilege patterns. If elevation is needed, document the justification and scope.
  • medium Privilege Escalation · line 241
    Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
    Fix: Avoid sudo/root unless strictly required. Prefer least-privilege patterns. If elevation is needed, document the justification and scope.
  • medium Excessive Agency · line 280
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
  • medium Rogue Agent · line 314
    Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
    Fix: Remove any persistence mechanisms (cron jobs, startup scripts, state files). Skills should not maintain state across sessions without explicit user consent.
  • medium Rogue Agent · line 852
    Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
    Fix: Remove any persistence mechanisms (cron jobs, startup scripts, state files). Skills should not maintain state across sessions without explicit user consent.
  • medium Rogue Agent · line 1126
    Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.
    Fix: Remove any persistence mechanisms (cron jobs, startup scripts, state files). Skills should not maintain state across sessions without explicit user consent.
How audits are shown
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.1 $0.00090 $0.23456
Opus 5.5 $0.00036 $0.09382
Sonnet 5.5 $0.00018 $0.04691
Haiku 4.5 $0.00009 $0.02346

Measured 6d ago against content hash 21550a90ca3f, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

claude-code-hooks scanned grade C with 3 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 6d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/test_hook.group-name-guard.sh, scripts/test_hook.sh), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

command position" for `timeout 5 TRIGGER`, `sudo -u root TRIGGER` and

Reads agent configuration directoriesmediumAgent snooping

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

(`~/.claude/settings.json` in this setup; the Registration section of

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

verifier was required to curl the raw source and grep for the exact string
daymade-claude-code/claude-code-hooks/SKILL.md · 1,383 lines

How it starts

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

Claude Code Hooks

Claude Code fires hooks at tool-call boundaries. A hook is a shell command that receives a JSON event on stdin and, for blocking hooks, decides via its exit code whether the tool call proceeds. This is the only mechanism that structurally stops a behavior — a prose rule in CLAUDE.md is a suggestion the completion drive can override; a hook is a wall.

When a hook is the right tool (and when it isn't)

Write a hook when a rule keeps getting violated even though it's already written down. The tell: you added the prose rule, it read clearly, and the behavior recurred anyway — because at the moment of action, attention is 100% on "get the thing done" and the reminder loses. That recurrence is the signal to move the rule from prose (advisory) to a hook (enforced). Governance rule of thumb: Tier-0 irreversible action + only prose, no hook → it should be a hook. (Tier-0 here = an action whose damage cannot be undone from inside the session: destroying uncommitted work, pushing secrets to a remote, deleting files, publishing something outward. The test is reversibility, not severity.)

Do not reach for a hook when: the rule has never actually recurred (don't pre-build guards for hypothetical mistakes — cost with no proven benefit), or the "rule" is a judgment call with no mechanical signature (a hook can only match tokens/patterns; it can't judge whether a design is good).

If the symptom is “it keeps reviewing / waiting / retrying,” do not assume the answer is another hook. First complete the Loop Contract in rule 7 and read pitfall #36. The loop may be created entirely by an agent repeatedly applying a prose rule.

Hook types and what the exit code means

Type Fires Exit 0 Exit 2 Other
PreToolUse before a tool runs normal permission flow unless JSON supplies allow/deny/ask block the call even when JSON says allow; read valid JSON fields (v2.1.214+). JSON blocking reason or stderr → model without schema-valid JSON, another nonzero exit is a non-blocking error and the call proceeds; with valid JSON, the supported fields decide and that status is ignored. Use exit 0 for structured control. Follow the official exit-code contract
PostToolUse after a tool ran quiet unless it prints a hookSpecificOutput JSON on stdout — that is how context injection works, and it happens at exit 0 feedback to the model (can't un-run the tool) —
SessionStart session begins proceed cannot block — stderr shows the user a hook-error notice, Claude never sees it, the session starts anyway exit 0 anyway: not because a non-zero would block (it can't), but because anything non-zero puts a <hook> hook error in the user's transcript on every single session start. Takes a matcher on how the session started — startup, resume, clear, compact, fork
Stop (+ SubagentStop) the model is about to finish responding let it stop block the stop — forces the model to keep going (stderr → fed back as the reason) loop safety: the hook checks stop_hook_active (necessary, not sufficient — rule 7). The harness's consecutive-block ceiling (default 8) is not a general backstop — its counter resets on any continuation that executed tools, so it never arrives for a hook whose remediation involves tool calls, which is most of them (#27). Carry your own bound. All Stop hooks for an event run in parallel — one block round can carry several hooks' feedback

Read the full file on GitHub · 1,383 lines

Files

What ships with it

5 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. 6d ago Changed · +5 lines 21550a90ca3f
  2. 12d ago Changed · +4 lines 376ee7fdb1c1
  3. 1mo ago Changed · +6 lines 3445fdf57b9d
  4. 1mo ago Changed · +23 lines 83678b59f7e6
  5. 1mo ago Changed · +5 lines 50e5c8ac629e
  6. 1mo ago Changed · +10 lines 4518a6f302fd
  7. 1mo ago Changed · +6 lines 3ce4c82525ac
  8. 1mo ago Changed · -11 lines · -157 tokens per session a9ee63d83709
  9. 1mo ago Changed · +19 lines 7b3944ba8b9e
  10. 1mo ago First seen · 1,316 lines · 247 tokens per session scan C 370e78b61b86

Subscribe to this mod's changes

claude-code-hooks is a skill published in the GitHub repository daymade/claude-code-skills (1,516 stars, last pushed yesterday), licensed MIT. It adds 90 tokens to every session and 23,456 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it C with 3 findings (asks for root, reads agent configuration directories, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

claude-code-hooks compared with skills from other repositories

claude-code-hooks next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
claude-code-hooksdaymade/claude-code-skillsSkill1.5kyesterdayMITC90Claude Code
imagegenopenai/codexSkill133kyesterdayApache-2.0A113Codex
playwright-climicrosoft/playwrightSkill99kyesterdayApache-2.0A19Claude Code
local-ai-agentsmicrosoft/ai-agents-for-beginnersSkill79k4d agoMITA200Claude Code, Codex
systematic-debuggingobra/superpowersSkill313k3d agoMITA21Claude Code
next-cache-components-adoptionvercel/next.jsSkill143kyesterdayMITA95Claude Code
next-partial-prefetching-adoptionvercel/next.jsSkill143kyesterdayMITA103Claude Code