hf.audit-hooks

hf.audit-hooks is a command for Claude Code from T-rav/hydraflow. It costs 0 tokens per session (934 once invoked), scanned A, original, Apache-2.0.

A command that reviews Claude Code hooks, which are scripts that run automatically before or after coding actions. It checks their configuration and shell scripts for correctness, speed, and useful conditions that can stop unnecessary work.

In plain words
What is it for?
Use it to inspect `.claude/settings.json` and hook scripts, review when they run, check fast-exit behavior, and find opportunities to make automated coding checks more reliable and efficient.
Why use it?
It helps detect hooks that run when they are irrelevant, repeat work, or perform expensive checks too early. The result is a report of workflow and configuration findings.

Command 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 commands/t-rav/hydraflow/hf.audit-hooks
Clone the repo
git clone --depth 1 https://github.com/T-rav/hydraflow

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 hf.audit-hooks

README.md
[![agentmods](https://agentmods.dev/badge/commands/t-rav/hydraflow/hf.audit-hooks.svg)](https://agentmods.dev/commands/t-rav/hydraflow/hf.audit-hooks)
Your own site
<a href="https://agentmods.dev/commands/t-rav/hydraflow/hf.audit-hooks"><img src="https://agentmods.dev/badge/commands/t-rav/hydraflow/hf.audit-hooks.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 934 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.00000 $0.00934
Opus 5 $0.00000 $0.00467
Sonnet 5 $0.00000 $0.00187
Haiku 4.5 $0.00000 $0.00093

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

Security

Grade A, and why

hf.audit-hooks 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 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.

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.

.claude/commands/hf.audit-hooks.md · 98 lines

How it starts

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

Hooks & Workflow Audit

Audit all Claude Code hooks (.claude/settings.json and .claude/hooks/*.sh) for correctness, efficiency, and gating opportunities. Launch a single agent that reads everything and reports findings.

Instructions

  1. Launch the agent below using Task with subagent_type: "general-purpose".
  2. Present the findings to the user.

Agent Prompt

You are a hooks and workflow auditor for this project.

## Steps

1. Read `.claude/settings.json` to understand the full hook configuration (PreToolUse, PostToolUse, Stop)
2. Read ALL `.sh` files in `.claude/hooks/` (use Glob for `**/*.sh`)
3. For each hook script, analyze against the checklist below
4. For the settings.json hook wiring, analyze against the wiring checklist below
5. Return a structured report of findings

## Hook Script Checklist

For each .sh file:

**Fast-exit gating:**
- Does it exit early when the tool input is irrelevant? (e.g., non-Python file for a Python-only check)
- Does it avoid expensive operations (git, grep, make) before confirming relevance?
- Are marker/warned checks done BEFORE filesystem scans or subprocess calls?
- Does it use session markers with TTL to avoid repeating warnings?

**Correctness:**
- Does `set -euo pipefail` behave correctly? (unmatched grep with pipefail can cause unexpected exits — should use `|| true`)
- Does it read tool_input correctly via jq? (Edit uses `file_path` + `old_string` + `new_string`; Write uses `file_path` + `content`)
- Are exit codes correct? (0 = allow, 2 = block for PreToolUse; 0 = ok for PostToolUse)
- Does it handle missing/empty jq fields gracefully?

**Efficiency:**
- Are there redundant subprocess calls? (multiple git invocations that could be combined)
- Are there filesystem operations that run unconditionally but could be gated?
- Could marker files be checked before mkdir -p?
- Are there grep/find calls that scan large directory trees unnecessarily?

**Robustness:**
- Does it work when CLAUDE_PROJECT_DIR is unset? (fallback to pwd)
- Does it handle filenames with spaces?
- Does it work on both macOS and Linux? (md5 vs md5sum, find syntax)
- Are /tmp marker directories cleaned up or TTL-gated?

## Settings.json Wiring Checklist

**Matcher coverage:**
- Are all relevant tools covered? (e.g., if a check applies to both Edit and Write, is it on both matchers?)
- Are there matchers that should exist but don't?
- Are there hooks on matchers where they'll never trigger? (wasted registration)

**Hook ordering:**
- Are fast/cheap hooks listed before slow/expensive ones in each matcher's array?
- For Stop hooks: are agent hooks gated by a marker or fast check before doing LLM work?
- Is the cleanup command hook last in the Stop array?

**Consistency:**
- Do all PreToolUse blocking hooks use exit 2?
- Do all PostToolUse tracking hooks use exit 0?
- Are timeout values reasonable? (tracking: 5s, checks: 10-15s, tests: 120s)
- Do all hooks that should have statusMessage have one?

**Gaps:**
- Are there tools or workflows not covered by any hook?
- Are there hooks that overlap or duplicate each other's checks?
- Could any PreToolUse hooks be replaced by cheaper PostToolUse tracking + Stop review?
- Is auto-lint wired to both Edit and Write PostToolUse? (prevents lint error accumulation)
- Is test-counterpart check wired to both Edit and Write PreToolUse? (catches edits without tests, not just new files)

## Report Format

Group findings by severity:

### Critical (broken or blocking incorrectly)
- [hook:line] description

### High (wasted execution or missing gate)
- [hook:line] description and recommended fix

### Medium (improvement opportunity)
- [hook:line] description

### Low (style/micro-optimization)
- [hook:line] description

### Summary
- Total hooks: X scripts, Y settings entries
- Gating score: X/Y hooks have proper fast-exit paths
- Portability: any macOS-only concerns
- Recommended next actions (top 3)

Read the full file on GitHub · 98 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 · 98 lines · 0 tokens per session scan A 0ca740b98c9c

Subscribe to this mod's changes

hf.audit-hooks is a command published in the GitHub repository T-rav/hydraflow (5 stars, last pushed today), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 934 tokens. 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.