test-hygiene-scanner
Skill2 starsChanged 7 days agoMITView on GitHub
Triage hardcoded dates, AsyncMock misuse, cross-tier truncates, envelope assertions, and singleton leaks in tests.
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 11 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Run a fixed set of searches over test files, then use judgment only to triage the hits.
- Distinctive: line 26
Read: only the file:line hits and enough surrounding lines to classify them.
- Distinctive: line 27
Do not read: production source, migrations, or unrelated repositories.
- Distinctive: line 41
Emit the report: Do not edit tests unless the caller explicitly asks.
- Distinctive: line 45
Use judgment only for:
- Distinctive: line 51
Do not add new categories or scan production code.
- Very specific: line 77
Use No <category> found. when a search is empty.
- Distinctive: line 81
Stop if neither test root exists.
- Distinctive: line 82
Do not report production code or non-test files.
- Distinctive: line 83
Do not apply fixes without an explicit request.
- Distinctive: line 87
Run the five searches exactly once.
- Distinctive: line 88
Default: open at most 20 surrounding-line windows.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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
Test Hygiene Scanner
<!--
contract: .claude/rules/doctrine/skill-execution.md
version: 2.0.0, owner: John D
-->Run a fixed set of searches over test files, then use judgment only to triage the hits. The searches are deterministic; do not invent categories or scan production code.
Inputs
- Required: the test roots (
tests). - Read: only the file:line hits and enough surrounding lines to classify them.
- Do not read: production source, migrations, or unrelated repositories.
Deterministic Steps
- Scan once.
The script owns the categories and regexes; do not run alternate searches.python3 .claude/skills/test-hygiene-scanner/scripts/scan.py \ tests - Triage every hit. For each, open only the surrounding lines and assign:
ERROR— definitely wrong for this project.WARNING— may cause flakes or false confidence.CLEAN— the hit is a legitimate fixture or already patched.
- Emit the report. Do not edit tests unless the caller explicitly asks.
LLM Judgment
Use judgment only for:
- distinguishing a real violation from a legitimate fixture;
- writing a concrete replacement;
- deciding whether a hit is ERROR vs WARNING.
Do not add new categories or scan production code. If a test hit reveals a production defect, add a one-line out-of-scope note; do not expand the scan.
Output
## Test Hygiene Report
### Hardcoded Dates
- ERROR|WARNING `<file>:<line>` — <why> — fix: <replacement>
### AsyncMock Misuse
- …
### Cross-Tier Truncates
- …
### Envelope Assertions
- …
### Singleton Leaks
- …
**Clean categories:** <list>Use No <category> found. when a search is empty.
Stop Conditions
- Stop if neither test root exists; report the missing path.
- Do not report production code or non-test files.
- Do not apply fixes without an explicit request.
Token Budget
- Run the five searches exactly once; do not re-scan with variations.
- Default: open at most 20 surrounding-line windows. If there are more hits, triage the highest-severity 20 and report the remaining count as untriaged.
- Target ≤ 700 words; cite file:line, not full files. Summarize repeated hits.
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.

