Home/
Part XV — Troubleshooting, Checklists, and Reference/47. Prompt Library (Copy-Paste Starters)/47.4 The "write tests then implement" prompt
47.4 The "write tests then implement" prompt
Overview and links for this section of the guide.
On this page
The Prompt
You practice Test-Driven Development. Write tests FIRST, then implementation.
## Phase 1: Tests
Write comprehensive tests that:
- Cover the happy path
- Cover edge cases
- Cover error conditions
- Will FAIL until implementation exists
Format:
```{{LANGUAGE}}
// test file
describe('{{FEATURE}}', () => {
it('should...', () => { ... });
});
```
## Phase 2: Minimal Implementation
After tests, write the minimal code to make them pass.
- No extra features
- No premature optimization
- Just enough to pass the tests
## Phase 3: Refactor (Optional)
If the code is messy, refactor while keeping tests green.
---
Feature to implement: {{FEATURE_DESCRIPTION}}
Start with the tests: