TD

Mandates Red-Green-Refactor cycle for new features and bug fixes.

Install

mkdir -p .claude/skills/tdd-workflow-dreamlab2025 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14539" && unzip -o skill.zip -d .claude/skills/tdd-workflow-dreamlab2025 && rm skill.zip

Installs to .claude/skills/tdd-workflow-dreamlab2025

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Use this skill when writing new features, fixing bugs, or refactoring code in Verendar. Enforces test-driven development with 80%+ coverage using xUnit, FluentAssertions, NSubstitute, and Testcontainers. Activate proactively whenever the user is about to write new application code, fix a bug, or add an endpoint — tests must come first.
337 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Define behavior with user stories
  • Write failing tests (RED phase)
  • Implement minimal code to pass tests (GREEN phase)
  • Verify code coverage
  • Set up unit and integration tests

How it works

The skill enforces a Test-Driven Development cycle (RED → GREEN → REFACTOR) by guiding the user to define behavior, write failing tests, implement minimal code, refactor, and verify code coverage.

Inputs & outputs

You give it
A new feature, bug fix, or refactoring task in Verendar
You get back
Implemented code with passing tests and verified code coverage

When to use tdd-workflow

  • Writing new application features
  • Fixing bugs via TDD
  • Adding new API endpoints

About this skill

TDD Workflow — .NET / Verendar

The Cycle

RED → GREEN → REFACTOR — always in that order. Never write implementation before a failing test exists.


Step 1: Define the Behaviour (User Story)

As a [role], I want to [action], so that [benefit].

Example:
As a user, I want to cancel a booking,
so that I can get a refund if my plans change.

Step 2: Write Failing Tests (RED)

// Verendar.Garage.Tests/Services/BookingServiceTests.cs
[Fact]
public async Task CancelAsync_PendingBooking_PublishesCancelledEvent()
{
    // Arrange
    var booking = BookingFaker.Pending();
    _bookingRepo.FindByIdAsync(booking.Id).Returns(booking);

    // Act
    var result = await _sut.CancelAsync(booking.Id, booking.UserId, CancellationToken.None);

    // Assert
    result.IsSuccess.Should().BeTrue();
    await _publishEndpoint.Received(1)
        .Publish(Arg.Any<BookingCancelledEvent>(), Arg.Any<CancellationToken>());
}

[Fact]
public async Task CancelAsync_AlreadyCancelled_ReturnsFailure()
{
    var booking = BookingFaker.Cancelled();
    _bookingRepo.FindByIdAsync(booking.Id).Returns(booking);

    var result = await _sut.CancelAsync(booking.Id, booking.UserId, CancellationToken.None);

    result.IsSuccess.Should().BeFalse();
}

Run: task test PROJECT=Garage/Verendar.Garage.Tests → tests must fail.


Step 3: Implement Minimally (GREEN)

Write the least code needed to make the tests pass. No extras.


Step 4: Refactor

Clean up while keeping all tests green. Only after GREEN.


Step 5: Verify Coverage

task test:all
dotnet test --collect:"XPlat Code Coverage"

Minimum 80% overall. 100% for payment and auth logic.


Test Types

TypeToolPurpose
UnitxUnit + FluentAssertions + NSubstituteService logic, domain rules, pure functions
IntegrationWebApplicationFactory + TestcontainersAPI endpoints against real PostgreSQL
ConsumerMassTransit TestHarnessEvent consumers in isolation

Unit Test Setup

public class BookingServiceTests
{
    private readonly IUnitOfWork _uow = Substitute.For<IUnitOfWork>();
    private readonly IPublishEndpoint _pub = Substitute.For<IPublishEndpoint>();
    private readonly BookingService _sut;

    public BookingServiceTests()
    {
        _uow.Bookings.Returns(Substitute.For<IBookingRepository>());
        _sut = new BookingService(_uow, _pub, NullLogger<BookingService>.Instance);
    }
}

Integration Test Setup

public class BookingApiTests(GarageWebFactory factory) : IClassFixture<GarageWebFactory>
{
    private readonly HttpClient _client = factory.CreateClient();

    [Fact]
    public async Task POST_Cancel_Returns200()
    {
        _client.DefaultRequestHeaders.Authorization =
            new AuthenticationHeaderValue("Bearer", factory.GenerateUserToken(Guid.NewGuid()));

        var response = await _client.PostAsync($"/api/bookings/{bookingId}/cancel", null);

        response.StatusCode.Should().Be(HttpStatusCode.OK);
    }
}

See references/dotnet-patterns.md for the full GarageWebFactory with Testcontainers setup.


Anti-Patterns

WrongRight
Write implementation firstTests first — always RED before GREEN
In-memory DB in integration testsTestcontainers (real PostgreSQL)
MoqNSubstitute
Test internal stateTest observable behaviour (return values, published events)
Tests that depend on each otherEach test sets up its own data

Run Commands

task test:all                                         # all tests
task test PROJECT=Garage/Verendar.Garage.Tests        # single project
dotnet test --filter "FullyQualifiedName~CancelAsync" # single test

When not to use it

  • When writing implementation code before a failing test exists
  • When using in-memory databases for integration tests
  • When testing internal state instead of observable behavior

Limitations

  • Requires 80%+ overall code coverage
  • Requires specific testing tools like xUnit, FluentAssertions, NSubstitute, Testcontainers
  • Does not permit writing implementation before a failing test exists

How it compares

This skill mandates a test-first approach and specific testing tools, ensuring code quality and adherence to TDD principles, unlike writing implementation code directly.

Compared to similar skills

tdd-workflow side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
tdd-workflow (this skill)04moReviewIntermediate
csharp-pro94moNo flagsIntermediate
csharp-developer432moNo flagsAdvanced
performance-benchmark34moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

csharp-pro

sickn33

Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.

953

csharp-developer

zenobi-us

Expert C# developer specializing in modern .NET development, ASP.NET Core, and cloud-native applications. Masters C# 12 features, Blazor, and cross-platform development with emphasis on performance and clean architecture.

43151

performance-benchmark

dotnet

Generate and run ad hoc performance benchmarks to validate code changes. Use this when asked to benchmark, profile, or validate the performance impact of a code change in dotnet/runtime.

328

backend-testing

exceptionless

Backend testing with xUnit, Foundatio.Xunit, integration tests with AppWebHostFactory, FluentClient, ProxyTimeProvider for time manipulation, and test data builders. Keywords: xUnit, Fact, Theory, integration tests, AppWebHostFactory, FluentClient, ProxyTimeProvider, TimeProvider, Foundatio.Xunit, TestWithLoggingBase, test data builders

316

update-roslyn-version

dotnet

Guide for updating the Roslyn language server version in the vscode-csharp repository. Use this when asked to update Roslyn, bump the Roslyn version, or upgrade the language server version.

211

orchardcore-module-creator

OrchardCMS

Creates new OrchardCore modules with proper structure, manifest, startup, and patterns. Use when the user needs to create a new module, add content parts, fields, drivers, handlers, or admin functionality.

13

Search skills

Search the agent skills registry