tdd
/tdd
Runs a strict red-green-refactor loop for one acceptance criterion or behaviour: write the failing test, show the failure, write the minimum code, show it passing, refactor with tests green. Use inside /dev-story, or whenever the user wants to build or fix behaviour test-first.
- Author
- chatquill ↗
- Repository
- claude-code-websites ↗
- Licence
- MIT
- Last repository change
- 09.11.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 09.11.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Runs a strict red-green-refactor loop for one acceptance criterion or behaviour: write the failing test, show the failure, write the minimum code, show it passing, refactor with tests green. Use inside /dev-story, or whenever the user wants to build or fix behaviour test-first.
Arguments
/tdd <S-NNN AC#> | <behaviour description>
Original author description
Runs a strict red-green-refactor loop for one acceptance criterion or behaviour: write the failing test, show the failure, write the minimum code, show it passing, refactor with tests green. Use inside /dev-story, or whenever the user wants to build or fix behaviour test-first.
How it works
- Inputs
- Phases
- Rules
- Rigor
- Next step
SKILL.md preview
---
name: tdd
description: "Runs a strict red-green-refactor loop for one acceptance criterion or behaviour: write the failing test, show the failure, write the minimum code, show it passing, refactor with tests green. Use inside /dev-story, or whenever the user wants to build or fix behaviour test-first."
argument-hint: "<S-NNN AC#> | <behaviour description>"
user-invocable: true
allowed-tools: Read, Glob, Grep, Write, Edit, AskUserQuestion, Bash(bash .claude/scripts/*), Bash(npx vitest run*), Bash(npx jest*), Bash(pytest*), Bash(go test*), Bash(npx playwright test*)
model: sonnet
---
# TDD
One behaviour at a time, three steps, each shown to the user. The rule: **no
production code is written until a test has been seen failing for the right
reason.**
## Inputs
- The AC (Given/When/Then) or the behaviour description
- The story's `## Tests` map for the planned test location
- `.claude/docs/stack-matrix.md` for the test runner and conventions
- `.claude/rules/test-standards.md`
## Phases
### Phase 1: Choose the test level
| Behaviour | Level | Example |
|---|---|---|
| Pure rule (pricing, validation, permissions logic) | unit | `tests/unit/pricing.test.ts` |
| Endpoint / server action / query | integration (real test DB) | `tests/integration/projects.test.ts` |
| Component behaviour | component (Testing Library) | `src/components/__tests__/InviteForm.test.tsx` |
| User journey across pages | e2e (Playwright) | `tests/e2e/signup.spec.ts` |
Pick the lowest level that proves the AC. Name the test after the behaviour,
not the function (`rejects an expired reset token`).
### Phase 2: Red
Write the test, then ask to write it ("May I write this test to `<path>`?").
Run only that test. Show the failure output. It must fail **because the
behaviour is missing**: an import error or typo is not a valid red; fix the test
and run it again.
### Phase 3: Green
Write the **minimum** code that makes the test pass. No extra features, no
speculative abstractions. Show the diff, ask before writing, run the test, show
it passing.
### Phase 4: Refactor
With the test green, improve names, remove duplication, extract functions
(standards: ≤ 40 lines, complexity ≤ 10). Run the related tests after each change.
Skip if nothing needs it; say so.
### Phase 5: Repeat or finish
Next AC → Phase 1. When all are done, run the full suite
(`bash .claude/scripts/test-run.sh all`) and report.
## Rules
- Deterministic tests: fixed clock, seeded data, mocked third-party HTTP (MSW,
respx, httptest), never real payment, email or AI calls.
- Query UI by role and label; never by CSS class.
- Never change a test's expectation to make code pass unless the spec changed;
then say so and update the spec too.
## Rigor
Under `minimal`, `/tdd` is opt-in and the hook only warns. Under `full`, the
`tdd-guard` hook blocks source changes without a matching test change.
## Next step
Back to `/dev-story` Phase 4, or `/story-done`.
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · chatquill/claude-code-websites | 100 | MIT |
| kdlbs/kandev | 100 | AGPL-3.0 |
| sentimony/skills | 100 | MIT |
| sentimony/skills | 100 | MIT |
| TerminalSkills/skills | 100 | Apache-2.0 |
| duronext/jig | 100 | MIT |
| xoai/sage | 100 | MIT |
| rolemodel/skills | 100 | MIT |
| matteocodogno/wellforge | 100 | MIT |
Database snapshot: 13.11.2026 · package version e756db86caa0 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 1 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100red-green-refactor
Guides the red-green-refactor TDD workflow: write a failing test first, implement the minimum code to make it pass, then refactor while keeping tests green. Use when a user asks to practice TDD, write tests first, follow red-green-refactor, do test-driven development, write… - 100tdd-workflow
Use when starting a new feature or function to write failing tests first, then implement the minimal code to pass (Red→Green→Refactor) - 100test-driven-development
Use when practicing TDD. Covers the red-green-refactor loop, choosing the next test, designing through tests, and when TDD is and is not the right approach. Trigger on "let's do tdd", "write the failing test first", "red green refactor", "what test should i write next". Do not… - 100tdd-expert
Drive development with strict Red-Green-Refactor discipline - write one failing test, write the minimum code to pass it, refactor on green - including test-list planning and a worked kata cycle. Use when someone asks "write this test-first", "do TDD on this feature", "help me… - 100tdd-feature
Red-green-refactor scaffold for building new features with TDD. Write failing tests first, then implement to pass. Use when building new features test-first. - 90tdd-guide
Test-first development route for TDD, writing failing tests first, RED -> GREEN -> REFACTOR, and behavior-changing feature/bug/refactor work. Do not use for already-failing test root-cause debugging, test-report packaging, or final completion evidence.