test-driven-development
Test-Driven Development
Part of Agent Skills™ by googleadsagent.ai™
Description
Test-Driven Development enforces the RED-GREEN-REFACTOR discipline on every code change an agent produces. The agent writes a failing test first, confirms the failure, writes the minimal code to pass, confirms the pass, refactors for clarity, and commits. No production code exists without a corresponding test that demanded its creation.
This skill eliminates the most common agent anti-pattern: generating large blocks of untested code that "look right" but silently break under edge cases. By forcing the agent through the TDD cycle, each line of production code is justified by a specific test assertion. The result is a codebase where test coverage is not an afterthought but a structural guarantee.
The cycle integrates directly with version control. Each RED-GREEN-REFACTOR iteration produces an atomic commit, creating a reviewable history of design decisions. The refactor phase is mandatory—the agent must evaluate naming, duplication, and structural clarity before moving to the next feature increment.
Use When
- Writing any new function, method, or module
- Fixing a bug (write the test that exposes the bug first)
- Refactoring existing code (ensure tests pass before and after)
- The user requests "TDD", "test-first", or "red-green-refactor"
- Building APIs, data transformations, or business logic