
Description
writing-unit-tests is an agent skill from the riekelt/principal-engineer collection, listed on skills.sh. It guides an AI agent in writing or refactoring unit tests, including a new test file, added cases, a flaky test or an unreadable one. It encodes behavior-first testing. The core principle is to test the contract, not the implementation, so a refactor that keeps behavior should not break the tests. The skill says not to assert call sequences or internal state unless the interaction is the contract, such as a required side effect at a boundary. It also says expected values should be literals worked out independently from a spec or real data, with the derivation in a comment, never recomputed with the production formula or the shared helper. Each test should cover one behavior, and its name should state the subject, the scenario and the expected outcome, such as an expired token being rejected with a 401. Tests should follow arrange, act and assert in that order, with no branching or loops in the test body. Shared setup belongs in builders or role-named fixtures. The skill names the principal-engineering skill as its background, and says the testing-changes skill decides which tests a change owes. The listing shows it as free, and its audits all show Pass results.…
Highlights
- Tests the contract, not the implementation
- One behavior per test, named as the claim
- Literal expected values with derivations
- Arrange, act, assert with no logic in tests
Ratings & Reviews
No ratings yet
Be the first to rate writing-unit-tests.
People also visit
writing-unit-tests FAQ
What does the writing-unit-tests skill do?
It guides an AI agent in writing or refactoring unit tests that check behavior rather than implementation details.
How do I install it?
Run: npx skills add https://github.com/riekelt/principal-engineer --skill writing-unit-tests
How should tests be named?
After the claim: subject, scenario and expected outcome, for example expired token is rejected with 401.
Can a test compute its expected value?
No. The skill says expected values must be literals worked out independently, not derived from production code.
Should tests contain loops or branches?
No. The skill says a test with logic needs its own test, and generation belongs in builders and helpers.
What do the security audits say?
Gen Agent Trust Hub: Pass. Socket: Pass. Snyk: Pass.
What are the best writing-unit-tests alternatives?
Popular alternatives to writing-unit-tests include principle-test-behavior-not-implementation, test and fix-tests. See all writing-unit-tests alternatives



















