tdd

Guides test-driven development through the Red-Green-Refactor cycle with behavior-focused testing.

3|Updated Nov 8, 2014
Ready to run
npx skills add https://github.com/mintuz/.dotfiles --skill tdd-mintuz
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: tdd
Source: https://github.com/mintuz/.dotfiles/tree/main/agents/.agents/skills/tdd
Command: npx skills add https://github.com/mintuz/.dotfiles --skill tdd-mintuz

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? It prevents ad-hoc coding by enforcing that every line of new or changed behavior is written only in response to a failing test, keeping implementations minimal and tests meaningful. ## Core Features & Use Cases - Red-Green-Refactor Discipline: Enforces writing one failing test first, adding minimal code to pass, then assessing refactoring with a reversible green baseline. - Behavior-Focused Testing: Promotes testing business outcomes through public APIs only, with factory functions instead of let/beforeEach shared state. - Violation Detection: Provides checklists and decision trees to catch critical violations like production code without a failing test or implementation-detail testing. - Use Case: When adding a free-shipping rule to an order processor, write a failing test for the behavior, implement the minimal conditional, then refactor constants only after all tests stay green. ## Quick Start Ask the AI to implement a new feature using strict TDD with the Red-Green-Refactor cycle, writing a failing test before any production code.

Frequently Asked Questions about tdd

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I practice TDD with the Red-Green-Refactor cycle?▼

Write one failing test describing the desired behavior, run it to confirm it fails for the right reason, then write the minimum code to pass. After green, assess whether refactoring adds value while keeping all tests passing.

How to write behavior-focused tests instead of implementation tests?▼

Test business outcomes through public APIs only, verifying what the code does rather than how. Avoid spying on internal methods or accessing private state, and use descriptive names that document intent.

Should I use factory functions or beforeEach for test data?▼

Use factory functions with optional overrides for test data instead of let/beforeEach, which create shared mutable state and hidden coupling. Reserve beforeEach for resources needing setup and teardown like servers or database transactions.

When is it acceptable to refactor code without tests?▼

Only refactor code covered by green tests. For untested code, first write a characterisation test that records actual current output, get it green, then refactor in small reversible steps without changing external APIs.

What counts as a valid failing test in TDD?▼

A valid RED fails because the behavior does not exist yet, such as an unresolved import of the module being created or a wrong result from the code under test. Harness faults like typos or broken runner config must be fixed first.