Feature request: per-rule activation metrics for hooks

Open 💬 3 comments Opened Jun 16, 2026 by VDP89

I've been running hooks as the enforcement layer for operator corrections since April. Currently 14 hooks over PreToolUse / UserPromptSubmit / SessionStart, logging ~1,100 fires per month in production use at an engineering firm.

The gap: hooks fire, but Claude Code exposes no native way to know how often each hook fired, on what, or with what outcome. Operate hooks seriously and you end up rolling your own logger; mine appends JSONL from every hook script. Without per-rule counts you can't tell a dead hook from a healthy low-frequency one, and you can't measure false-positive rates to decide when a warn-severity hook is safe to promote to deny.

What I'd find useful, in rough order of value:

  1. A per-hook fire counter exposed somewhere queryable (a claude hooks stats command, or a standard JSONL the harness writes).
  2. Hook event metadata included in the payload so a hook can know its own match context without re-parsing. (This overlaps the open request in #65733 for prompt_id in Pre/PostToolUse payloads, same direction.)
  3. Optionally: a place for a hook to report back an outcome label, so operators can build precision metrics on top.

From my own telemetry, the per-rule numbers are what made the system manageable: they surfaced one hook with a 35% false-positive rate (since redesigned), one that had silently never fired in 30 days (regex tested fine, the triggering event is just rare), and one producing 45% of total signal with no useful outcome attached (now instrumented separately). None of that is visible without counting fires per rule.

Context, if useful: I documented the operator-corrections use case for hooks here (DOI 10.5281/zenodo.19555971) and maintain fscars (PyPI), a small wrapper that implements this logging on top of the current hook system. Happy to share schema or data.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗