test-quality
Skill209 starsChanged 2 months agoMITView on GitHub
Apply test quality principles when generating or reviewing test code. Enforces Arrange-Act-Assert structure, one behavior per test, assertion quality, test isolation, meaningful naming, and test data management. Use when writing tests, reviewing test code, or when the user mentions 'write tests', 'test this', 'test quality', 'test review', 'improve tests', or 'test structure'. Loaded automatically by the code-generating molecules (code-forge, refactor-safely, bug-fix). This skill governs the craft of writing individual test cases -- not what to test (that is driven by the code being implemented) but how to write tests that are reliable, readable, and maintainable.
We split this skill into the rules it gives an agent
9 rules. 0 are common, 4 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 11 edited versions we read keep these.
4
Distinctive
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
- Very specific: line 11
Read .lattice/config.yaml in the repo root.
- Very specific: line 12
If found, check paths.test_quality for a custom document path.
- Very specific: line 13
If a custom document exists at that path, read it and check its YAML frontmatter for mode:
- Very specific: line 16
If a custom path is configured but no document exists at it → tell the user which configured path is missing, then fall back to …
- Very specific: line 17
If there is no config file or no paths.test_quality key, read ./references/defaults.md.
- Distinctive: line 33
Project-specific checks: if the loaded doc (from Config Resolution) contains a validation checklist section, apply those checks after the …
- Distinctive: line 35
All checks pass → state "Passes test-quality.
- Distinctive: line 39
After the checklist, scan for each of these.
- Distinctive: line 66
Run steps 3–5 only, scoped to the changed test:
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Test Quality
Config Resolution
Projects can customize this skill's standards. Resolution order:
- Read
.lattice/config.yamlin the repo root. - If found, check
paths.test_qualityfor a custom document path. - If a custom document exists at that path, read it and check its YAML frontmatter for
mode:mode: override: the custom document has full control. Use it instead of the embedded defaults. It must be complete -- treat it as the sole reference.mode: overlay(or no mode field): read the embedded./references/defaults.mdfirst, then apply the custom document on top. A custom section replaces the matching default section (matched by exact heading); new sections append after the defaults.
- If a custom path is configured but no document exists at it → tell the user which configured path is missing, then fall back to
./references/defaults.md. - If there is no config file or no
paths.test_qualitykey, read./references/defaults.md. - Language adaptation: if
paths.language_idiomsis set in the config and the document exists, read its "Testing Patterns" section and adapt §5 (Test Naming Conventions), §4 (Test Isolation Techniques), and §6 (Test Data Builders and Factories) to the language's test-framework idioms. Language idioms take precedence over the pseudocode defaults.
Self-Validation Checklist
STOP after generating each test. Verify ALL checks before continuing. Fix every failed check. If a check is ambiguous (see Ambiguity Signals), flag it -- present options and reasoning.
- AAA STRUCTURE: Are arrange, act, and assert visually separate (blank lines)? Is there any logic (if/loop/try) inside arrange or assert?
- SINGLE BEHAVIOR: Does the test verify one behavior per the loaded doc (default: one behavior per test; a name that needs "and" → split it)?
- ASSERTION QUALITY: Does it assert observable behavior rather than implementation? Is it specific enough to catch a regression?
- ISOLATION: Does the test depend on another test's output or effects? Is all mutable state created per-test?
- TEST NAME: Does the name follow the team convention per the loaded doc (default: describe the behavior, not the method)? Is the failure message clear?
- TEST DATA: Does complex arrange use builders/factories? Are magic values promoted to named constants? (Inline literals are fine for trivial tests.)
- MOCK BOUNDARIES: Are mocks placed per the loaded doc (default: only at architectural boundaries -- I/O, external services -- not between internal collaborators)?
- TEST CODE AS FIRST-CLASS: Is the test structured like production code? Shared constants at top, helpers extracted, no dead code, clear file organization?
Project-specific checks: if the loaded doc (from Config Resolution) contains a validation checklist section, apply those checks after the base checklist.
All checks pass → state "Passes test-quality. [next step]."
Active Anti-Pattern Scan
After the checklist, scan for each of these. Any box you can check → fix before presenting.
- Test-per-Method: one test per method regardless of behaviors → one test per scenario, named for the behavior.
- Assertion Roulette: multiple unrelated assertions; unclear which one broke → split to one behavior per test.
- Shared Mutable State: tests pass alone but fail together → isolate state; per-test setup; no static mutable data.
- Testing Implementation Details: test breaks on a refactor that preserves behavior; mocks assert call counts → assert observable behavior, not method calls.
- Mystery Guest: test depends on an external file/db/env var not visible in the test → inline the data or use builders; make all preconditions visible.
- Slow Tests by Default: the unit suite takes minutes; tests hit db/network/filesystem → mock or fake I/O; use in-memory implementations.
- Conditional Test Logic: a test contains if/loop/try -- a test that needs its own tests → remove the logic; use parameterized tests; let assertions fail naturally.
- Copy-Paste Tests: near-identical tests with small changes → extract shared setup into builders; parameterize.
Class-Level Review
Fires when: (1) all tests for a class are complete -- new or existing; (2) any test in an existing class is added or edited.
STOP before presenting. The per-test checks verify individual quality; this review verifies that the test suite covers the class's contract.
Full review (new class or significant additions)
- Behavior inventory — list every public method/behavior of the class under test. If the class is not available, ask the user to enumerate them.
- Coverage matrix — map each test to the behavior it covers. Any behavior with zero tests → blocking. Do not present until the user closes the gap or explicitly accepts it.
- Error path check — scan the class under test for explicit throws, conditional error branches, and edge guards. For each one found: does a test exercise this path? If not → flag it by name. Zero-coverage error paths are blocking unless the user explicitly accepts them.
- Behavioral duplication — compare the "then" clauses across all tests. The same observable outcome regardless of structural differences → flag as likely duplication; name both tests.
- Balance signal — any behavior that has tests but none covering a failure or edge case → surface as a question, not a hard failure: "
deleteUserhas 1 test (happy path only) -- does it have error cases?"
Edit-scoped review (adding or changing one test in an existing class)
Run steps 3–5 only, scoped to the changed test:
- Does this test duplicate the observable outcome of any existing test?
- Does it cover a behavior or error path not previously covered?
Ambiguity Signals
Multiple valid outcomes exist. Present the options rather than silently choosing. If framework:collaborative-judgment is loaded, use its presentation format. See ./references/defaults.md for resolution guidance.
- Unit vs Integration: a service coordinates several components -- test it in isolation (mocked) or with real collaborators? Depends on the coupling and what the test must verify.
- Mock Depth: mock direct dependencies or let calls pass through? Over-mocking tests the implementation; under-mocking creates slow, flaky tests.
- Test Granularity: one test with multiple assertions vs multiple tests with one assertion each? When the assertions verify facets of the same behavior, grouping is fine.
Test Code as First-Class Code
Treat test files like production classes:
- Shared constants and boundary values at the top of the file (named, not magic)
- Shared builders/factories extracted to helpers -- not copy-pasted per test
- Setup methods or fixtures for repeated arrange patterns
- Logical grouping: related behaviors together (by feature, by scenario type)
- Dead tests removed, not commented out
- Refactoring applies: extract a method when arrange is long, rename when intent is unclear, move shared setup when duplicated
Refactoring opportunities to surface proactively:
- Multiple tests repeat the same arrange → extract a builder or shared fixture
- The same assertion pattern across tests → extract a custom assertion helper
- A test file grows beyond ~300 lines → split by behavior group
- Constants scattered inline → collect at the top with descriptive names
- Deeply nested test structures → flatten with clear naming
See ./references/defaults.md for AAA structure examples, assertion patterns, isolation techniques, naming conventions, test data builder patterns, and pyramid distribution guidance.
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- modelcontextprotocol/python-sdk★ 25ksame name
- assistant-ui/assistant-ui★ 13ksame name
- cataclysmbn/Cataclysm-BN★ 1.3ksame name
- cataclysmbnteam/Cataclysm-BN★ 1.3ksame name
- decebals/claude-code-java★ 763same name
- rcore-os/tgoskits★ 76same name
- rollinsio/beyond-test-coverage★ 52same name
- AhmedAbdelfattah0/AI-Skills★ 4same name
- hams-ollo/zen-agent-skills★ 2same name
- andrewclark88/skills★ 1same name
2 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use security-audit.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
CloudflareSkillsecurity-audit
Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.
Also in 3 projects that use this
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- architecture-compassSkill
- architecture-refinerSkill
- architectureSkill
- bug-fixSkill
- clean-code-refinerSkill
- clean-codeSkill
- code-forgeSkill
- collaborative-judgmentSkill
- context-anchoringSkill
- ddd-refinerSkill
- design-blueprintSkill
- design-firstSkill
- domain-driven-designSkill
- knowledge-priming-refinerSkill
- knowledge-primingSkill
- language-idioms-refinerSkill
- lattice-initSkill
- learning-harvestSkill
- refactor-safelySkill
- refiners-updateSkill
- requirement-forge-refinerSkill
- requirement-forgeSkill
- requirement-qualitySkill
- review-refinerSkill
- reviewSkill
- secure-codingSkill
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.

