/agent-skills:test-guidelinesfrom agent-skills
How to write a test that verifies behavior instead of rotting alongside the code — Given-When-Then structure plus named anti-patterns (tautological assertions, bug-matching assertions, reflexive over-mocking, coverage chasing, interaction assertions, snapshot rubber-stamping, busy-waiting) and what to do when a test fails. Use whenever writing, editing, or reviewing a test.
Ships in agent-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Structure every test as Given-When-Then. The test name states the full scenario — Given the setup, When the action, Then the outcome — so a failing test is diagnosable from its name alone, without opening the body. Split the body into three commented sections matching the name:
@Test
fun `Given a cart with one item When applying a 10 percent discount Then reduce the total by 10 percent`() {
// Given
val cart = Cart(items = listOf(Item(price = 200)))
// When
val total = cart.applyDiscount(percent = 10)
// Then
assertEquals(180, total)
}
Tautological assertions. The expected value is derived from the same code path being tested (or a mock is asserted to return what it was told to return). This proves the code ran, not that it's correct.
Bug-matching assertions. When the implementation is wrong, fix the implementation — don't write the Then to match its wrong output. A test's job is to encode intent, not to rubber-stamp whatever the code currently does.
Reflexive over-mocking. Mocking a collaborator that isn't a true external boundary, until nothing real executes and the test verifies wiring instead of behavior.
Coverage chasing. A test written to touch a line rather than to verify a guarantee. Coverage is a byproduct of testing real behavior, not something to target directly.
Interaction assertions. Verifying a mock was called instead of verifying the resulting behavior. This couples the test to implementation — a refactor that preserves behavior can still break it.
Snapshot rubber-stamping. Approving a snapshot diff without reading it turns the assertion into a no-op that always passes.
Busy-waiting via sleep. A hardcoded delay standing in for a real condition — wait on the actual state or event instead; a sleep is both slower and less reliable.
Fix the implementation. If the right fix isn't clear, stop and report what failed, what you tried, and your hypothesis. Never weaken the assertion, skip the test, or delete it to force a green run — that hides the bug instead of resolving it.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub joachimwedin/agent-skills --plugin agent-skills32 skills in this plugin
/blackbox-test-casesGenerate exhaustive, non-negotiably rigorous black-box test case descriptions (Given/When/Then, not code) for a public API's external contract — never its implementation. Use for zero-tolerance test coverage, an extremely strict/exhaustive black-box test case sweep, or whenever "thorough" test-case generation isn't thorough enough. Produces an API handoff file, one case file per sub-agent — each is its own source of truth — and a master index file pointing at all of them. Every case carries a checkbox so a later implementing agent can track what's been turned into runnable tests. This skill never writes runnable tests itself./brand-palettePick a primary and accent color that fit a given project and fit each other, or — given an explicit primary — pick three accent candidates that each fit the primary and the project, then generate the full Tailwind v4 color-token system (raw OKLCH scales plus the semantic layer, light and dark) for all three candidates as copy-paste CSS and a visual HTML report written into the project. Use when the user wants brand colors chosen for a project, a Tailwind color system generated from a repo, or a secondary/accent color picked to pair with a primary they already have./codebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.