test-driven-development

Test-Driven Development (TDD)

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "test-driven-development" with this command: npx skills add hjewkes/agent-skills/hjewkes-agent-skills-test-driven-development

Test-Driven Development (TDD)

Overview

Write the test first. Watch it fail. Write minimal code to pass.

Core principle: If you didn't watch the test fail, you don't know if it tests the right thing.

Violating the letter of the rules is violating the spirit of the rules.

When to Use

Always: New features, bug fixes, refactoring, behavior changes. Exceptions (ask your human partner): Throwaway prototypes, generated code, configuration files.

Thinking "skip TDD just this once"? Stop. That's rationalization.

The Iron Law

NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST

Write code before the test? Delete it. Start over.

No exceptions: Don't keep it as "reference". Don't "adapt" it while writing tests. Don't look at it. Delete means delete. Implement fresh from tests. Period.

Red-Green-Refactor

digraph tdd_cycle { rankdir=LR; red [label="RED\nWrite failing test", shape=box, style=filled, fillcolor="#ffcccc"]; verify_red [label="Verify fails\ncorrectly", shape=diamond]; green [label="GREEN\nMinimal code", shape=box, style=filled, fillcolor="#ccffcc"]; verify_green [label="Verify passes\nAll green", shape=diamond]; refactor [label="REFACTOR\nClean up", shape=box, style=filled, fillcolor="#ccccff"]; next [label="Next", shape=ellipse];

red -> verify_red;
verify_red -> green [label="yes"];
verify_red -> red [label="wrong\nfailure"];
green -> verify_green;
verify_green -> refactor [label="yes"];
verify_green -> green [label="no"];
refactor -> verify_green [label="stay\ngreen"];
verify_green -> next;
next -> red;

}

  • RED — Write one minimal failing test. Verify it fails for the right reason.

  • GREEN — Write simplest code to pass. No extras.

  • REFACTOR — Clean up. Keep tests green. Don't add behavior.

  • Repeat — Next failing test for next feature.

For detailed examples (good/bad) and step-by-step instructions, see references/tdd-detailed-process.md.

Red Flags — STOP and Start Over

  • Code before test

  • Test after implementation

  • Test passes immediately

  • Can't explain why test failed

  • "I already manually tested it"

  • "Tests after achieve the same purpose"

  • "Keep as reference" or "adapt existing code"

  • "Already spent X hours, deleting is wasteful"

  • "TDD is dogmatic, I'm being pragmatic"

  • "This is different because..."

All of these mean: Delete code. Start over with TDD.

For rationalization counters explaining WHY order matters, see references/why-order-matters.md. For good tests table, verification checklist, and when-stuck guide, see references/tdd-guidelines.md.

Final Rule

Production code -> test exists and failed first Otherwise -> not TDD

No exceptions without your human partner's permission.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

test-driven-development

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

test-driven-development

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

test-driven-development

No summary provided by upstream source.

Repository SourceNeeds Review