agentleFS
peopleforresterpeopleforrester/claude-dotfiles/skills/development/tdd-workflow/SKILL.md

tdd-workflow

Skill3 starsChanged 8 months agoMITView on GitHub

Test-driven development workflow for implementing new features and fixing bugs. Use when the user mentions TDD, "write tests first", "red-green-refactor", or when implementing features that need comprehensive test coverage.

78 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use kotlin-testing, ralphinho-rfc-pipeline and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • tpavanipradeepSkill

    kotlin-testing

    Kotlin testing patterns with Kotest, MockK, coroutine testing, property-based testing, and Kover coverage. Follows TDD methodology with idiomatic Kotlin practices.

    Also in 6 projects that use this

  • InfopibeSkill

    ralphinho-rfc-pipeline

    RFC-driven multi-agent DAG execution pattern with quality gates, merge queues, and work unit orchestration.

    Also in 10 projects that use this

  • mryeastcodeSkill

    nuxt4-patterns

    Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.

    Also in 5 projects that use this

  • saxon-ySkill

    configure-ecc

    Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

    Also in 12 projects that use this

  • InfopibeSkill

    content-hash-cache-pattern

    Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.

    Also in 12 projects that use this

  • mryeastcodeSkill

    pytorch-patterns

    PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading.

    Also in 8 projects that use this

  • +2 more from Infopibe
  • +1 more from mryeastcode

The file

We split this skill into the rules it gives an agent

12 rules. 0 are common, 12 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 72 edited versions we read keep these.

  • 12

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When high test coverage is required

    line 28
  2. Distinctive:

    Before writing any code:

    line 50
  3. Distinctive:

    Run the test - it should fail (RED).

    line 68
  4. Distinctive:

    Run the test - it should pass (GREEN).

    line 78
  5. Distinctive:

    Add test for edge case → implement

    line 94
  6. Distinctive:

    Add test for error handling → implement

    line 95
  7. Distinctive:

    Add test for complex scenario → implement

    line 96
  8. Distinctive:

    Critical: Run tests after each change to ensure they still pass.

    line 106
  9. Distinctive:

    Write a test that reproduces the bug

    line 157
  10. Distinctive:

    Ensure no other tests broke

    line 161
  11. Distinctive:

    Write test for simplest behavior

    line 166
  12. Distinctive:

    Write test for next behavior

    line 168

“Common” is measured: kept by at least 6 in 10 of the 72 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Test-Driven Development Workflow

A systematic approach to writing code guided by tests.

When to Use

  • User explicitly requests TDD approach
  • Implementing new features with clear requirements
  • Fixing bugs (write failing test first)
  • Refactoring existing code safely
  • When high test coverage is required

The TDD Cycle

┌─────────────────────────────────────────┐
│                                         │
│   1. RED: Write a failing test          │
│      ↓                                  │
│   2. GREEN: Write minimal code to pass  │
│      ↓                                  │
│   3. REFACTOR: Improve while green      │
│      ↓                                  │
│   (repeat)                              │
│                                         │
└─────────────────────────────────────────┘

Instructions

Step 1: Understand Requirements

Before writing any code:

  1. Clarify the expected behavior with the user
  2. Identify edge cases and error conditions
  3. Break down into small, testable units

Step 2: Write the First Failing Test

// Start with the simplest case
describe('calculateTotal', () => {
  it('should return 0 for empty cart', () => {
    const result = calculateTotal([]);
    expect(result).toBe(0);
  });
});

Run the test - it should fail (RED).

Step 3: Write Minimal Code to Pass

function calculateTotal(items: CartItem[]): number {
  return 0; // Simplest implementation that passes
}

Run the test - it should pass (GREEN).

Step 4: Add Next Test Case

it('should sum item prices', () => {
  const items = [{ price: 10 }, { price: 20 }];
  expect(calculateTotal(items)).toBe(30);
});

This test fails, so update implementation.

Step 5: Iterate

Continue the cycle:

  • Add test for edge case → implement
  • Add test for error handling → implement
  • Add test for complex scenario → implement

Step 6: Refactor

Once all tests pass, refactor:

  • Extract helper functions
  • Improve naming
  • Reduce duplication
  • Optimize if needed

Critical: Run tests after each change to ensure they still pass.

Test Quality Checklist

  • Tests are independent (no shared mutable state)
  • Test names describe the behavior being tested
  • Each test verifies one specific behavior
  • Edge cases are covered (empty, null, boundary values)
  • Error conditions are tested
  • Tests run fast (mock external dependencies)

Common Test Patterns

Arrange-Act-Assert

it('should apply discount to total', () => {
  // Arrange
  const items = [{ price: 100 }];
  const discount = 0.1;

  // Act
  const result = calculateTotal(items, discount);

  // Assert
  expect(result).toBe(90);
});

Testing Errors

it('should throw on negative price', () => {
  const items = [{ price: -10 }];
  expect(() => calculateTotal(items)).toThrow('Price cannot be negative');
});

Testing Async Code

it('should fetch user data', async () => {
  const user = await fetchUser(123);
  expect(user.name).toBe('John');
});

Examples

Bug Fix with TDD

  1. Write a test that reproduces the bug
  2. Verify test fails
  3. Fix the bug
  4. Verify test passes
  5. Ensure no other tests broke

New Feature with TDD

  1. List all behaviors the feature needs
  2. Write test for simplest behavior
  3. Implement
  4. Write test for next behavior
  5. Implement
  6. Continue until feature complete

Anti-Patterns to Avoid

  • ❌ Writing implementation before tests
  • ❌ Writing all tests at once before any implementation
  • ❌ Tests that test implementation details, not behavior
  • ❌ Skipping the refactor step
  • ❌ Tests that depend on execution order

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.