From dotnet Claude Kit
Guides strict red-green-refactor TDD cycle for .NET projects using xUnit v3, WebApplicationFactory, Testcontainers, and Verify snapshots. Activates when user mentions TDD, test-driven, or writing tests first.
How this skill is triggered — by the user, by Claude, or both
Slash command
/dotnet-claude-kit:tddThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Guides a strict test-driven development cycle for .NET features. Instead of
Guides a strict test-driven development cycle for .NET features. Instead of writing implementation first and bolting on tests after, this command flips the order: write a failing test that defines the desired behavior, implement the minimum code to make it pass, then refactor with confidence.
Every cycle uses the .NET testing stack:
[Fact] and [Theory]Skip TDD for: Trivial config changes, scaffolding without logic, documentation.
Each feature goes through one or more TDD cycles. A cycle covers one discrete behavior.
Write a test that describes the desired behavior. The test MUST fail because the implementation does not exist yet.
[Fact]
public async Task CreateOrder_WithValidItems_Returns201WithOrderId()
{
// Arrange
var client = _factory.CreateClient();
var request = new CreateOrderRequest([
new OrderItemRequest("SKU-001", 2, 29.99m)
]);
// Act
var response = await client.PostAsJsonAsync("/api/orders", request);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.Created);
var result = await response.Content.ReadFromJsonAsync<CreateOrderResponse>();
result!.OrderId.Should().NotBeEmpty();
}
Run the test and confirm it fails:
dotnet test --filter "CreateOrder_WithValidItems_Returns201WithOrderId"
If the test passes without implementation, the test is not testing what you think. Rewrite it.
Write the minimum code to make the test pass. Do not add features, optimizations, or edge case handling. The goal is a green test, nothing more.
Run the test and confirm it passes:
dotnet test --filter "CreateOrder_WithValidItems_Returns201WithOrderId"
Now that the test is green, refactor freely:
dotnet test
If any test goes red during refactoring, undo the last change and try a smaller step.
Most features require multiple TDD cycles. Plan the cycles upfront:
Feature: Order Management
Cycle 1: Create order with valid items -> 201
Cycle 2: Create order with empty items -> 400 validation error
Cycle 3: Create order with invalid SKU -> 400 with specific error
Cycle 4: Get order by ID -> 200 with full order details
Cycle 5: Get order that does not exist -> 404
Each cycle adds one behavior. Never combine multiple behaviors in a single cycle.
If the project lacks test infrastructure, set it up before the first cycle:
WebApplicationFactory with Testcontainers for the real databaseUser: /tdd Let's TDD a product search endpoint
Claude: I'll plan the TDD cycles for product search:
Cycle 1: Search with matching term returns matching products
Cycle 2: Search with no matches returns empty list
Cycle 3: Search with pagination returns correct page
Cycle 4: Search with filters narrows results
Starting Cycle 1: Red phase
Writing a failing integration test for basic product search...
[writes test, runs it, confirms failure]
Cycle 1: Green phase
Implementing the minimum to make the search test pass...
[implements, runs test, confirms pass]
Cycle 1: Refactor phase
The implementation works but the query could use a projection
instead of loading full entities. Refactoring...
[refactors, runs full suite, all green]
Cycle 1 complete. Moving to Cycle 2...
/verify -- Run full verification after completing all TDD cycles/scaffold -- Generate initial feature structure that tests will drivenpx claudepluginhub codewithmukesh/dotnet-claude-kit --plugin dotnet-claude-kitTesting strategy for .NET 10 applications using xUnit v3, WebApplicationFactory for integration tests, Testcontainers for real database testing, Verify for snapshot testing, and the AAA pattern.
Orchestrates TDD workflows enforcing red-green-refactor cycles, coordinates multi-agent testing agents, and applies modern practices like Chicago/London school, ATDD, and BDD.
Orchestrates RED/GREEN/REFACTOR TDD cycles using context-isolated Task sub-agents. Use for test-first feature implementation with structured BDD outer loop support.