Skip to content

Test Driven Development

Verified

TDD-oriented workflow enforcing Red-Green-Refactor cycle.

By Antigravity / sickn33 v1.0 Updated 2026-03-15

Install

Claude Code

Add to .claude/skills/

About This Skill

Test Driven Development is a skill that enforces the classic Red-Green-Refactor cycle when Claude Code writes or modifies code. By default, AI coding agents tend to write implementation code first and tests as an afterthought (if at all). This skill reverses that order, requiring the agent to write a failing test before writing any production code.

The workflow follows three strict phases. In the Red phase, the agent writes a test that captures the desired behavior and verifies it fails. This confirms the test is actually testing something meaningful and that the feature doesn't already exist. In the Green phase, the agent writes the minimum implementation code needed to make the test pass — no more. This prevents over-engineering and keeps changes small and verifiable. In the Refactor phase, the agent improves code quality, removes duplication, and cleans up naming while ensuring all tests continue to pass.

The skill enforces several discipline rules that prevent common AI agent shortcuts. The agent must not write implementation and tests simultaneously. Each test must be seen failing before the implementation is written. The agent should resist the urge to write more code than necessary to pass the current test. After each Green-Refactor cycle, the agent considers whether additional test cases are needed to cover edge cases, error conditions, and boundary values.

This skill works with any testing framework the project already uses — pytest, Jest, JUnit, Go's testing package, or others. It reads the existing test structure and follows the same patterns, file organization, and assertion style already established in the codebase.

TDD through this skill is particularly valuable for implementing business logic, data transformations, API endpoints, and utility functions where correctness is critical. It naturally produces well-tested code with high coverage and serves as living documentation of expected behavior.

Use Cases

  • Implementing complex business logic with full test coverage from the start
  • Building API endpoint handlers where input validation and error handling must be airtight
  • Writing data transformation functions that need verified correctness for edge cases
  • Refactoring legacy code safely by establishing a test harness before making changes

Pros & Cons

Pros

  • + Guarantees test coverage as a byproduct of the development process
  • + Prevents over-engineering by requiring only minimal code to pass each test
  • + Produces tests that serve as executable documentation of expected behavior

Cons

  • - Slower initial velocity compared to writing implementation code directly
  • - Less suited for exploratory prototyping where requirements are still unclear
  • - Requires the project to have a working test runner and framework configured

Stay Updated on Agent Skills

Get weekly curated skills + safety alerts

每周精选 Skills + 安全预警