← ClaudeAtlas

test-driven-developmentlisted

Red-green-refactor discipline for features and bug fixes: write one minimal failing test, watch it fail for the expected reason, write the least code that passes, refactor only on green. Use when implementing any feature or bugfix, when fixing a bug (the reproducing test comes first and the fix follows), when tempted to backfill tests after the code, or when a new test passes on its first run and therefore proves nothing yet. The bright line: production code is written only against a test you have watched fail; code that preceded its test is deleted and redone test-first, because adapting it quietly converts test-first into test-after. Exceptions — throwaway prototypes, generated code, pure configuration — are agreed with the user, not self-granted. Hands red-green evidence to verification-before-completion. Not for designing suite architecture or coverage strategy, and not for diagnosing an unexplained failure (systematic-debugging owns diagnosis and returns here for the fix).
grimaldost/craft-collection · ★ 2 · AI & Automation · score 68
Install: claude install-skill grimaldost/craft-collection
# Test-Driven Development Write the test first and watch it fail. A test you never saw fail proves nothing — it can pass for reasons unrelated to the behavior it was meant to pin. This is a **rigid** skill. The bright line: **production code is written only against a test you have watched fail.** It holds for features, bug fixes, refactors, and behavior changes alike. Exceptions — throwaway prototypes, generated code, pure configuration — are agreed with the user before skipping the cycle, not self-granted. ## The cycle One behavior at a time: red, verify red, green, verify green, refactor. ### 1. Red — write one failing test One behavior, a name that describes it, real code over mocks. ```typescript // Good: clear name, real behavior, one thing test('retries failed operations 3 times', async () => { let attempts = 0; const operation = () => { attempts++; if (attempts < 3) throw new Error('fail'); return 'success'; }; const result = await retryOperation(operation); expect(result).toBe('success'); expect(attempts).toBe(3); }); ``` A vague name ("retry works") asserting against a mock tests the mock, not the code. ### 2. Verify red — watch it fail Run the test. Confirm three things: it fails rather than errors, the failure message is the one you expected, and it fails because the feature is missing — not because of a typo. A test that passes here is testing behavior that already exists; fix the test. A test that errors is not failing correctly;