create-hook

A repository workflow for creating a Claude Code hook: a script that runs on an event such as before a tool call, after a prompt, or when a session stops. It creates the script, its documentation, and the settings needed to activate it.

In plain words
What is it for?
Use it to create, scaffold, or review hooks in this repository, including their lifecycle event, script, settings.json entry, documentation, and generated catalogue entry.
Why use it?
It avoids wiring hooks by hand and documents the exact configuration users must add, since installing the files alone does not activate a hook. It also checks that the hook behaves safely.

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/khaledsaeed18/dotclaude/create-hook
Any agent
npx skills add KhaledSaeed18/dotclaude --skill create-hook
Clone the repo
git clone --depth 1 https://github.com/KhaledSaeed18/dotclaude

Made for: Claude Code, Codex.

Per session 62 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,200 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 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.00062 $0.01200
Opus 5 $0.00031 $0.00600
Sonnet 5 $0.00012 $0.00240
Haiku 4.5 $0.00006 $0.00120

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

Security

Grade A, and why

create-hook scanned grade A with 0 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/engineering/create-hook/SKILL.md · 75 lines

How it starts

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

Create a hook: a script Claude Code runs on a lifecycle event (before a tool, after a prompt, on stop, and so on). Make it do one deterministic thing, fail safe, and ship with documentation a user can paste into settings.json. Then regenerate the derived files and validate.

Source layout is hooks/<category>/<name>/HOOK.md plus the script. Hooks are folder-layout: the whole folder installs to .claude/hooks/<name>/, so the script and any helpers ride along. The category is the folder; registry.json and the README catalog are generated by pnpm gen. Never hand-edit generated files.

Hooks differ from skills, agents, and commands in one critical way: they are configuration, not a loadable file. The shadcn installer copies the script and HOOK.md but cannot edit a user's settings.json. So HOOK.md must document the exact settings block to add, and the hook is inert until the user adds it.

Hard rules: never break these

  • Fail safe and non-blocking by default. Unless the hook's job is to block, swallow its own errors and exit 0 so it can never interrupt or break a tool call or session. Exit 2 only when blocking is the intended behavior for that event.
  • HOOK.md must document activation. Include the precise settings.json block, the event, the matcher, and the command line. Without it the hook does nothing after install.
  • Be safe with data. Hooks see tool inputs and outputs. Redact secret-looking fields and truncate large payloads before logging or sending anything.
  • Zero or pinned dependencies. Prefer the language's standard library so the script runs anywhere it lands. State the runtime requirement.
  • name is globally unique and equals the folder name, kebab-case.
  • Never hand-write registry.json or the README catalog. Run pnpm gen.
  • No AI/co-author mentions anywhere in the hook or its output.

Step 1: Define the hook

  • The one thing it does, in a sentence.
  • The event it fires on and whether it needs a matcher (for example PreToolUse matched to Bash). Event list, matcher support, and the input/exit-code contract: reference/events.md.
  • Blocking or observing. Does it just record/notify (exit 0), or veto an action (exit 2 on the right event)?

Read the full file on GitHub · 75 lines

Files

What ships with it

2 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 · 75 lines · 62 tokens per session scan A 28ded0c1a48a

Subscribe to this mod's changes

create-hook is a skill published in the GitHub repository KhaledSaeed18/dotclaude (4 stars, last pushed 8d ago), licensed MIT. It adds 62 tokens to every session and 1,200 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.