mailwal

AI is better at these .NET tasks than you

David - Round The Code

New to Minimal APIs? Build a full project with .NET 10, EF Core and SQL Server in my beginners course. Start learning

.NET tasks AI is better at than developers

Creating projects, writing unit tests, adding comments and debugging exceptions. With the right prompts, AI is better than .NET developers at all of it.

To put that to the test, I used Claude Code with an ASP.NET Core Web API. For each task, I gave it a markdown spec file that told it exactly what I wanted.

Creating a .NET project

If you're still creating your .NET projects by hand, you're wasting your time.

I added a spec file called 01-create-project.md to an empty folder. It covers details about the projects, such as:

.NET 10
C# 14
A clean architecture solution
NuGet packages to install

Then I gave Claude Code this prompt:

/plan Read 01-create-project.md and plan how you are going to build it

Adding /plan puts Claude Code into plan mode. Rather than making changes straight away, it reads the spec file and comes up with a plan:

What it's going to build
The steps it will follow
The files it will create
How it will check the result

Once I was happy with the plan, I got it to execute it.

Claude Code created the project in less than five minutes. It would have taken me at least an hour by hand. Running the application loads the Swagger documentation, along with the endpoint I asked for.

To be fair, the spec file took a couple of hours to write, going back and forth with Claude to perfect it. But I only have to write it once. The next time I need a new project, I can reuse it.

I think this is the direction the .NET developer role is heading over the next couple of years. A lot less coding, and more architectural decisions. If you're not using AI for tasks like this, you're going to fall behind other developers.

Writing unit tests

I used the same approach for unit tests, with a spec file called 02-create-unit-tests.md. It asks for:

xUnit v3 test projects
Moq for mocking
Entity Framework Core in memory provider for testing the repositories

Claude Code created the test projects in just over five minutes. There's a separate test project for each project from the first step, and it set up an in memory DbContext so the Entity Framework Core queries can be tested.

When I ran the tests, they all passed. That wasn't luck. The spec file told Claude Code to run dotnet test and confirm every test passes.

Writing thorough unit tests by hand takes a long time. AI speeds that up, and it can help you plan your tests too, as it will find things you didn't think to test. Some developers don't write unit tests at all, either because they find them too complicated or they simply can't be bothered. With AI, there's no excuse.

Adding comments

The first spec file told Claude Code not to add any comments, so the project didn't have any. I used a third spec file, 03-add-comments.md, to add XML documentation comments to the Api, Application and Infrastructure projects.

Once it had finished, the classes, constructors, properties and methods all had comments. AI can write really long comments, but these are short because the spec file set a 60 character limit.

When developers do write comments, they often have spelling mistakes or grammatical errors. Parameter comments can also refer to parameters that no longer exist, or have since been renamed. AI is good at spelling and grammar, and at keeping parameter comments up to date. So there's really no excuse not to comment your code.

The fourth task was debugging. When I ran the endpoint, I got a 500 error with a SQL Server exception. In the full article, I cover what caused it, how long Claude Code took to find it and the mistake I made that slowed it down. I also share what I think this means for .NET developers and their jobs.

I also go through it in this week's video, where I use Claude Code to create a .NET project, write unit tests, add comments and debug a SQL Server exception.

You can watch it below:

Thanks for reading,

David Grace

Want to reach .NET and C# developers? Sponsor this newsletter

Follow me

Website YouTube LinkedIn

If you wish to unsubscribe from our newsletter, click here