Check audit
Test-pruning core adapted from openclaw's test-audit skill (MIT, OpenClaw Foundation; see LICENSE).
Read AGENTS.md and .agents/pstack/rules/tests.md first. Stay read-only when asked only for candidates or gaps, and skip third-party skills or vendor code. skill-audit owns agent prose (skills, playbooks, AGENTS.md); check-audit owns everything executable that tests, gates, or slows down delivery.
Run the scanner
shnode <skill>/scripts/audit.mjs <target> [--json] [--events <path>]
Reports landChecks and always: true generators, check.mjs land step counts, large baseline files, hook parity and missing-script references across .agents/hooks.json, .claude/settings.json, and .codex/hooks.json, oversized or zero-caller scripts under tooling/scripts/ or scripts/, and recent Local CI events.jsonl red/flake counts.
Default bar
Internal, helper, and post-hoc unit tests, slow land checks, and micro-scripts are guilty until they guard a real user defect that E2E, public boundary, type, lint, or zero-baseline invariant checks miss. Keep a test only when breaking public behavior fails it and refactoring internals keeps it passing (principle-test-behavior-not-implementation).
Hard safety net
- Never cut E2E, deterministic concurrency/sync, or public golden tests without an explicit replacement.
- Never silently delete an unwired security, access, auth, PHI, consent, or customer-send guard whose only caller is a test; flag it as a finding so production wires or retires it intentionally.
- Never delete a test failing on the current tree or raise a timeout/limit to make CI green; reproduce and fix the bug or fixture first.
Pass 1: Tests
Cut coherent package or owner batches without per-test scratch mutation courtrooms:
- Internal and test-only entries:
*.internal.*files and tests importing non-public or test-only exports. Delete dead test-only exports and helpers with them (knip --productionorgit grep). - Low-signal shapes: mock-verifying, constant-pinning (unless user-promised with the promise named), source-text/grep, assertion-free, self-comparing, snapshot, and exhaustive-matrix tests.
- Timing bounds: wall-clock assertions outside dedicated benchmarks.
- Duplicate coverage: unit tests whose user behavior is already exercised by a kept E2E, golden, or public boundary test.
- Flaky and slow tests: fix deterministic flakes in one pass or cut and replace; cut slow tests that duplicate boundary coverage and shrink inputs on unique slow tests.
Reserve targeted scratch mutant or refactor checks only for genuinely uncertain edge cases, never as mandatory paperwork on clear cuts.
Pass 2: Landing speed
Audit what blocks every land.mjs run (landChecks, land: true steps in check.mjs, and generated entries with always: true):
- Measure wall-clock time and real failure-catch rate per landing step.
- Demote slow, rarely tripped, or broad-blast steps from
landto post-landing Local CI or on-demand--audit. - Remove
always: trueregeneration on outputs that only change when specific sources change.
Pass 3: Local CI and baselines
Audit check.mjs, CI workflows, and baseline files against recent failure history (events.jsonl or CI logs):
- Rank steps by red count, flake rate, and time-to-green; fix root causes of chronic flakes or cut checks that only produce noise.
- Demote multi-hundred-line known-bad baseline sweeps out of blocking CI into on-demand audit commands.
- Fold static invariants into types or lint rules and delete redundant micro-scripts.
Pass 4: Scripts and gate hooks
Audit tooling/scripts/, scripts/, and runtime hook configs (.agents/hooks.json, .claude/settings.json, .codex/hooks.json):
- Delete zero-caller orphan scripts, retired-runtime helpers, and Stop hooks that fire after
land.mjshas already pushed commits. - Move land-time invariants into
landChecksovergit diff <base>..HEADinstead of parsing per-runtime JSONL transcripts in Stop hooks. - Close hook parity gaps across active agent runtimes and flag oversized single-purpose scripts (
>= 600lines) for simplification.
Full mode and validation
In /check-audit full, run the scanner, write an area ledger in the run directory (files, line counts, timings, failure counts, state), and process one area per batch, highest leverage first. Ask the owner before changing hooks, landChecks, or blocking CI policy unless explicitly authorized.
Validate every deleted or changed batch:
- Run remaining tests, boundary/E2E suites, typecheck, lint, and hook/contract tests.
- When removing files, scripts, or exports, run the project's full check (
pnpm checkor equivalent) to catch stale contract lists, hook paths, or manifests. - Report removed categories, landing/CI speed delta, production or script deletions unlocked, kept edge cases, commands run, and separate production, test, and tooling line counts.


