← ClaudeAtlas

test-firstlisted

Use when implementing keeper code — any behavior meant to last, and especially when fixing a bug. Triggers on writing a function/feature you intend to keep, "add a test", "TDD", or the urge to write the code first and test it "after". Not for verifying a finished change before claiming it works — that's evidence-before-claims
atgreen/hackinator · ★ 1 · Testing & QA · score 72
Install: claude install-skill atgreen/hackinator
# Test-First ## Overview **Core principle:** For code you intend to keep, write the test **before** the code, and **watch it fail** before you make it pass. A test written after the code asks "what does this do?"; a test written first asks "what should this do?" — and only the second one can catch the code being wrong. If you didn't watch the test fail, you don't know it tests the right thing. It might pass because of a typo, a stubbed return, or nothing at all. ## The Iron Law ``` NO KEEPER CODE WITHOUT A FAILING TEST FIRST ``` Wrote the code before the test? Delete it and start over. Not "keep it as reference," not "adapt it while I write the test" — **delete**. The value was the *watched failure*, and you can't get it back by testing code that already works. ## Scope: What Counts as "Keeper" This law governs **code meant to last**. It does **not** govern: - **Spikes and throwaway probes** — exploration is exempt *by design*. That's the whole point of **spike-and-stabilize**: learn in the ugly spike, then rebuild the answer test-first in the stabilize phase. The spike is where you're allowed to skip tests; the keeper version is not. - **Generated code, config, and trivial declarations** with no behavior to test. When in doubt about whether something is a keeper, it's a keeper. ## RED → GREEN → REFACTOR 1. **RED** — write one small test for one real behavior. Real behavior, not a mock of it. 2. **Watch it fail (mandatory).** Run it. Confirm it fails *for the