tdd-red-green-refactor

Enforces incremental Red-Green-Refactor test-driven development cycles in TypeScript and Node.js projects.

1|Updated Jun 30, 2026
One-click install
npx skills add https://github.com/khulnasoft-bot/design.md --skill tdd-red-green-refactor-khulnasoft-bot
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tdd-red-green-refactor
Source: https://github.com/khulnasoft-bot/design.md/tree/main/.agents/skills/tdd
Command: npx skills add https://github.com/khulnasoft-bot/design.md --skill tdd-red-green-refactor-khulnasoft-bot

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? AI-assisted coding often produces large, unverified code blocks written in one pass, making it hard to confirm correctness or catch regressions. This Skill imposes a disciplined Red-Green-Refactor loop so every line of code is backed by a failing-then-passing test. ## Core Features & Use Cases - Three-Phase Cycle Enforcement: Guides the AI through Red (write one failing test), Green (minimal passing implementation), and Refactor (clean up while tests stay green). - Incremental Test Discipline: Forbids writing multiple tests at once, requiring a strict one-test, one-fix loop for every sub-feature. - Test Integrity Protection: Prevents modifying existing tests just to make failing implementations pass, using TypeScript typing and assertions as backpressure. - Use Case: When adding a new utility function to a Node.js service, the AI writes a single Vitest test, watches it fail, implements the minimal code to pass, then refactors with full type safety. ## Quick Start Use the TDD skill to implement a new string-reversal utility in TypeScript with Vitest, following the red-green-refactor cycle one test at a time.

Frequently Asked Questions about tdd-red-green-refactor

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

FAQPage Schema
How do I practice test-driven development in TypeScript?▼

Write one failing test in Vitest or Jest for the next small behavior, then write the minimal code to make it pass, then refactor while keeping tests green. Repeat this loop for each sub-feature rather than writing many tests at once.

What is the red-green-refactor cycle in TDD?▼

Red means writing a test that fails because the feature does not exist yet. Green means writing the simplest code that makes the test pass. Refactor means improving naming, removing duplication, and adding types while the tests stay green.

Does this TDD workflow work with Vitest and Jest?▼

Yes, the workflow is demonstrated with Vitest and applies equally to Jest since both support the same describe/it/expect test structure. Any TypeScript-compatible test runner fits the red-green-refactor loop.

Why should I write only one test at a time in TDD?▼

Writing one test at a time keeps each failure traceable to a single missing behavior and prevents large unverified code splurges. The tight feedback loop ensures every line of implementation is justified by a passing test.

When should I not modify an existing failing test?▼

Never modify an existing test just to make a failing implementation pass, since that hides defects. A test should only change when the underlying requirement itself has changed, not because the code is difficult to write.