Skip to content
Back to skills

Test First

ASecurity

Use when writing or changing code that has behaviour to test - new features, bug fixes, refactors - so that a failing test exists before the implementation.

  • 2 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added October 22, 2026
developmentgodocumentation

Security analysis

A100/100

Scanned October 22, 2026

npx -y skills add Ethos6/superpowers --skill test-first --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Test First?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Test First
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ethos6-test-first/badge)](https://www.skillsdirectory.com/skills/ethos6-test-first)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: test-first
description: Use when writing or changing code that has behaviour to test - new features, bug fixes, refactors - so that a failing test exists before the implementation.
---

# Test first

A test you have never seen fail proves nothing: it might not run, might test the wrong thing, or might pass by accident. So the order is fixed: failing test, minimal code, passing test, tidy up.

## The cycle

1. **Write one test** for the next small behaviour. Use the exact examples from the spec's acceptance checks when they exist. Name it after the behaviour, not the function.
2. **Watch it fail** for the right reason: `sp test <n> --expect fail --match "<name of the new test>"`. Without `-- <command>` it runs the task's `Verify:` command; add one to run something more focused. `--match` makes the run count only if its output mentions your test, which rules out failures elsewhere in the suite. It cannot tell why your test failed, so read the message: a missing import or typo is not the red you want.
3. **Make it pass** with the smallest change that does so. No extra features, options or "while I'm here" edits.
4. **Run it green:** `sp test <n> --expect pass`. Then run the wider suite, since a change can break neighbours. Long output can be shortened with `--tail 40`.
5. **Tidy** names and duplication with the tests green. Re-run after tidying.

`sp done` checks that a failing run was recorded before the first passing one. That is the evidence that the test came first.

## Bug fixes

Reproduce the bug as a failing test first. That test is the proof the fix works and the guard against it coming back.

## Good tests

- Test behaviour through the public interface, not private details.
- One reason to fail per test. Clear failure messages.
- Real code over mocks; mock only slow, external or non-deterministic edges (network, clock, randomness).
- No sleeps to wait for async work; wait for the condition itself, with a timeout.

## When test-first does not fit

Pure configuration, documentation, generated code, or exploratory spikes you will throw away. Mark the plan task `Test-first: no - <reason>` and still record a passing check before closing it. If you wrote code before its test anyway, say so plainly; the honest fix is to delete that code and redo it test-first.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.