Tdd

From FastLED/FastLED · View interactive version

Tdd is an AI agent skill from the GitHub repository FastLED/FastLED. Guide Test-Driven Development workflow for FastLED. Use when implementing new features or fixing bugs with a test-first approach. Enforces Red-Green-Refactor discipline with FastLED test conventions.

How to use this skill

Skill file

TDD Workflow — Red-Green-Refactor for FastLED

You are guiding a Test-Driven Development cycle. Follow the strict Red-Green-Refactor discipline.

Input

$ARGUMENTS

Phase 1: RED — Write a Failing Test

Steps

  1. Understand the requirement: Read relevant source code to understand the API and behavior
  2. Find existing tests: Search tests/ for related test files — prefer extending them
  3. Write the test FIRST: Create a minimal test that describes the expected behavior
  4. Run the test: Execute bash test TestName to verify it FAILS
  5. Verify failure reason: The test must fail because the feature is missing or the bug exists, NOT because of a compile error or typo

Test Conventions

Output

## RED Phase

**Test file**: tests/unit/fl/example.cpp
**Test case**: "Feature - expected behavior"
**Status**: FAILS as expected
**Failure reason**: [why it fails — confirms the test is valid]

Phase 2: GREEN — Make It Pass

Steps

  1. Write minimal code: Implement just enough to make the test pass
  2. No premature optimization: Simplest solution that works
  3. Run the test: Execute bash test TestName to verify it PASSES
  4. Run full suite: Execute bash test --cpp to verify no regressions

Output

## GREEN Phase

**Implementation**: src/fl/example.h (lines X-Y)
**Changes**: [brief description of what was added/changed]
**Test status**: PASSES
**Full suite**: All tests pass (no regressions)

Phase 3: REFACTOR — Clean Up

Steps

  1. Review the code: Look for duplication, unclear naming, unnecessary complexity
  2. Refactor incrementally: Make one change at a time
  3. Run tests after each change: bash test TestName must stay green
  4. Consider edge cases: Add 1-2 more test cases if critical edge cases are obvious
  5. Run full suite: bash test --cpp to confirm everything still passes

Output

## REFACTOR Phase

**Changes made**: [list of refactoring improvements]
**Test status**: All tests still pass
**Edge cases added**: [any additional test cases, or "none needed"]

Final Summary

After all three phases, provide:

## TDD Summary

**Feature**: [what was implemented]
**Test file**: [path]
**Source file(s)**: [paths]
**Tests added**: [count and names]
**All tests passing**: Yes/No

Key Rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.