test-driven-development

Enforces red-green-refactor test-driven development workflow before writing production code.

Updated Jan 12, 2025
One-click install
npx skills add https://github.com/rinbarpen/NeuroTrain --skill test-driven-development-rinbarpen
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/rinbarpen/NeuroTrain/tree/main/.cursor/commands/test-driven-development
Command: npx skills add https://github.com/rinbarpen/NeuroTrain --skill test-driven-development-rinbarpen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers often write production code first and add tests afterward, which produces tests that pass immediately and prove nothing about correctness. This Skill enforces a strict test-first discipline so every feature, bugfix, and refactor is backed by a test that was watched failing before implementation. ## Core Features & Use Cases - Red-Green-Refactor Enforcement: Guides the AI through writing a failing test, verifying the failure, writing minimal passing code, and refactoring while keeping tests green. - Rationalization Detection: Lists common excuses for skipping TDD (e.g., "too simple to test", "I'll test after") and mandates deleting code written before tests. - Testing Anti-Pattern Reference: Ships a companion reference covering mock-behavior testing, test-only production methods, incomplete mocks, and over-mocking, with gate functions to catch violations. - Use Case: When asked to fix a bug where an empty email is accepted, the Skill directs writing a failing test asserting the rejection error, verifying it fails, then implementing the minimal validation fix. ## Quick Start Ask the AI to implement a new feature or bugfix using test-driven development with a failing test written and verified before any production code.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I practice test-driven development on a new feature?▼

Write one minimal failing test describing the desired behavior, run it to confirm it fails for the right reason, then write the simplest code that passes. Refactor only after all tests are green, and repeat the cycle for each new behavior.

How do I fix a bug using TDD?▼

Write a failing test that reproduces the bug first, then implement the minimal fix until the test passes. This proves the fix works and creates a regression test preventing the bug from returning.

Why should tests be written before production code?▼

Tests written after code pass immediately, which proves nothing about whether they test the right behavior. Watching a test fail first confirms it actually exercises the missing feature rather than typos or existing behavior.

When is it acceptable to skip test-driven development?▼

Exceptions are limited to throwaway prototypes, generated code, and configuration files, and only with explicit approval from your human partner. Exploration is allowed, but the exploratory code must be discarded before restarting with TDD.

What are common mocking mistakes in unit tests?▼

Common mistakes include asserting on mock elements instead of real behavior, adding test-only methods to production classes, mocking without understanding side effects, and creating incomplete mocks missing fields downstream code uses. Mock minimally at the correct level and mirror real API structures completely.