agentleFS
patronus-protectpatronus-protect/patronus-security-cli/.claude/skills/qa-hooks/SKILL.md

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.

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
  1. Very specific:

    Run node qa/hooks.mjs (add --live on the weekly run).

    line 28
  2. Very specific:

    Read ~/.patronus-qa/runs/<date>/hooks.json.

    line 29
  3. Very specific:

    Error or timeout rates: look at metrics.hooks[*].errors and trace the error code in plugins/native/src/hooks.ts, broker.ts, daemon.ts.

    line 31
  4. Very specific:

    Detection misses: look at metrics.replay rows with expect=flag and verdict=pass.

    line 32
  5. Very specific:

    Message UX: read the hook messages a person or agent sees (systemMessage, additionalContext, warnings in plugins/deepseek/src/notice.ts, …

    line 36

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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:

  1. Preflight: records integration <host> status and hashes of the global host config files. A globally active Patronus plugin becomes a finding.
  2. Enable in a sandbox only. It uses three layers:

    • direct calls into the built hook bundles,
    • claude --plugin-dir with its own CLAUDE_CONFIG_DIR,
    • a temporary CODEX_HOME with a scripted model.

    Hook lifecycle journaling is switched on with PATRONUS_HOOK_TRACE=1.

  3. 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.
  4. Teardown: closes every broker session and deletes the sandbox, also on SIGINT or SIGTERM.
  5. Postflight: the global config hashes and the integration state must be unchanged.

Steps

  1. Run node qa/hooks.mjs (add --live on the weekly run). It takes about 20 minutes, and --quick runs the replay only. Never run integration <host> enable|install yourself.
  2. Read ~/.patronus-qa/runs/<date>/hooks.json. Check that every check is ok, especially global host config unchanged. If that check failed, stop and report it as critical. Do not restore files yourself.
  3. Investigate the findings:
    • Error or timeout rates: look at metrics.hooks[*].errors and trace the error code in plugins/native/src/hooks.ts, broker.ts, daemon.ts.
    • Detection misses: look at metrics.replay rows with expect=flag and verdict=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=pass and verdict=flag.
    • Prompt policy: UserPromptSubmit misses may be policy, not detection; compare with plugins/deepseek/src/prompt-policy.ts.
    • Cold start / latency: compare against qa/thresholds.json and the previous run in ~/.patronus-qa/history.jsonl.
  4. Message UX: read the hook messages a person or agent sees (systemMessage, additionalContext, warnings in plugins/deepseek/src/notice.ts, failureMessage in hooks.ts). Each message should say what happened, whether the content is safe to use, and the one next command. Record unclear or overlong messages as ux findings.
  5. 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.json as 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_unavailable or 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 green node qa/hooks.mjs --quick run.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.