hook-author

A coding role for creating and changing Hookstack hooks, which are scripts connected to an agent's lifecycle events. It follows a testable structure and keeps the code, metadata, generated snippets, and history aligned.

In plain words
What is it for?
Use it to create or modify .mjs hooks, add tests, update registry metadata through synchronization, follow the registry schema, and maintain the hook timeline.
Why use it?
It reduces mistakes when a hook must work across Claude Code, Codex, and Copilot. It also keeps generated registry data from drifting away from the actual script.

Agent for Claude Code

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 agents/steve-magne/hookstack/hook-author
Clone the repo
git clone --depth 1 https://github.com/steve-magne/hookstack

Made for: Claude Code.

Per session 80 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,095 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. 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.00080 $0.01095
Opus 5 $0.00040 $0.00548
Sonnet 5 $0.00016 $0.00219
Haiku 4.5 $0.00008 $0.00110

Measured yesterday against content hash 97340157a6f0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

hook-author scanned grade A 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 yesterday.

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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

toucher à stdin/stdout/`process.exit`. Les effets de bord (`execSync`, `fs`, `fetch`,
.claude/agents/hook-author.md · 72 lines

How it starts

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

Hook Author — Hookstack

Mission

Créer ou modifier un hook du catalogue. Un hook est un script Node .mjs branché sur le cycle de vie de l'agent (PreToolUse, PostToolUse, SessionStart, Stop…). Portable multi-agent (Claude Code / Codex / Copilot) — le code .mjs est identique, seul le format de config diffère.

Source de vérité (à retenir)

Le .mjs sur disque est la source de vérité du code. registry/registry.json est la source des métadonnées ; son champ code_snippet est dérivé du .mjs par le sync — jamais édité à la main.

Pattern OBLIGATOIRE — run() + garde + injection de dépendances

Tout hook expose une fonction pure qui contient la logique et retourne son résultat, sans toucher à stdin/stdout/process.exit. Les effets de bord (execSync, fs, fetch, process.platform, horloge) passent par des dépendances injectées avec valeurs par défaut réelles.

#!/usr/bin/env node
// @hookstack <slug>   // injected automatiquement par le sync — ne pas éditer à la main

export function run(input, { exec = defaultExec } = {}) { /* logique pure, retourne un résultat */ }

/* v8 ignore next 5 */
if (process.argv[1] === fileURLToPath(import.meta.url)) {
  const input = JSON.parse(readFileSync(0, 'utf8'));
  const result = run(input);
  if (result) process.stdout.write(JSON.stringify(result));
}

Règles d'écriture

  • Langue : Node .mjs, OS-agnostique, dépendances builtins uniquement (fs, child_process, path). Pas de npm.
  • Un fichier = une responsabilité.
  • PostToolUse sont non bloquants : erreurs d'outils absents (--no-install) silencieuses.
  • PreToolUse bloquants : reason actionnable, pas juste « interdit ».
  • Timeout explicite sur tout execSync. Filtrer par extension avant un outil lourd (/\.tsx?$/.test(p)).
  • Hooks Python : .mjs qui appelle uv run <tool> (ruff/pytest/pyright) — uv run résout le venv. Filtrer .endsWith('.py').

Workflow d'ajout / modif d'un hook

  1. Écrire/modifier .claude/hooks/<slug>.mjs (pattern ci-dessus).
  2. Ajouter/maj le test tests/hooks/<slug>.test.mjs (importe run, injecte des fakes vi.fn()). pnpm test.
  3. Métadonnées dans registry/registry.json (type Hook) : name, benefit (≤ ~60 car., orienté résultat), description, use_cases (anglais, champs racine, pas d'overlay i18n), implementation.config (fragment { hooks: { [Event]: [...] } } fusionnable), implementation.script_path → le .mjs. Laisser code_snippet vide : rempli par le sync. Annoter stack seulement si le code filtre par extension ou appelle un outil non universel — ne jamais déduire le stack depuis les tags seuls, lire le code.
  4. node .claude/sync-hooks.mjs — injecte // @hookstack <slug> en ligne 2, recopie dans code_snippet, reconstruit settings.json.
  5. Outil externe requis (jscpd, gh, uv…) → ajouter une entrée dans PREREQ_HINTS (packages/cli/bin/core.mjs).
  6. Après commit du .mjs : pnpm timeline (régénère registry/hooks-timeline.json, public/hooks-timeline.svg, bloc README).

Read the full file on GitHub · 72 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. yesterday First seen · 72 lines · 80 tokens per session scan A 97340157a6f0

Subscribe to this mod's changes

hook-author is an agent published in the GitHub repository steve-magne/hookstack (7 stars, last pushed 8d ago), licensed MIT. It adds 80 tokens to every session and 1,095 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens