test-guard
Skill1.3k starsChanged 5 months agoMITView on GitHub
Review generated or changed test code against universal testing rules before it ships. Best used reactively after an agent writes, edits, generates, or refactors tests, before presenting, committing, or merging them. Use for pytest (test_*.py, *_test.py), PHPUnit/Pest (*Test.php), Jest/Vitest (*.test.ts, *.spec.js), Go (*_test.go), files under tests/, __tests__/, or spec/, and review requests like 'write tests for X', 'add tests', 'test this', 'review these tests', or PR diffs containing tests. Can also guide test writing when explicitly invoked before the work. This skill is the quality gate that prevents AI-generated test bloat. DO NOT USE for production or implementation code review (use clean-code-guard), CI or test-runner configuration, running or debugging tests, or general architecture discussion.
1 other project uses a version of this.
Trending
Quiet since October.thin dataabout the whole repository
Most recently taken up by
- furkananter/skillstheir own version, first seen Aug 13, 2026
Who's talking about amElnagdy/guard-skills
- sudosubin/agents.nix“agent-skills.github.amelnagdy.guard-skills: v1.0.0 → refs/tags/v1.0.0”GitHub · Oct 3, 2026
- ProSkillsMD/proskills“[Candidate] amelnagdy/guard-skills/skills/wp-guard - wp-guard”GitHub · Sep 27, 2026
- ProSkillsMD/proskills“[Candidate] amelnagdy/guard-skills/skills/woo-guard - woo-guard”GitHub · Sep 27, 2026
- ProSkillsMD/proskills“[Candidate] amelnagdy/guard-skills/skills/test-guard - test-guard”GitHub · Sep 26, 2026
- ProSkillsMD/proskills“[Candidate] amelnagdy/guard-skills/skills/docs-guard - docs-guard”GitHub · Sep 26, 2026
The biggest 5 of 9 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 9
Talked about on GitHub (9 times).
On GitHub · 9
- Oct 3, 2026agent-skills.github.amelnagdy.guard-skills: v1.0.0 → refs/tags/v1.0.0 — sudosubin/agents.nix0 reactions
- Sep 27, 2026[Candidate] amelnagdy/guard-skills/skills/wp-guard - wp-guard — ProSkillsMD/proskills0 reactions · 2 comments
- Sep 27, 2026[Candidate] amelnagdy/guard-skills/skills/woo-guard - woo-guard — ProSkillsMD/proskills0 reactions · 2 comments
- Sep 26, 2026[Candidate] amelnagdy/guard-skills/skills/test-guard - test-guard — ProSkillsMD/proskills0 reactions · 2 comments
- Sep 26, 2026[Candidate] amelnagdy/guard-skills/skills/docs-guard - docs-guard — ProSkillsMD/proskills0 reactions · 2 comments
4 more on GitHub
- Sep 26, 2026[Candidate] amelnagdy/guard-skills/skills/clean-code-guard - clean-code-guard — ProSkillsMD/proskills0 reactions · 1 comment
- Sep 25, 2026agent-skills.github.amelnagdy.guard-skills: init at 1.0.0 — sudosubin/agents.nix0 reactions
- Jul 10, 2026Feature Request: Add guard-skills (amElnagdy/guard-skills) to the collection — FrancoStino/opencode-skills-collection0 reactions · 1 comment
- Jun 8, 2026[github] amElnagdy/guard-skills — baekenough/second-brain0 reactions
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- furkananter/skills★ 1same name
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.
In this repository4 other files it gives its agents.
- clean-code-guardSkill
- docs-guardSkill
- woo-guardSkill
- wp-guardSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 12 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
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 23
Check the project's own agent instructions (CLAUDE.md, AGENTS.md) and testing docs.
- Distinctive: line 28
If the project calls LLM APIs, uses agent frameworks, or wires up observability/telemetry, also read references/llm-app-testing.md — it …
- Distinctive: line 33
Read the test code: the diff, the new file, or the section being modified.
- Distinctive: line 34
Check each test against the rules below.
- Distinctive: line 36
If the user explicitly invokes this skill before test writing, apply the rules as you write — don't write violations and then flag them.
- Distinctive: line 38
When writing new tests, ask for each test: "What specific bug does this catch that no other test in this suite catches?" If you can't …
- Distinctive: line 43
Test what code does from the caller's perspective.
- Distinctive: line 51
When you mock a boundary, assert what the caller *does with the response*, not that the mock received specific arguments.
- Very specific: line 54
If two or more tests share identical setup and differ only in input/output values, merge them into one data-driven test …
- Distinctive: line 59
Ask: "What bug does this catch that no other test catches?" Delete tests that only catch typos, verify default values of data classes, or …
- Distinctive: line 76
Don't test that the validation library validates, the ORM commits, the router returns 404, or the test framework's fixtures work.
- Distinctive: line 88
When flagging violations, use this format:
- Distinctive: line 100
Not all violations are equal.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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 Guard
You are reviewing generated or changed test code before it ships. Enforce the rules below after the first test-writing pass and before the tests are presented, committed, or merged. Be a sharp reviewer, not a pedantic one: flag what wastes maintenance effort or hides real bugs, ignore cosmetic preferences.
These rules exist because coding agents over-generate tests. The common failure modes: mock-heavy unit tests that assert implementation details, near-duplicate test bodies that differ by one value, and tests that re-verify the framework instead of the project's logic. Each looks productive in a diff and costs maintenance forever.
When this skill activates
- A coding agent has just written new test functions or test files, in any language
- You are editing existing tests
- You are reviewing a diff that contains test changes
- The user asks you to write, add, or review tests
Adapt to the project first
These rules are universal, but their application is not. Before reviewing:
- Check the project's own agent instructions (CLAUDE.md, AGENTS.md) and testing docs. Project-specific testing rules win over this skill when they conflict.
- Identify the test stack, then read the matching reference for concrete patterns:
- Python / pytest → references/pytest.md
- PHP / PHPUnit / Pest / WordPress → references/phpunit.md
- JavaScript / TypeScript / Jest / Vitest → references/jest.md
- If the project calls LLM APIs, uses agent frameworks, or wires up observability/telemetry, also read references/llm-app-testing.md — it adds three rules specific to LLM applications.
- Map the project's system boundaries: network calls, databases, filesystem, clock and randomness, third-party SDKs, LLM APIs. Existing fixtures and test helpers usually reveal where the project already draws these lines.
What to do
- Read the test code: the diff, the new file, or the section being modified.
- Check each test against the rules below.
- Report violations concisely: rule number, location, why it violates, suggested fix.
- If the user explicitly invokes this skill before test writing, apply the rules as you write — don't write violations and then flag them.
When writing new tests, ask for each test: "What specific bug does this catch that no other test in this suite catches?" If you can't answer clearly, don't write it.
The Nine Rules
Rule 1: Test behavior, not implementation
Test what code does from the caller's perspective. Assert return values and observable side effects. Never assert that an internal helper was called with specific arguments — that test breaks on every refactor while catching nothing.
Violation pattern: asserting a mock of an internal function was called, where that function is not a system boundary. Fix: assert the return value or the state change the caller observes.
Rule 2: Every mock must be justified
Mock only at system boundaries: network and HTTP calls, LLM APIs, databases, filesystem I/O on external files, clock and randomness, third-party SDKs. Never mock internal classes or helper functions to isolate a "unit" — the seams you create hide the integration bugs worth catching.
When you mock a boundary, assert what the caller does with the response, not that the mock received specific arguments.
Rule 3: One scenario per test, data-driven for variants
If two or more tests share identical setup and differ only in input/output values, merge them into one data-driven test (@pytest.mark.parametrize, PHPUnit #[DataProvider], Jest test.each).
When separate tests ARE correct: different setup, different assertions, different mock configurations, or genuinely different scenarios that happen to exercise the same function.
Rule 4: Every test must justify its existence
Ask: "What bug does this catch that no other test catches?" Delete tests that only catch typos, verify default values of data classes, or test trivial pass-through logic.
Common unjustified tests: constructors setting attributes, a function rejecting input the type system already forbids, string formatting of log messages, a constant equaling its literal value.
Rule 5: Name tests for the scenario
Pattern: test_<scenario>_<expected_outcome>. The name should read like a requirement, not echo the function signature.
| Bad | Good |
test_parse_response_missing_field | test_malformed_response_falls_back_to_default |
test_get_language_no_class | test_element_without_class_returns_empty_language |
test_add_tags_single_string | test_single_tag_normalizes_to_list |
Rule 6: Production regression tests are sacred
Tests that reproduce a real production bug are always justified. Reference the incident (date, issue ID, or short description) in the name or a comment, and never delete them. They are exempt from Rule 4 — their justification is the incident.
Rule 7: No tests for framework guarantees
Don't test that the validation library validates, the ORM commits, the router returns 404, or the test framework's fixtures work. Test your logic that sits on top of the framework.
Violation pattern: a test that would still pass if you deleted all the project's custom code and kept only framework defaults.
Rule 8: State and value objects are real, never mocked
Never mock a data model, DTO, entity, or state object. Construct a real instance. Mocking state hides field-name typos and validation errors — exactly the bugs worth catching. If constructing the real object is painful, that is design feedback, not a reason to mock; add a small builder or factory helper.
Rule 9: Infrastructure under test gets real infrastructure
When database queries, schema behavior, or persistence logic is the subject of the test, run against a real test database with real migrations applied via fixtures. Mocking the session there tests nothing. Mocking the database is fine when persistence is only a side effect of the behavior under test.
Reporting format
When flagging violations, use this format:
**Rule N violation** in `tests/path/file.ext::<test_name>`
- What: <one sentence describing the violation>
- Fix: <one sentence describing what to do instead>Group violations by file. If a file has no violations, don't mention it.
Severity guide
Not all violations are equal. Use judgment:
- Must fix: Rules 1, 2, 8 — these hide real bugs or make tests brittle
- Should fix: Rules 3, 4, 5, 7 — these cause bloat and maintenance drag
- Sacred: Rule 6 — never delete, always allow
- Worth noting: Rule 9 — test architecture; flag it, but don't block small changes on it
References
- references/pytest.md — Python/pytest patterns: parametrize, fixtures, mock boundaries, real Pydantic instances
- references/phpunit.md — PHP/PHPUnit/Pest patterns, including WordPress and WooCommerce test boundaries
- references/jest.md — Jest/Vitest patterns: test.each, module mocks, msw, snapshot discipline
- references/llm-app-testing.md — three extra rules for LLM applications: prompt contracts, observability wiring, agent-flow transitions
What this skill does NOT do
- It does not run tests. Use the project's test runner for that.
- It does not enforce code style — that's the linter's job.
- It does not decide what to test — only how to test it.
- It does not flag pre-existing violations in files you're not touching, unless asked to audit.
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.

