tdd-red-green-refactor

Enforce a Red-Green-Refactor TDD cycle for TypeScript/Node.js codebases.

Updated May 5, 2025
One-click install
npx skills add https://github.com/yopitek/Obsidian --skill tdd-red-green-refactor-yopitek
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tdd-red-green-refactor
Source: https://github.com/yopitek/Obsidian/tree/main/HQ/10_resources/03_writing_prompts/stittch_design_md/.agents/skills/tdd
Command: npx skills add https://github.com/yopitek/Obsidian --skill tdd-red-green-refactor-yopitek

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The Red-Green-Refactor workflow enforces a structured TDD cycle to ensure every feature begins with a failing test, then a minimal passing implementation, followed by refactoring—keeping code verifiable and maintainable.

Core Features & Use Cases

  • Red-Green-Refactor cycle: write a failing test, implement minimal code to pass, and refactor for readability and safety.
  • Guardrails: strict incremental development with backpressure and typing to avoid speculative coding.
  • Use Case: apply to new features, bug fixes, or migrations in TypeScript/Node.js projects to maintain high-quality, testable code.

Quick Start

Use this skill to guide a single red-green-refactor cycle for a TypeScript function: write a failing test, implement the minimal code to pass it, then refactor.

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 enforce a strict red-green-refactor TDD cycle in TypeScript?

To enforce a strict red-green-refactor TDD cycle in TypeScript, use a workflow that mandates writing a failing test first, implementing minimal code to pass, and refactoring with safety nets. This prevents speculative coding by applying strict incremental development.

What is the red-green-refactor workflow for Node.js testing?

The red-green-refactor workflow in Node.js testing is a structured TDD cycle where you write a failing test, implement the minimal code required to make it pass, and then refactor the code for readability and maintainability while keeping tests green.

Can I use Vitest for test-driven development in a Node.js project?

Yes, you can use Vitest for test-driven development in a Node.js project. The workflow supports TypeScript and Node.js environments, utilizing Vitest to run tests incrementally and verify failures before moving to minimal implementation and refactoring.

How do I prevent speculative coding when writing TypeScript tests?

To prevent speculative coding when writing TypeScript tests, apply strict incremental development with backpressure and typing. This ensures you write one failing test at a time and implement only the minimal code needed to pass before refactoring.

Does the TDD red-green-refactor cycle work for bug fixes and migrations?

Yes, the TDD red-green-refactor cycle works for bug fixes and migrations. Applying this workflow to TypeScript and Node.js codebases ensures that changes are verifiable, tests are written first, and minimal correct implementations are produced safely.

What are the limitations of using a strict TDD workflow in TypeScript?

A strict TDD workflow in TypeScript requires strict adherence to running one test at a time and avoiding speculative coding. This may slow down initial feature development but ensures high-quality, testable, and maintainable code through continuous verification.