1---2name: test-writing3description: Test coverage audits, writing, and review.4---56## Workflow781. Classify the request as audit or review versus writing or updating, then trace the named behavior and its existing tests.92. Apply the test-quality rules below. For a repo, directory, suite, or other broad surface, also use $systematic-work and the repository-audit10 workflow.113. For audit or review requests, report findings without editing. For writing or update requests, run the official focused test command and report12 coverage, changes, results, and remaining risk.1314## Test quality1516- Name the observable behavior contract before accepting, adding, or changing a test.17- Add coverage only for a meaningful behavior gap such as changed behavior, a boundary, failure, authorization, persistence, integration, or18 user-visible state.19- Add a bug regression only when it fails on the original bug and protects behavior users or callers rely on.20- Never deploy as part of test writing, test review, or verification. Prove behavior locally or in CI without mutating a deployed environment.21- Do not add or retain committed tests for disposable code that is available only in local, development, or test environments and has no production,22 user-facing, deployment, security, migration, release, or relied-on infrastructure contract. Temporary disposable tests and probes may use any23 format, but keep them outside the repository and remove them after use.24- Reject tests of private calls, incidental order or branching, intermediate objects, non-contract storage shapes, irrelevant DOM structure, framework25 behavior, or mock and fixture choreography.26- Prefer the lowest test layer that proves the contract. Use integration or feature coverage when the contract includes wiring, persistence, framework27 behavior, permissions, rendered UI, events, jobs, or multiple collaborators.28- Mock real boundaries rather than reenacting implementation. Verify a call only when the call itself is the contract.29- Accept a test only when it catches the intended break and survives reasonable implementation refactors.3031## Repository test audit32331. Define the exact scope and build a durable inventory from the repository's test-discovery sources. Split large inventories into non-overlapping34 slices.352. Track every test file or case as:36 - `keep`: valid contract and healthy test.37 - `rewrite`: useful contract but brittle, shallow, overfit, or at the wrong layer.38 - `merge`: duplicated coverage or one contract split into branch-shaped tests.39 - `move`: valid test in a stale or misleading location.40 - `delete`: invalid, redundant, stale, or non-contractual.41 - `investigate`: requires product, implementation, or external-service evidence.42 - `unclear`: cannot be decided safely with available evidence.433. Name the protected contract for every retained test and assess missing coverage, duplication, brittleness, placement, runtime, and flakiness.44 Passing verification alone does not establish suite quality.454. Prefer rewriting or merging when the behavior matters. Delete only when equivalent coverage exists or the final report records the resulting gap.465. When the user approves auditing and repairing the full scope, proceed through classification, edits, moves, deletions, and verification without47 per-item approval unless a decision is product-sensitive or genuinely unclear.486. Finish with the inventory source, total reviewed, counts by status, material changes, runtime or flakiness findings, commands and results, and49 every unresolved item.