Hook Authoring

Hook Authoring is a skill for Claude Code, Codex from lukacf/meerkat. It costs 20 tokens per session (521 once invoked), scanned A, original, Apache-2.0.

A guide to writing lifecycle hooks for an agent runtime. Hooks are handlers that run at defined points, such as before a tool call or after a response.

In plain words
What is it for?
Use it to create logging, analytics, runtime adapters, and allow-or-deny checks across the eight documented agent lifecycle points.
Why use it?
It clarifies where hooks run, how foreground decisions can allow or deny actions, and why background observation should not enforce policy.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

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

Made for: Claude Code, Codex.

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 Hook Authoring

README.md
[![agentmods](https://agentmods.dev/badge/skills/lukacf/meerkat/hook-authoring.svg)](https://agentmods.dev/skills/lukacf/meerkat/hook-authoring)
Your own site
<a href="https://agentmods.dev/skills/lukacf/meerkat/hook-authoring"><img src="https://agentmods.dev/badge/skills/lukacf/meerkat/hook-authoring.svg" alt="Measured on agentmods" height="20"></a>
Per session 20 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 521 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.1 $0.00020 $0.00521
Opus 5 $0.00010 $0.00260
Sonnet 5 $0.00004 $0.00104
Haiku 4.5 $0.00002 $0.00052

Measured 6d ago against content hash 7ccde8bf8f78, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

Hook Authoring 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 6d 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.

meerkat-hooks/skills/hook-authoring/SKILL.md · 63 lines

How it starts

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

Hook Authoring

Use hooks for runtime observation and policy decisions at typed lifecycle points. Hooks can observe, allow, or deny; they should not become hidden owners of runtime truth.

Hook Points

Meerkat provides 8 hook points in the agent lifecycle:

  1. RunStarted - When the agent run begins
  2. PreLlmRequest - Before sending to the LLM
  3. PostLlmResponse - After receiving the LLM response
  4. PreToolExecution - Before executing a tool call
  5. PostToolExecution - After tool execution completes
  6. TurnBoundary - At the boundary between turns
  7. RunCompleted - When the agent run completes successfully
  8. RunFailed - When the agent run fails

Execution Modes

  • Foreground hooks run in ascending priority, then registration order. A deny short-circuits later foreground hooks at that point.
  • Background hooks run concurrently and must declare capability: observe. Their decisions are discarded. Use them for logging and analytics, not policy enforcement.
  • Runtime adapters are in-process handlers, commands, or HTTP endpoints. Each entry has a typed adapter, timeout, point, mode, capability, and priority.

Decision Semantics

Foreground hooks return one of:

  • Allow: proceed normally.
  • Deny: block the operation with a reason.
  • Observe only: return no decision and no patches.

Boundaries

Semantic hook patches are retired. Hooks can observe typed projections and deny through the typed decision shape; provider parameters, assistant text, tool arguments/results, and final run text remain owned by the runtime/tool/LLM authority that produced them.

There is no per-hook failure_policy. Invalid configuration, execution failure, and timeout are typed engine errors. Foreground failures fail the run; background failures are recorded as dropped background dispatches and do not become hook-local denials.

Tool hook projections carry optional ToolProvenance, and LLM-response projections carry typed provider-native server_tool_content. Classify those typed fields synchronously instead of parsing display text or tool names.

Read the full file on GitHub · 63 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. 6d ago First seen · 63 lines · 20 tokens per session scan A 7ccde8bf8f78

Subscribe to this mod's changes

Hook Authoring is a skill published in the GitHub repository lukacf/meerkat (20 stars, last pushed today), licensed Apache-2.0. It adds 20 tokens to every session and 521 once invoked, about $0.0001 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-30.