skills/tdd/SKILL.md
Enforce strict Test-Driven Development (TDD) using the red-green-refactor cycle. Use when writing unit tests, practicing test-first development, applying TDD discipline, or implementing features via red-green-refactor workflows.
npx skillsauth add MeroZemory/oh-my-droid tddInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
Write code before test? DELETE IT. Start over. No exceptions.
| If You See | Action | |------------|--------| | Code written before test | STOP. Delete code. Write test first. | | Test passes on first run | Test is wrong. Fix it to fail first. | | Multiple features in one cycle | STOP. One test, one feature. | | Skipping refactor | Go back. Clean up before next feature. |
Before each implementation:
npx jest --watchAll # Should have ONE new failure
# or: npx vitest run, pytest, go test ./...
After implementation:
npx jest --watchAll # New test should pass, all others still pass
capitalize Function// src/strings.test.js
const { capitalize } = require('./strings');
describe('capitalize', () => {
it('should uppercase the first letter and lowercase the rest', () => {
expect(capitalize('hello')).toBe('Hello');
});
it('should handle single character strings', () => {
expect(capitalize('h')).toBe('H');
});
it('should return empty string for empty input', () => {
expect(capitalize('')).toBe('');
});
});
Run tests — they fail because strings.js does not export capitalize:
FAIL src/strings.test.js
● capitalize › should uppercase the first letter and lowercase the rest
TypeError: capitalize is not a function
// src/strings.js
function capitalize(str) {
if (!str) return '';
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
}
module.exports = { capitalize };
Run tests — all three pass:
PASS src/strings.test.js
capitalize
✓ should uppercase the first letter and lowercase the rest
✓ should handle single character strings
✓ should return empty string for empty input
Extract a guard clause for clarity, ensure tests still pass:
function capitalize(str) {
if (str.length === 0) return '';
return str[0].toUpperCase() + str.slice(1).toLowerCase();
}
Tests still green. Move to the next failing test.
When guiding TDD:
## TDD Cycle: [Feature Name]
### RED Phase
Test: [test code]
Expected failure: [what error you expect]
Actual: [run result showing failure]
### GREEN Phase
Implementation: [minimal code]
Result: [run result showing pass]
### REFACTOR Phase
Changes: [what was cleaned up]
Result: [tests still pass]
Remember: The discipline IS the value. Shortcuts destroy the benefit.
documentation
Agentic memory system for writers - track characters, relationships, scenes, and themes
development
Decompose multi-step tasks into parallel sub-agent workloads, route each sub-task to the cheapest capable model tier (Haiku/Sonnet/Opus), run long-running commands in the background, and verify all deliverables before stopping. Use when the user asks to 'go fast', 'parallelize', 'ultrawork', or when a request contains 3+ independent sub-tasks that benefit from concurrent execution.
tools
QA cycling workflow - test, verify, fix, repeat until goal met
development
Parallel autopilot with file ownership partitioning