Guide · Agent skill
How to use the C# testing patterns agent skill (csharp-testing)
Updated · written with AI from the project's own documentation and checked against our catalogue data
The csharp-testing skill is a reference guide that an AI agent reads before writing automated tests for C# and .NET code. It covers xUnit tests, FluentAssertions, mocking with NSubstitute or Moq, ASP.NET Core API tests with WebApplicationFactory, and database tests with Testcontainers. After reading this guide you will know how to install the skill, ask for test work in plain language, and check the agent's output against the patterns it follows.
Quick start
- 1Download the skill. Download the csharp-testing ZIP from this page and unzip it. You should see a folder containing SKILL.md.
- 2Choose a location. Copy the folder into ~/.claude/skills/ for all projects, or into your project's .claude/skills/ folder for one project.
- 3Or upload it in the Claude apps. In the Claude apps, open Settings, go to Capabilities, then Skills, and upload the skill.
- 4Prepare your test project. Make sure you have a .NET SDK and an xUnit test project, and Docker if you plan to use Testcontainers.
- 5Ask in plain language. Describe the test you want, naming the class or method and your mocking library, for example NSubstitute.
- 6Review the generated code. Read the tests the agent writes, checking that they assert behaviour and results rather than implementation details.
- 7Run the tests yourself. Run dotnet test to execute the tests, since the skill does not run them for you.
What the skill makes the agent do
A skill is a folder containing a SKILL.md file that gives an agent extra instructions for a specific kind of task. This one holds C# and .NET testing patterns. When it applies, the agent follows the documented structure: Arrange-Act-Assert unit tests, parameterised tests with Theory and InlineData or MemberData, mocks created with NSubstitute, API tests built on WebApplicationFactory, and database tests that start a real container with Testcontainers.
The skill also suggests a folder layout for test projects, with separate unit, integration and test-helper projects, and it lists common anti-patterns with their fixes. It is guidance only. It does not run tests or check that code is correct; you still run dotnet test yourself.
Install the csharp-testing skill
Download the ZIP for this skill from our page and unzip it. The skill folder contains SKILL.md. Put that folder in one of these locations:
- For all your projects: ~/.claude/skills/
- For one project only: the project's .claude/skills/ folder
- Or in the Claude apps: open Settings, go to Capabilities, then Skills, and upload the skill there
Trigger the skill with a natural request
You do not need a special command. Describe the testing task in plain words that mention C# or .NET, such as the examples below. The skill's trigger list covers writing new tests, reviewing test quality and coverage, setting up test infrastructure, and debugging flaky or slow tests.
- Write xUnit tests for my OrderService.PlaceOrderAsync method, using NSubstitute for the repository.
- Add a Theory with email cases to test my EmailValidator.
- Review these tests for flaky patterns and slow setup.
- Set up an integration test project for my ASP.NET Core API with WebApplicationFactory.
Examples of what the agent produces
For a service method, the skill shows a test class with a constructor that builds fresh mocks, and tests named in the form Method_ExpectedResult_WhenCondition. For validation logic, it shows a [Theory] with [InlineData] rows so one test covers many inputs. For an API, it shows a WebApplicationFactory setup that swaps the database for an in-memory one and checks a 404 and a 201 response.
The Testcontainers example starts a PostgreSQL container with the image postgres:16-alpine and runs migrations before the tests. The skill also includes an OrderBuilder class for building test data in a readable way.
[Theory]
[InlineData("", false)]
[InlineData("user@example.com", true)]
public void IsValidEmail_ReturnsExpected(string email, bool expected)
{
EmailValidator.IsValid(email).Should().Be(expected);
}What you need before you start
The examples assume a .NET SDK and an xUnit test project. The code uses packages including xUnit, FluentAssertions, NSubstitute or Moq, Testcontainers, Microsoft.AspNetCore.Mvc.Testing and Bogus. Docker is needed to run the Testcontainers examples. The skill does not run scripts and does not use the network.
Run the tests with the standard commands from the skill:
- dotnet test runs all tests
- dotnet test --collect:"XPlat Code Coverage" runs tests with coverage
- dotnet test --filter "FullyQualifiedName~OrderService" filters by test name
- dotnet watch test --project tests/MyApp.UnitTests/ reruns tests while you develop
dotnet testSafety notes
The skill itself contains no scripts and makes no network calls, so installing it does not run code on your machine. The code it suggests does run when you execute it, and the Testcontainers examples start Docker containers. Read generated code before running it, especially code that connects to a database, and check that test databases are not pointing at real data.
Tips for better results
Name the project, class and method you want tested, and say which mocking library you use. The skill allows either NSubstitute or Moq, so stating your choice avoids mixed styles. If your project already has its own testing conventions, tell the agent to follow them, because the skill's patterns may differ from your team's style.
- Ask for one behaviour per test rather than one large assertion block
- Ask the agent to always pass CancellationToken through, as the anti-patterns table recommends
- For flaky tests, ask the agent to replace Thread.Sleep with timeouts or polling helpers
What people use it for
- Writing Arrange-Act-Assert xUnit tests for an order service with mocked repositories
- Converting several similar checks into one parameterised Theory with InlineData or MemberData
- Testing an ASP.NET Core API endpoint with WebApplicationFactory, including 404 and 201 responses
- Running repository tests against a real PostgreSQL container with Testcontainers
- Organising a new solution into unit, integration and test-helper projects
Frequently asked questions
How do I install the csharp-testing skill?
Download the ZIP from this page and unzip it. Place the folder in ~/.claude/skills/ for all projects, or in a project's .claude/skills/ folder. You can also upload it in the Claude apps under Settings, then Capabilities, then Skills.
Do I need Docker to use this skill?
Docker is needed only to run the Testcontainers examples, which start a real database container. Unit tests with mocks and the WebApplicationFactory examples do not require it according to the examples in the skill.
Is the csharp-testing skill free?
The skill is published under the MIT licence. The source material does not mention pricing, so check this page for any current licence details.
Does the skill run my tests or check they are correct?
No. The skill only provides guidance and example code. You run the tests yourself with dotnet test, and the skill does not verify correctness.
Can I use this skill with Python or JavaScript?
No. The patterns are specific to C# and .NET, so use a skill written for your language for Python or JavaScript projects.
Should I use NSubstitute or Moq with this skill?
The skill lists either NSubstitute or Moq for mocking. Tell the agent which one your project uses so it keeps to a single style.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use this skill if you write C# and .NET tests and want consistent, readable xUnit code, or if you are setting up test projects for an ASP.NET Core application. Pick something else if your project is not in C#, or if you need a tool that runs tests or verifies correctness, since this skill only supplies guidance and examples.
Download the skill