Skip to content

lootlog/monorepo / .agents/skills/test-audit

test-audit

Verified

Gate every new or changed test, and audit existing tests for low-value, implementation-coupled, or duplicative coverage and the test-only production seams they keep alive. Use when writing, changing, reviewing, or pruning tests.

Test Audit

Three modes, one value bar. Authoring mode gates every new or changed test at write time. Audit mode runs focused sweeps of tests that re-assert source, duplicate stronger proof, couple behavior to implementation, or keep test-only production seams alive. Continue broad audits as separate coherent follow-up changes; optimize for confidence, not deletion count. Campaign mode prunes one whole subsystem's test surface (every test file an app, service area, or package owns); before starting one, read CAMPAIGN.md.

The Verification section of AGENTS.md is the baseline test policy. This skill adds the gate, the audit workflow, and the evidence a deletion needs.

Authoring gate

Before adding any test, answer four questions; a missing answer means do not add it yet:

  1. What observable behavior, invariant, or independent contract does it protect?
  2. What credible regression makes it fail?
  3. Why does existing coverage not already catch that failure? Each contract has one primary test owner at the strongest boundary; another layer needs its own distinct risk, such as a transport or lifecycle failure the owner cannot reach. Prefer extending a table-driven case or shared fixture over a near-duplicate test; consolidate duplicated setup in the same change.
  4. Does it need a production seam (export, flag, wrapper, injection hook) that no production caller needs? If yes, move the test to the real boundary instead.

Then check the test against every junk pattern; a match fails the gate unless the retention bar names the contract it independently guards. A test that would break under behavior-preserving refactoring is asserting implementation, not behavior; rewrite it at the owning boundary before landing it.

Bug regression tests must fail on the pre-fix code for the intended reason and pass after the owner-boundary repair. A regression test that never demonstrably failed proves the mock, not the fix. One regression at the owner boundary covers the bug; do not replay the same scenario at every layer it crosses (Game client, HTTP, RabbitMQ, gateway, Web).

Junk patterns

The shared checklist for both modes: the authoring gate rejects a new test that matches one, and audits hunt for existing tests that do.

  • assertion-free coverage probes;
  • self-comparisons and identity copiers;
  • copied fixtures, inventories, manifests, or export lists;
  • exact source, import, or string greps;
  • private predicate or call-shape tests duplicated at real boundaries;
  • duplicate invocations of the same contract;
  • workspace-local replays of a helper a shared package already tests;
  • tests whose only purpose is preserving test-only exports, globals, or wrappers;
  • dead production code whose only callers are tests;
  • expected values produced by the helper or renderer under test;
  • mocks that implement the asserted behavior, or one identical mock standing in for different APIs;
  • fixtures that supply the receipt, admission, or callback ordering the owner should produce, or persistence asserted against a store the path never writes;
  • tests that restate a declared flag, config, or Capability list instead of exercising the delivery, acknowledgement, or access decision it promises;
  • negative controls that pass for an unrelated reason, such as a denial from a different guard, an Organization-scope rejection the path never reaches, or a validation error that fires before the check under test;
  • names or fixtures that promise more than the input exercises, such as a "clears the timer" test asserting the timer was not cleared.

Value bar

Tests justify their maintenance cost by protecting behavior, a credible regression, or an independently meaningful contract. In an audit, an existing test that must change for behavior-preserving source reorganization is suspect, not automatically deletable; the authoring gate still rejects new ones.

Before judging a candidate, read the complete test and production owner, its entry point, callers, callees, sibling implementations, overlapping tests, the workspace test and test:integration scripts, and relevant history. Use CodeGraph to trace callers. When the test claims dependency-backed behavior, inspect the dependency source or types directly, under repos/ when vendored.

Discovery

Keep discovery read-only and report evidence before editing. For broad scope, run parallel discovery lanes as read-only subagents:

  • Game client (apps/game-client);
  • Web app and public surfaces (apps/web, apps/landing, apps/docs, apps/wiki, apps/developer);
  • backend services (apps/api, apps/auth, apps/gateway, apps/battlelog, apps/activity, apps/search, apps/discord-bot);
  • shared packages, scripts, and tooling (packages/, scripts/, tools/);
  • a cross-cutting pattern sweep.

Outside campaign mode, prefer a few high-confidence candidates over a large speculative inventory. Hunt for the junk patterns.

Retention bar

Keep a test when it independently enforces a contract AGENTS.md protects: Margonem runtime semantics (object, callback, this, exception, return value, request count), Game client performance bounds, Organization isolation and Capability checks, HTTP schemas and response statuses, RabbitMQ facts, WebSocket events, generated clients, persisted data and migrations, consumer idempotency under redelivery, userscript settings and stored preferences, public battle links, or a public SDK contract. Also keep:

  • Game client characterization tests for runtime, adapter, processor, projection, and domain-store behavior;
  • golden expectations, until an intended behavior change is established independently;
  • call ordering when order is observable behavior;
  • regressions with a credible failure mode;
  • source inspection when it is the cheapest independent guard: it fails when the contract changes (the user-facing key, byte, or path) and survives an identifier-only refactor;
  • a retained test that fails on the baseline: treat it as a possible product bug, reproduce it, and repair the owner rather than deleting it.

Static or slow is not a deletion reason. A test that resembles implementation may still be the independent contract; prove otherwise before removing it.

Candidate evidence

Record every field below before editing. A missing field means the candidate is not ready for deletion:

  • exact test name and location;
  • what failure it can actually detect;
  • non-test callers of the covered production or support seam;
  • stronger remaining owner-boundary proof, or why no proof is needed;
  • relevant history and the reason the test or seam exists;
  • production or test-support deletion unlocked;
  • risk and the focused validation command.

Edit shape

Choose one coherent owner-boundary batch. Delete obsolete test-only exports, globals, wrappers, and dead production paths instead of preserving aliases. Move retained regressions to their canonical owners. Consolidate repeated package or dependency assertions into one generic contract.

Prefer net-negative production LOC. Do not add replacement tests that restate the same implementation, and do not convert uncertain candidates into cleanup to increase deletion counts.

Validation

  1. Run the smallest owner and sibling tests with the runner the workspace's test script uses: bun --conditions=development test <path> or bunx vitest run <path>, from the workspace directory.
  2. test excludes *.integration.* suites. When a change touches one, run the workspace test:integration script (testcontainers needs Docker). Those scripts list files explicitly and CI runs only what they list, so register every moved or renamed integration suite there.
  3. For removed source greps or contract assertions, run the command that owns the real contract, such as bun run client:check.
  4. Run bunx oxfmt <changed-paths>, then git diff --check.
  5. Run bunx turbo run lint typecheck test --filter=<workspace> for every affected workspace, and bun run knip to catch exports and files the deletion orphaned.
  6. Inspect git diff --numstat; report production/tooling separately from tests and test support.
  7. After final audit edits, have an independent reviewer (a fresh subagent or the code-review skill when available) compare deleted coverage against the remaining proof.

Landing and continuation

Follow the Delivery section of AGENTS.md. Land one coherent change at a time; after landing, refresh from current main and rerun read-only discovery for the next high-confidence batch.

Handoff

Report:

  • root cause and removed low-value categories;
  • production owner simplifications;
  • retained false positives and why they remain valuable;
  • focused and full proof actually run;
  • production versus test LOC;
  • commit, branch, or pull request state;
  • named follow-ups.
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 467kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 193kUpdated Claude CodeCodexVerifiedInstall