acus9345

Hookfuzz — Testing skill for Claude Code

Testing community

Test harness, spec runner and fuzzer for Claude Code hooks (any language).

How to install Hookfuzz

This entry records only its repository, not the path inside it, so there is no exact command to give. Open acus9345/hookfuzz and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Hookfuzz does

Test harness, spec runner and fuzzer for Claude Code hooks (any language). Build realistic payloads, assert decisions, fuzz edge cases, scan settings.

Alternatives in Testing

  • Test Runner — Run Python tests with pytest, unittest, or other testing frameworks 23.4k ★
  • OpenAgentsControl — AI agent framework for plan-first development workflows with approval-based execution 4.8k ★
  • Maestro Spec — Intent-driven spec precipitation — state a constraint in natural language (加一条规范:禁止用 any / 记录架构约束:服务间走 gRPC / 530 ★

README

hookfuzz

**Test harness, spec runner and fuzzer for [Claude Code hooks](https://docs.claude.com/en/docs/claude-code/hooks)** — in any language.

Claude Code hooks are scripts that receive a JSON payload on stdin and answer with an exit code (`0` ok, `2` block with stderr fed back) and optional JSON on stdout. They are easy to get subtly wrong: a typo in `hookEventName`, a crash on an unexpected payload, a hook that hangs, a path in `settings.json` that doesn't exist (so your "policy" hook silently never runs). `hookfuzz` catches all of these before a real session does.

npm i -D hookfuzz     # binary: hookfuzz

Node 20+, Linux / macOS / Windows, one runtime dependency (`yaml`).

Commands

`hookfuzz run` — fire one realistic event at a hook

$ hookfuzz run PreToolUse --tool Bash --input '{"command":"rm -rf /"}' -- bash hooks/block-rm.sh
event     PreToolUse
exit      2
decision  block (blocks) - Blocked: rm -rf is not allowed by policy
time      6.9 ms
stdout    empty
stderr
  │ Blocked: rm -rf is not allowed by policy

$ hookfuzz run PreToolUse --tool Write --input '{"file_path":"a/.env"}' -- "node hooks/guard.mjs"
event     PreToolUse
exit      0
decision  deny (blocks) - Writing .env files is not allowed
time      31.2 ms
stdout    valid JSON
  │ {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny",...}}
  • --tool, --input JSON|@file — tool name and tool_input (or event fields like prompt).
  • --payload JSON|@file — deep-merge overrides into the payload (null deletes a key).
  • --timeout ms (default 60000; must be a positive integer), --json for machine-readable output.
  • --shell runs a multi-argument hook command through the shell anyway (sh -c / cmd.exe); arguments are quoted, and on Windows cmd metacharacters such as %VAR%, %VAR:a=b% and %VAR:~0,5% are caret-escaped so they stay literal. A first word that cmd resolves to a .cmd/.bat shim through PATHEXT (e.g. npx