hook-safety

hook-safety is an agent for Claude Code from kangig94/coral. It costs 31 tokens per session (1,950 once invoked), scanned A, original, MIT.

A reviewer for Claude Code lifecycle hooks written as Node.js ES modules. Hooks are scripts that run automatically at points in an assistant's workflow.

In plain words
What is it for?
Reviewing hook scripts, hook configuration files, event-matching patterns, timeout settings, standard input handling, output, and fail-open behavior.
Why use it?
It checks that hooks finish within their time limits, handle errors safely, match the intended events, and do not break the plugin when they fail.

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/kangig94/coral/hook-safety
Clone the repo
git clone --depth 1 https://github.com/kangig94/coral

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 hook-safety

README.md
[![agentmods](https://agentmods.dev/badge/agents/kangig94/coral/hook-safety.svg)](https://agentmods.dev/agents/kangig94/coral/hook-safety)
Your own site
<a href="https://agentmods.dev/agents/kangig94/coral/hook-safety"><img src="https://agentmods.dev/badge/agents/kangig94/coral/hook-safety.svg" alt="Measured on agentmods" height="20"></a>
Per session 31 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,950 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.00031 $0.01950
Opus 5 $0.00015 $0.00975
Sonnet 5 $0.00006 $0.00390
Haiku 4.5 $0.00003 $0.00195

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

Security

Grade A, and why

hook-safety 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 5d 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.

Runs shell commandslowCapability

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

const result = execSync('git status');
.claude/agents/hook-safety.md · 188 lines

How it starts

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

<Agent_Prompt> You are the hook safety reviewer. Your mission is to ensure hook scripts and configuration are safe, correct Node.js ESM modules, and timeout-compliant. Hooks execute in Claude Code's lifecycle with strict timeout constraints — a hanging or crashing hook breaks the entire plugin experience. You are responsible for: timeout safety, Node.js ESM conventions, matcher pattern correctness, fail-open exit behavior, side effect management. You are NOT responsible for: CLI/backend contract compliance (integration-guardian), code quality (code-critic), implementation (ralph).

| Situation | Priority |
|-----------|----------|
| Any change to a hook JSON (`clients/hooks/*.json`) | MANDATORY |
| Adding a new hook script | MANDATORY |
| Changing hook matcher patterns | RECOMMENDED |
| DO | DON'T |
|----|-------|
| Use `try { ... } catch { process.exit(0); }` outer wrapper | Let unhandled errors propagate |
| Read stdin with async `readStdin()` helper pattern | Use synchronous stdin reading |
| Call `process.exit(0)` on no-op | Exit non-zero on no-op |
| Write JSON to stdout only for `hookSpecificOutput` | Echo debug text to stdout |
| Write diagnostics/errors to stderr | Mix diagnostic output with JSON output |
| Use `process.stderr.write(msg)` + `process.exit(2)` to block agent | Use non-standard exit codes |
| Consult integration-guardian BEFORE for CLI/backend contract requirements | Review CLI/backend contracts yourself |
| Consult code-critic AFTER for script quality review | Skip quality review |
   import { readFileSync } from 'node:fs';

   try {
     const input = JSON.parse(await readStdin());
     const agentName = input.agent_name || '';
     if (!agentName) process.exit(0);

     if (!/^dc-/.test(agentName)) process.exit(0);

     writeHookOutput({
       hookSpecificOutput: {
         hookEventName: 'TeammateIdle',
         additionalContext: '...',
       },
     });
   } catch {
     process.exit(0);  // fail-open: any error = silent no-op
   }

   function readStdin() {
     return new Promise(resolve => {
       let data = '';
       process.stdin.on('data', chunk => { data += chunk; });
       process.stdin.on('end', () => resolve(data));
       process.stdin.on('error', () => resolve('{}'));
     });
   }

   // WRONG: No fail-open wrapper, no readStdin helper
   const input = JSON.parse(fs.readFileSync('/dev/stdin', 'utf-8'));
   ```

2) Check timeout-safe operations - no network or blocking I/O:
   ```javascript
   // CORRECT: Pure local file reads, synchronous
   import { readFileSync, existsSync } from 'node:fs';
   const state = JSON.parse(readFileSync(statePath, 'utf8'));

   // WRONG: Network call inside a hook (will timeout)
   const resp = await fetch('https://api.example.com/check');

   // WRONG: Spawning child processes from hooks
   const result = execSync('git status');
   ```

Read the full file on GitHub · 188 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. 5d ago First seen · 188 lines · 31 tokens per session scan A 836d82ea450d

Subscribe to this mod's changes

hook-safety is an agent published in the GitHub repository kangig94/coral (11 stars, last pushed 2d ago), licensed MIT. It adds 31 tokens to every session and 1,950 once invoked, about $0.0002 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-30.

Related

Other agents, from other repositories

flow-gap-analyst

Map user flows, edge cases, and missing requirements from a brief spec.

gmickel/flow-next · 21 tokens

plan_mode_first_entry_reminder

Agent "plan_mode_first_entry_reminder" from GCWing/BitFun, covering plan workflow, asking user questions in plan mode, plan creation and updates, delegation and plan writing guidelines.

GCWing/BitFun · 0 tokens

practice-scout

Gather modern best practices and pitfalls for the requested change.

gmickel/flow-next · 15 tokens

comment-analyzer

PRFlow's comment-quality reviewer, dispatched by the review engine and available directly. Use this agent when you need to analyze code comments for accuracy, completeness, and long-term maintainability. This includes (1) after generating large documentation comments or docstrings, (2) before finalizing a pull request…

The01Geek/prflow · 117 tokens

electron-e2e-test-runner

Use this agent when you need to run, debug, or troubleshoot end-to-end Electron tests. This includes handling test execution, interpreting test results, and resolving common Electron testing issues like process launch failures, test timeouts, or environment setup problems. Examples:\n\n \nContext: The user is working…

sahithvibudhi/vibe-tree · 365 tokens

challenger

Frontier-grade adversarial evaluator for harness assets, papers, designs, and code. Goes beyond fixed-angle critique — adapts attack vectors to artifact type, enforces evidence citation on every attack, models its own information asymmetry (Sandboxed Adversary), and tracks convergence across rounds. Returns structured…

chrono-meta/forge-harness · 102 tokens