skills/testing/test-driven-development/SKILL.md
RED-GREEN-REFACTOR cycle with strict phase gates for TDD.
npx skillsauth add notque/claude-code-toolkit test-driven-developmentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Enforce the RED-GREEN-REFACTOR cycle for all code changes. Tests are written before implementation code, verified to fail for the right reasons, and maintained through disciplined development cycles.
| Signal | Load These Files | Why |
|---|---|---|
| errors, error handling | error-handling.md | Loads detailed guidance from error-handling.md. |
| example-driven tasks | examples.md | Loads detailed guidance from examples.md. |
| tasks related to this reference | phase-guidance.md | Loads detailed guidance from phase-guidance.md. |
Before starting any TDD cycle, read and follow repository CLAUDE.md files. Project instructions override default TDD behaviors because local conventions (test frameworks, directory layout, naming) vary across codebases.
Full phase guidance (steps, rationale, code examples, language commands) lives in references/phase-guidance.md. Load it when you need detailed instructions or examples. The sections below are the lean phase skeleton plus the mandatory gates.
Write a test that describes the desired behavior before any implementation exists. Use specific assertions, descriptive names, Arrange-Act-Assert pattern, and one concept per test. Run the test and show full output. Details: references/phase-guidance.md.
Proceed to the GREEN phase only after all of these are true:
The test must fail because the feature is not implemented, NOT because of syntax errors, import errors, wrong test setup, or unrelated failures. Expected patterns per language and recovery steps: references/phase-guidance.md.
Write ONLY enough code to make the failing test pass. No extra features. Hardcoded values are OK initially. Over-engineering and correct examples: references/phase-guidance.md.
Run the test and the full suite; show complete output. Never summarize. Debug guidance: references/phase-guidance.md.
Proceed to the REFACTOR phase only after all of these are true:
Improve code quality without changing behavior. Establish a green baseline first, refactor incrementally, run tests after every step. Test behavior, not internals. Decision criteria table and behavior-vs-internals examples: references/phase-guidance.md.
Mark the task complete only after all of these are true:
Commit the test and implementation together as an atomic unit. Run the full suite, commit with a descriptive message, clean up temporary files. Report facts without self-congratulation.
Each feature gets its own RED-GREEN-REFACTOR cycle. Do not batch multiple features into one cycle. Wrong-vs-correct cycle examples: references/phase-guidance.md.
Load references/error-handling.md when a cycle is stuck. It covers: test passes before implementation, test fails for wrong reason, tests pass but feature does not work, refactoring breaks tests.
documentation
Document translation: quick/normal/refined modes with chunked parallel subagents and glossary support.
development
AI image generation: Gemini and Nano Banana backends; single/series/batch workflows with prompt-to-disk.
testing
Unified voice content generation pipeline with mandatory validation and joy-check. 13-phase pipeline: LOAD, GROUND, STATS-CHECKPOINT, GENERATE, HOOK-GATE, VALIDATE, REFINE, VARIETY-GATE, JOY-CHECK, ANTI-AI, CLOSE-GATE, OUTPUT, CLEANUP. Use when writing articles, blog posts, or any content that uses a voice profile. Use for "write article", "blog post", "write in voice", "generate content", "draft article", "write about".
documentation
Critique-and-rewrite loop for voice fidelity validation.