mcpField
T
test-driven-development

test-driven-development

github.com/dralgorhythmTesting & quality12964 installsUpdated 14w ago
Repository

About test-driven-development

A skill that explains the test-driven development cycle: write a failing test, implement the minimum needed, then refactor. It helps developers apply this workflow to features, bug fixes, business logic, and API contracts.

Key features

  1. 01Red-Green-Refactor cycle
  2. 02Stepwise test-first workflow
  3. 03TDD examples in TypeScript
  4. 04Guidance on test design
  5. 05Situations suited to TDD

Use cases

  1. 01Developing features with clear requirements
  2. 02Fixing bugs by writing a failing test first
  3. 03Testing complex business logic
  4. 04Developing API contracts

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dralgorhythm/claude-agentic-framework --skill test-driven-development

After installing, type/test-driven-developmentin Claude Code to confirm it loaded.

Details

From the project README

Test-Driven Development

The TDD Cycle

  1. Red: Write a failing test
  2. Green: Write minimal code to pass
  3. Refactor: Improve code while keeping tests green

Workflows

  • Write Test: Write a test that describes desired behavior
  • Run Test: Verify it fails (Red)
  • Implement: Write minimal code to pass
  • Run Test: Verify it passes (Green)
  • Refactor: Clean up while tests stay green
  • Repeat: Next test case

TDD Example

Step 1: Red - Write Failing Test
describe("Calculator", () => {
  test("adds two numbers", () => {
    const calc = new Calculator();
    expect(calc.add(2, 3)).toBe(5);
  });
});

// Run: FAIL - Calculator is not defined
Step 2: Green - Minimal Implementation
class Calculator {
  add(a: number, b: number): number {
    return a + b;
  }
}

// Run: PASS
Step 3: Refactor (if needed)

Code is already clean, move to next test.

Step 4: Next Test
test("subtracts two numbers", () => {
  const calc = new Calculator();
  expect(calc.subtract(5, 3)).toBe(2);
});

// Run: FAIL - subtract is not defined

TDD Benefits

  • Design Feedback: Tests reveal design issues early
  • Documentation: Tests document expected behavior
  • Confidence: Refactor fearlessly with test safety net
  • Focus: One behavior at a time

TDD Tips

  1. Start Simple: Begin with the simplest test case
  2. One Assert: Each test should verify one behavior
  3. Descriptive Names: Test names are documentation
  4. No Logic in Tests: Tests should be obvious
  5. Fast Feedback: Tests should run in milliseconds

When to Use TDD

  • New features with clear requirements
  • Bug fixes (write failing test first)
  • Complex business logic
  • API contract development

When TDD is Less Useful

  • Exploratory/prototype code
  • UI layout changes
  • Simple CRUD operations

Comments

Markdown supported