test-writing
Skill1 starsChanged 6 months agoMITView on GitHub
Decide what to test, structure tests with arrange/act/assert, and avoid common pitfalls. Use when the user asks to write, add, or improve tests for existing code, or wants test coverage for a new feature.
6 other projects use a version of this.
Adopted by
Most recently taken up by
- wilbeibi/wilbeibi-skillstheir own version, first seen Sep 7, 2026
- NVIDIA/torch-harmonicstheir own version, first seen Jul 13, 2026
- jnMetaCode/skillettheir own version, first seen Jun 10, 2026
- kumar303/pietheir own version, first seen Jun 8, 2026
- andreaswasita/copilot-agents-dojotheir own version, first seen Jun 4, 2026
- plipowczan/claude-piv-skeletontheir own version, first seen Jan 22, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- NVIDIA/torch-harmonics★ 710same name
- andreaswasita/copilot-agents-dojo★ 54same name
- plipowczan/claude-piv-skeleton★ 4same name
- wilbeibi/wilbeibi-skills★ 2same name
- jnMetaCode/skillet★ 1same name
- kumar303/pie★ 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 repository50 other files it gives its agents.
- accessibility-reviewSkill
- adr-authorSkill
- api-designSkill
- architecture-reviewSkill
- caching-strategySkill
- changelogSkill
- ci-cd-pipelineSkill
- codebase-explorationSkill
- code-reviewSkill
- code-style-guideSkill
- context-engineeringSkill
- conventional-commitsSkill
- cost-optimizationSkill
- database-migrationSkill
- data-privacy-reviewSkill
- debuggingSkill
- dependency-updateSkill
- deprecation-migrationSkill
- error-handlingSkill
- feature-flag-rolloutSkill
- filament-resource-designSkill
- flux-ui-patternsSkill
- git-workflowSkill
- i18n-reviewSkill
- idea-refineSkill
- incident-responseSkill
- incremental-implementationSkill
- inertia-patternsSkill
- laravel-ai-featuresSkill
- laravel-eloquent-performanceSkill
- laravel-queue-designSkill
- laravel-testingSkill
- livewire-component-designSkill
- llm-feature-designSkill
- observabilitySkill
- onboarding-docSkill
- performance-budgetSkill
- pr-descriptionSkill
- primevue-patternsSkill
- refactoringSkill
- release-checklistSkill
- resilience-patternsSkill
- runbook-authorSkill
- security-auditSkill
- spec-writingSkill
- task-breakdownSkill
- tech-debt-triageSkill
- threat-modelingSkill
- using-elyra-skillsSkill
- vue-component-patternsSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 80
Test names are sentences the codebase tells you when something breaks.
- Distinctive: line 98
Run the new test → it must pass
- Distinctive: line 100
Run the full suite → must still pass
“Common” is measured: kept by at least 6 in 10 of the 4 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 Writing
Tests exist to catch regressions and document intent. Coverage numbers are a side effect, not a goal.
When to use
- "Write tests for this function/class/module"
- "Add tests for the new feature"
- "Improve test coverage in X"
- "This isn't tested — fix that"
Procedure
1. Detect the stack
Find the existing test framework and conventions before writing anything new:
# Quick stack sniff
ls package.json composer.json pyproject.toml Cargo.toml go.mod 2>/dev/null
grep -l 'vitest\|jest\|pytest\|phpunit\|pest\|mocha\|rspec' \
package.json composer.json pyproject.toml 2>/dev/nullThen read one existing test file to match style: file location, naming (*.test.ts vs *_test.go vs test_*.py), helpers, factories.
Always match existing conventions. A "better" test style in an inconsistent codebase is a worse test.
2. Decide what to test
For each unit under test, ask:
| Category | Examples |
| Happy path | Typical input → expected output |
| Edge cases | Empty, null, zero, one, max, boundary, off-by-one |
| Error paths | Bad input, missing dependency, network/IO failure |
| Branches | Every meaningful if / switch / match arm |
| Invariants | Things that must always be true (idempotency, sort order, …) |
Don't test:
- Trivial getters/setters
- Third-party library internals
- Generated code
- Implementation details (private methods, internal call order)
3. Structure each test: Arrange / Act / Assert
def test_user_can_redeem_valid_coupon():
# Arrange — set up the world
user = make_user()
coupon = make_coupon(code="SAVE10", percent=10)
# Act — do the one thing
result = redeem(user, coupon)
# Assert — check the outcome
assert result.discount == 10
assert coupon.used_by == user.idOne Act per test. If you have two, it's two tests.
4. Name tests for behavior, not implementation
Test names are sentences the codebase tells you when something breaks.
- ✅
redeem_marks_coupon_as_used_for_redeeming_user - ✅
it returns 404 when product does not exist - ❌
test_redeem_1 - ❌
testRedeemFunction
5. Assert on observable behavior
Tests should fail when the behavior changes, not when the code structure changes.
- ✅ "After
register(), the user can log in with that email" - ❌ "After
register(),userRepository.savewas called once with{email: ...}"
The second one breaks the moment you rename a repo, even though behavior is unchanged.
6. Run and iterate
- Run the new test → it must pass
- Break the code under test deliberately → the test must fail (otherwise it doesn't actually test anything)
- Run the full suite → must still pass
Common pitfalls
| Pitfall | Why it hurts | Fix |
| Testing mocks instead of behavior | Refactors break tests even when behavior is preserved | Assert on outputs/state, not on mock calls |
| Shared mutable fixtures | Tests pass/fail depending on order | Fresh setup per test, or explicit factories |
| Time-dependent tests | Flaky on slow CI / different timezones | Inject a clock, freeze time |
| Hitting the network / real DB | Slow + flaky | In-memory DB, recorded fixtures, contract tests |
| Asserting too much | Brittle to unrelated changes | Assert only what the test name claims |
| Asserting too little | Test passes even when broken | Mutation test: break the code, watch the test fail |
| Sleep/setTimeout in tests | Flaky | Poll with timeout, or use the framework's async primitives |
Output format
Report:
## Tests added: <scope>
**Framework:** <pytest / vitest / phpunit / …>
**Coverage:**
- ✅ Happy path: …
- ✅ Edge cases: …
- ✅ Error paths: …
**Deliberately not covered (and why):**
- …
**How to run:**
\`\`\`
<exact command>
\`\`\`Anti-patterns
- ❌ Writing tests after deploying — you tested in prod, then doubled down
- ❌ Chasing 100% coverage by testing trivia
- ❌ One giant test that does seven things
- ❌ Tests that pass without an assertion (yes, this happens)
- ❌ Skipped/commented-out tests left in the codebase
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.

