
tdd-red-green-refactor
Enforces a disciplined Red-Green-Refactor (TDD) workflow in TypeScript/Node.js. Use this whenever creating new features, fixing bugs, or migrating logic to ensure high-quality, verifiable implementations.
- Installs
- 172
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/google-labs-code/stitch-sdk --skill tdd-red-green-refactor- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads tdd-red-green-refactor automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Red-Green-Refactor (TDD) Skill: TypeScript Edition
This skill implements a structural framework for AI-assisted programming to ensure every line of code is verifiable, typed, and purposeful.
The Three-Phase Cycle
Phase 1: Red (Establish Failure)
You must prove the feature does not exist and that your test is valid.
- Write One Test: Create a single test case (e.g., in Vitest or Jest) for the next small piece of behavior.
- Execute & Fail: Run the test. It must fail.
- Verify: Ensure the failure is related to the missing logic (e.g.,
ReferenceError: add is not defined) and not a configuration error.
Phase 2: Green (Minimal Pass)
Make the test pass as quickly and simply as possible.
- Minimal Implementation: Write the simplest code that satisfies the test. Do not build for the future; focus strictly on the current "Red" test.
- Run Tests: Execute the suite. All tests must be Green.
- Evidence: The transition from Red to Green is the "Proof of Work" for the developer.
Phase 3: Refactor (Clean Up)
Improve the code structure while maintaining the "Green" state.
- Clean Up: Improve naming, remove duplication, and optimize the code written in Phase 2.
- Safety Net: Rerun the tests after every change. If they turn Red, revert the change immediately.
Core Operational Rules
1. No "Horizontal Splurging"
You are strictly forbidden from writing a large "splurge" of multiple tests at once. You must follow a strictly incremental loop:
- Write 1 Test -> See it Fail -> Write 1 Fix -> See it Pass.
- Repeat this loop for every sub-feature.
2. Impose Backpressure
Use automated assertions and strong typing (TypeScript) as backpressure to prevent the AI from "guessing" the solution or "playing in the mud" with low-quality code.
3. Verification of Integrity
Never modify an existing test to make a failing implementation pass. If a test must change, it must be because the requirement changed, not because the code is difficult to write.
Example Workflow (TypeScript + Vitest)
Step 1: Red
// math.test.ts
import { describe, it, expect } from "vitest";
import { add } from "./math";
describe("add", () => {
it("should sum two numbers", () => {
expect(add(2, 2)).toBe(4); // Fails: ReferenceError: add is not defined
});
});
Step 2: Green
// math.ts
export const add = (a: any, b: any) => {
return 4; // Passes: Minimal code to satisfy the test
};
Step 3: Refactor
// math.ts
/**
* Sums two numbers with explicit type safety.
*/
export const add = (a: number, b: number): number => {
return a + b; // Passes: Proper implementation with safety net
};
FAQ
What does the tdd-red-green-refactor skill do?
Enforces a disciplined Red-Green-Refactor (TDD) workflow in TypeScript/Node.js. Use this whenever creating new features, fixing bugs, or migrating logic to ensure high-quality, verifiable implementations.
How do I install tdd-red-green-refactor?
Run npx skills add https://github.com/google-labs-code/stitch-sdk --skill tdd-red-green-refactor in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/tdd-red-green-refactor/ (personal) or .claude/skills/tdd-red-green-refactor/ (project).
Which AI agents can use tdd-red-green-refactor?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is tdd-red-green-refactor safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains tdd-red-green-refactor?
It is published by google-labs-code in google-labs-code/stitch-sdk, and it is an official skill from the maker of the technology it covers. It has 172 recorded installs.
More from google-labs-code/stitch-sdk
stitch-sdk-usage
google-labs-code/stitch-sdk
Use the Stitch SDK to generate, edit, and iterate on UI screens from text prompts, manage projects, and retrieve screen HTML/images. Use when the user wants to consume the SDK in their application.
stitch-sdk-readme
google-labs-code/stitch-sdk
Generate or update the README for the Stitch SDK. Use the Bookstore Test structure and source the current API from the codebase. Use when the README needs to be written or updated.
stitch-sdk-development
google-labs-code/stitch-sdk
Develop the Stitch SDK. Covers the generation pipeline, dual modality (agent vs SDK), error handling, and Traffic Light (Red-Green-Yellow) implementation workflow. Use when adding features, fixing bugs, or understanding the architecture.
stitch-sdk-domain-design
google-labs-code/stitch-sdk
Design the domain model for the Stitch SDK. Use when mapping MCP tools to domain classes and bindings in domain-map.json. This is Stage 2 of the generation pipeline.
stitch-sdk-pipeline
google-labs-code/stitch-sdk
Open the skill to read its SKILL.md instructions.
stitch-sdk-bug-bash
google-labs-code/stitch-sdk
Find bugs in the Stitch SDK using a real API key. Covers standard functional edges and tricky situations.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.