tdd-workflow
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.zipInstalls 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.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
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
| Type | Tool | Purpose |
|---|---|---|
| Unit | xUnit + FluentAssertions + NSubstitute | Service logic, domain rules, pure functions |
| Integration | WebApplicationFactory + Testcontainers | API endpoints against real PostgreSQL |
| Consumer | MassTransit TestHarness | Event 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
| Wrong | Right |
|---|---|
| Write implementation first | Tests first — always RED before GREEN |
| In-memory DB in integration tests | Testcontainers (real PostgreSQL) |
| Moq | NSubstitute |
| Test internal state | Test observable behaviour (return values, published events) |
| Tests that depend on each other | Each 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.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| tdd-workflow (this skill) | 0 | 4mo | Review | Intermediate |
| csharp-pro | 9 | 4mo | No flags | Intermediate |
| csharp-developer | 43 | 2mo | No flags | Advanced |
| performance-benchmark | 3 | 4mo | No flags | Intermediate |
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.
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.
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.
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
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.
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.