hooks

hooks is a skill for Claude Code from nimadorostkar/Claude-Skills-collection. It costs 39 tokens per session (1,203 once invoked), scanned C, original, MIT.

A system for running automatic actions at points in an AI agent's lifecycle, such as before or after a tool call, when a session starts, or when it stops. These actions can enforce rules, add context, log activity, or block unsafe commands.

In plain words
What is it for?
Use it to run checks around edits or commands, prevent dangerous actions, inject information at the right time, and automate notifications or logging.
Why use it?
It makes important rules happen reliably instead of depending on the agent to remember them every time. This is useful for required checks, formatting, safety controls, and repeated setup steps.

Skill for Claude Code

Written for Claude Code: PostToolUse hook event.

Good fit Use it to run checks around edits or commands, prevent dangerous actions, inject information at the right time, and automate notifications or logging.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/nimadorostkar/claude-skills-collection/hooks
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 nimadorostkar/Claude-Skills-collection --skill hooks
Clone the repo
git clone --depth 1 https://github.com/nimadorostkar/Claude-Skills-collection

Made for: Claude Code.

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 hooks

README.md
[![agentmods](https://agentmods.dev/badge/skills/nimadorostkar/claude-skills-collection/hooks/github.svg)](https://agentmods.dev/skills/nimadorostkar/claude-skills-collection/hooks)
Your own site
<a href="https://agentmods.dev/skills/nimadorostkar/claude-skills-collection/hooks"><img src="https://agentmods.dev/badge/skills/nimadorostkar/claude-skills-collection/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 hooks

Your own site · 80×15
<a href="https://agentmods.dev/skills/nimadorostkar/claude-skills-collection/hooks"><img src="https://agentmods.dev/badge/skills/nimadorostkar/claude-skills-collection/hooks.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,203 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.00039 $0.01203
Opus 5 $0.00019 $0.00602
Sonnet 5 $0.00008 $0.00241
Haiku 4.5 $0.00004 $0.00120

Measured 12d ago against content hash b71372eccacb, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade C, and why

hooks scanned grade C with 1 finding 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 12d 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.

Recursive force deletehighDestructive command

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

- Guard against the destructive command (`rm -rf`, a force push, a production deploy) in a pre-tool hook. This is cheap insurance.
skills/agent-tooling/hooks/SKILL.md · 115 lines

How it starts

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

Hooks

Purpose

Enforce a rule deterministically rather than asking the model to remember it. A hook runs every time, regardless of the model's attention, its context, or its mood — which is exactly what a rule requires.

When to Use

  • A rule must hold every time: formatting, a forbidden command, a required check.
  • The agent keeps forgetting an instruction despite it being in the instructions.
  • Automating a step that should happen around every edit or command.
  • Blocking a dangerous action before it executes.

Capabilities

  • Lifecycle events: before and after a tool call, on session start, on stop.
  • Deterministic enforcement: formatting, linting, blocking.
  • Injecting context at the right moment.
  • Notification and logging.

Inputs

  • The rule and when it must apply.
  • The event that should trigger it.
  • What should happen when it fails: block, warn, or fix.

Outputs

  • Hook configuration that runs reliably.
  • Rules enforced without depending on the model's memory.
  • A fast hook — one that does not make the agent unpleasant to use.

Workflow

  1. Identify the rule that keeps being broken — If an instruction is in the instruction file and is still violated, it is a hook, not an instruction. Instructions are guidance; hooks are enforcement.
  2. Choose the event — Before a tool call to block or validate; after one to format or verify; on session start to inject context.
  3. Make it fast — A hook runs on every matching event. Two seconds on every file edit is a hostile environment. Under 500ms, or run it asynchronously.
  4. Fail informatively — A hook that blocks must say why and what to do instead. A silent block is maddening and the model cannot recover from it.
  5. Prefer fixing over blocking — A hook that formats the file is better than one that rejects the edit and demands the model format it.
  6. Test the hook itself — A broken hook blocks everything, and the failure mode is confusing.

Best Practices

  • A rule the model must remember is a rule the model will eventually forget. If it matters, enforce it in a hook.
  • Do not put slow operations in a synchronous hook. A full test suite on every edit is a way to make the agent unusable.
  • Blocking hooks must explain themselves. exit 2 with an explanatory message on stderr is what lets the model correct course.
  • Match narrowly. A hook that fires on every tool call, including reads, wastes time on operations it does not care about.
  • Auto-formatting after an edit is the single most valuable hook: it removes an entire class of diff noise and lint failures for free.
  • Guard against the destructive command (rm -rf, a force push, a production deploy) in a pre-tool hook. This is cheap insurance.

Read the full file on GitHub · 115 lines

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. 12d ago First seen · 115 lines · 39 tokens per session scan C b71372eccacb

Subscribe to this mod's changes

hooks is a skill published in the GitHub repository nimadorostkar/Claude-Skills-collection (26 stars, last pushed 24d ago), licensed MIT. It adds 39 tokens to every session and 1,203 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it C with 1 finding (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

offensive-c2-frameworks

Command and Control framework deployment, configuration, and operational tradecraft for red team engagements. Covers Cobalt Strike (malleable C2 profiles, Beacon types HTTP/HTTPS/DNS/SMB, Beacon Object Files for in-memory execution, sleep and jitter tuning, named pipe pivoting), Sliver (implant generation across…

SnailSploit/Claude-Red · 250 tokens

offensive-crypto-attacks

Systematic methodology for identifying and exploiting cryptographic implementation weaknesses in real-world applications. Covers padding oracle attacks against CBC-mode ciphers with PKCS7 padding (Vaudenay's original attack through modern padbuster automation), ECB mode exploitation including block cut-and-paste and…

SnailSploit/Claude-Red · 261 tokens

offensive-parameter-pollution

HTTP parameter pollution (HPP) checklist: duplicate parameter injection, backend vs frontend parsing differences, WAF bypass via HPP, server-side vs client-side HPP, and practical exploitation patterns. Use when testing web applications for parameter handling flaws.

SnailSploit/Claude-Red · 0 tokens

offensive-wifi

Wireless / 802.11 attack methodology for red team engagements and wireless security assessments. Covers monitor-mode setup, WPA/WPA2-PSK handshake capture and PMKID attacks, WPA3 SAE downgrade and Dragonblood, WPA-Enterprise (EAP) attacks (MSCHAPv2 cracking, EAP-TLS cert theft, evil-twin RADIUS), Karma / Known Beacons…

SnailSploit/Claude-Red · 183 tokens

offensive-z-wave

Z-Wave attack methodology — sniffing with Z-Force / EZ-Wave / RTL-SDR + ZniffMobile, S0 (legacy) network-key derivation flaw and key reuse, S2 (modern) ECDH commissioning analysis, replay/injection on unauthenticated nodes, default-key brute-force on test deployments, and home-automation hub pivots. Use when targeting…

SnailSploit/Claude-Red · 113 tokens

seo

Optimize for search engine visibility and ranking. Use when asked to "improve SEO", "optimize for search", "fix meta tags", "add structured data", "sitemap optimization", or "search engine optimization".

addyosmani/web-quality-skills · 46 tokens