qa-hooks
Skill2 starsChanged 2 months agoApache-2.0View on GitHub
Measure and improve the Patronus runtime hooks (Claude, Codex) — success rate, latency, detection utility and message quality — with hooks enabled only inside an isolated QA sandbox.
In this repository5 other files it gives its agents.
- harness-buildSkill
- qa-dashboardSkill
- qa-dxSkill
- qa-integrationsSkill
- qa-runSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
Run node qa/hooks.mjs (add --live on the weekly run).
- Very specific: line 29
Read ~/.patronus-qa/runs/<date>/hooks.json.
- Very specific: line 31
Error or timeout rates: look at metrics.hooks[*].errors and trace the error code in plugins/native/src/hooks.ts, broker.ts, daemon.ts.
- Very specific: line 32
Detection misses: look at metrics.replay rows with expect=flag and verdict=pass.
- Very specific: line 36
Message UX: read the hook messages a person or agent sees (systemMessage, additionalContext, warnings in plugins/deepseek/src/notice.ts, …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Hook QA
The hooks must never be enabled in the global Claude or Codex configuration on this machine, because other local routines run here without hooks. qa/hooks.mjs handles the lifecycle:
- Preflight: records
integration <host> statusand hashes of the global host config files. A globally active Patronus plugin becomes a finding. Enable in a sandbox only. It uses three layers:
- direct calls into the built hook bundles,
claude --plugin-dirwith its ownCLAUDE_CONFIG_DIR,- a temporary
CODEX_HOMEwith a scripted model.
Hook lifecycle journaling is switched on with
PATRONUS_HOOK_TRACE=1.- QA:
- replay of
qa/hooks/corpus.json(detection recall, false positives, cold start, latency, message length), - the scripted Claude host suites,
- the Codex release E2E flows,
- with
--live, a real Claude session against the QA account.
- replay of
- Teardown: closes every broker session and deletes the sandbox, also on SIGINT or SIGTERM.
- Postflight: the global config hashes and the integration state must be unchanged.
Steps
- Run
node qa/hooks.mjs(add--liveon the weekly run). It takes about 20 minutes, and--quickruns the replay only. Never runintegration <host> enable|installyourself. - Read
~/.patronus-qa/runs/<date>/hooks.json. Check that every check is ok, especiallyglobal host config unchanged. If that check failed, stop and report it as critical. Do not restore files yourself. - Investigate the findings:
- Error or timeout rates: look at
metrics.hooks[*].errorsand trace the error code inplugins/native/src/hooks.ts,broker.ts,daemon.ts. - Detection misses: look at
metrics.replayrows withexpect=flagandverdict=pass. Scanner quality lives in Ark, outside this repository, so propose an issue (see/qa-run) that names the corpus case IDs. - False positives: rows with
expect=passandverdict=flag. - Prompt policy:
UserPromptSubmitmisses may be policy, not detection; compare withplugins/deepseek/src/prompt-policy.ts. - Cold start / latency: compare against
qa/thresholds.jsonand the previous run in~/.patronus-qa/history.jsonl.
- Error or timeout rates: look at
- Message UX: read the hook messages a person or agent sees (
systemMessage,additionalContext, warnings inplugins/deepseek/src/notice.ts,failureMessageinhooks.ts). Each message should say what happened, whether the content is safe to use, and the one next command. Record unclear or overlong messages asuxfindings. - Grow the corpus when you find a realistic gap, such as a new injection style or a benign case that was flagged. Add cases to
qa/hooks/corpus.jsonas part of a draft PR, using synthetic data only.
End-to-end sessions
node qa/e2e/run.mjs (area e2e, see /qa-run) complements the replay with whole work sessions on the same sandbox rules. It shows effects the replay cannot: tool result shapes a hook does not extract (a leak at one step only), false positives that block the task, whether the receipt protocol (check, read redacted, PII consent) recovers the needed text, the ignore_once prompt gate end to end, and the per-step overhead against a run without the plugin. When a replay finding and an e2e row disagree, trust the e2e row: it is what the model received.
Fixes worth a draft PR
- Error handling or fail-open paths that produce
hook_error,broker_unavailableor timeouts. - Hook messages that are unclear or too long.
- Starting the broker earlier, for example at SessionStart, if the cold start exceeds the threshold.
- Each fix needs a test in
plugins/native/tests/, rebuilt bundles, and a greennode qa/hooks.mjs --quickrun.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

