Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
itallstartedwithaidea avatar

Test Driven Development

  • 54 installs
  • 31 repo stars
  • Updated April 12, 2026
  • itallstartedwithaidea/agent-skills

Force your coding agent through RED-GREEN-REFACTOR so every production line is backed by a failing test first, then minimal implementation and a refactor commit.

About

Test-Driven Development is an Agent Skills package skill that locks coding agents into classic TDD instead of dumping large untested blocks that look plausible but fail on edge cases. Solo and indie builders shipping with Claude Code, Cursor, or Codex invoke it whenever the agent will add or change behavior: new functions, modules, bug fixes, or refactors. The workflow is explicit—RED (failing test you can see fail), GREEN (smallest code to pass), REFACTOR (clarity without changing behavior)—and each loop ends in version control as an atomic commit. That turns coverage from a late audit into a structural guarantee because code only exists to satisfy assertions the agent already wrote. It pairs naturally with planning and review skills: after a spec is approved, TDD is how implementation stays honest under automation. The skill does not replace your test framework choice; it governs agent behavior so discipline survives fast iteration.

  • Enforces RED-GREEN-REFACTOR on every agent-generated change
  • Requires a failing test before any new production code
  • One atomic git commit per completed TDD cycle for reviewable history
  • Mandatory refactor pass on naming, duplication, and structure before the next increment
  • Bug fixes start by writing a test that reproduces the failure

Test Driven Development by the numbers

  • 54 all-time installs (skills.sh)
  • +3 installs in the week ending Aug 2, 2026 (Skillselion tracking)
  • Ranked #1,203 of 2,153 Testing & QA skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/itallstartedwithaidea/agent-skills --skill test-driven-development

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs54
repo stars31
Security audit3 / 3 scanners passed
Last updatedApril 12, 2026
Repositoryitallstartedwithaidea/agent-skills

What it does

Force your coding agent through RED-GREEN-REFACTOR so every production line is backed by a failing test first, then minimal implementation and a refactor commit.

Files

SKILL.mdMarkdownGitHub ↗

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
  • You need confidence that a change does not introduce regressions

How It Works

graph LR
    R[RED: Write Failing Test] --> G[GREEN: Minimal Code to Pass]
    G --> RF[REFACTOR: Clean Up]
    RF --> C[COMMIT: Atomic Commit]
    C --> R
    style R fill:#e74c3c,color:#fff
    style G fill:#2ecc71,color:#fff
    style RF fill:#3498db,color:#fff
    style C fill:#95a5a6,color:#fff

RED: Write a test that describes the next small behavior increment. Run it. Confirm it fails for the expected reason—not a syntax error or import failure, but a genuine assertion failure. GREEN: Write the simplest production code that makes the test pass. Resist the urge to generalize. REFACTOR: Improve names, extract duplication, simplify control flow. All tests must still pass. COMMIT: Stage and commit with a message referencing the behavior added.

Implementation

# RED: Write the failing test first
def test_calculate_discount_applies_ten_percent_for_orders_over_100():
    order = Order(items=[Item(price=150.00)])
    result = calculate_discount(order)
    assert result == 135.00  # 10% off

# Run: pytest => FAIL (calculate_discount not defined)

# GREEN: Minimal implementation
def calculate_discount(order):
    total = sum(item.price for item in order.items)
    if total > 100:
        return total * 0.9
    return total

# Run: pytest => PASS

# REFACTOR: Extract magic numbers
DISCOUNT_THRESHOLD = 100
DISCOUNT_RATE = 0.10

def calculate_discount(order):
    total = sum(item.price for item in order.items)
    if total > DISCOUNT_THRESHOLD:
        return total * (1 - DISCOUNT_RATE)
    return total

# Run: pytest => PASS
# git commit -m "feat: apply 10% discount for orders over $100"

Anti-Patterns to Avoid

Anti-PatternWhy It Fails
Writing tests after codeTests confirm assumptions, not behavior
Testing implementation detailsBrittle tests break on valid refactors
Skipping the RED stepNo proof the test can actually fail
Large GREEN stepsLose traceability of which test drives which code
Skipping REFACTORTechnical debt accumulates silently

Best Practices

  • Each RED-GREEN-REFACTOR cycle should take under 5 minutes
  • If GREEN requires more than 10 lines, the test is too ambitious—split it
  • Name tests as behavior specifications: test_<action>_<condition>_<outcome>
  • Run the full test suite after every REFACTOR, not just the new test
  • Commit after each complete cycle to preserve the design narrative
  • Use test doubles (mocks, stubs) only at architectural boundaries

Platform Compatibility

PlatformSupportNotes
CursorFullShell tool runs tests inline
VS CodeFullTerminal integration for test runs
WindsurfFullCascade executes test commands
Claude CodeFullDirect shell access for pytest/jest
ClineFullConfigurable test runner
aiderPartialManual test confirmation needed

Related Skills

  • Systematic Debugging - Root cause analysis that starts by writing a failing test reproducing the bug
  • Code Review - Quality gate that verifies test coverage alongside production code changes
  • Subagent-Driven Development - Isolated subagents that follow TDD cycles independently for each subtask

Keywords

tdd test-driven-development red-green-refactor failing-test-first test-first unit-testing regression-prevention atomic-commits

---

© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License

Related skills

FAQ

Is Test Driven Development safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Testing & QAbackendtesting

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.