# Tdd Workflow

> Write tests first, enforce red-green-refactor, keep commits tight.

- Skill: `sabahattink/tdd-workflow` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add sabahattink/tdd-workflow`
- Raw SKILL.md: https://api.skillmd.com/api/skills/sabahattink/tdd-workflow/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: sabahattink (https://skillmd.com/u/sabahattink)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/sabahattink/tdd-workflow

---


# TDD Workflow

Use when: implementing any feature or bug fix.

## The loop

1. **Red** — write one failing test. Run it. Confirm the error message.
2. **Green** — write the minimum code that makes the test pass. Nothing more.
3. **Refactor** — tidy the design while green. Re-run tests.
4. **Commit** — one conventional-commit-style message per green cycle.

## Rules

- Never write implementation before the failing test exists.
- Each commit should leave the suite green.
- If a test is hard to write, the design is wrong — refactor the code, not the test.
- Coverage is a side effect, not a goal.

## When to deviate

- Exploratory spikes: write code without tests to answer a question, then discard the spike and restart with a test.
- External API contracts: record a real response as a fixture before mocking.

## Pairing with other skills

- `systematic-debugging` when a test is failing for unclear reasons
- `receiving-code-review` when your PR comes back with test-shape feedback

