majiayu000/test-driven-development
Enforces TDD discipline with RED-GREEN-REFACTOR cycle. Use when writing new features, fixing bugs, or refactoring code. Ensures tests genuinely verify behavior.
npx skills add https://github.com/majiayu000/spellbook --skill test-driven-development
> From obra/superpowers
Write tests before implementation. Watch them fail. Write minimal code to pass.
THE IRON LAW: NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
# Verify RED
- Run the test
- Confirm it fails
- Confirm failure is NOT due to syntax errors
- Confirm you're not testing existing functionality
# Verify GREEN
- Run all tests
- Confirm new test passes
- Confirm no other tests broke
Tests written AFTER implementation:
| Excuse | Reality |
|--------|---------|
| "Too simple to test" | Simple code still breaks |
| "I'll write tests after" | Post-implementation tests pass immediately |
| "Already manually tested" | Manual testing lacks systematic rigor |
| "Deleting work is wasteful" | Unverified code is technical debt |
| "Keep as reference" | You'll adapt it; that's testing-after |
If any of these occur, DELETE the code and start over:
# 1. RED - Write failing test
def test_user_can_login_with_valid_credentials():
user = create_user(email="[email protected]", password="secret")
result = login(email="[email protected]", password="secret")
assert result.success == True
assert result.user == user
# 2. Run test - MUST FAIL
# 3. GREEN - Implement minimal code
def login(email, password):
user = User.find_by_email(email)
if user and user.check_password(password):
return LoginResult(success=True, user=user)
return LoginResult(success=False, user=None)
# 4. Run test - MUST PASS
# 5. REFACTOR - Clean up if needed
Take majiayu000/test-driven-development from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.