Claude Code hook that always builds and tests your .NET app
To ensure that Claude Code always builds and run unit tests, you can add a Stop hook to your .NET application. You can find out more about Claude Code hooks in .NET, or watch the video:
Download the code example
You'll need to fill out the code example form. We will send you an email where you can download the code example.
Software
This is the software that will need to be installed onto your machine.
Visual Studio 2026. Version 18.12.0 or above. It will work with the free community version.
.NET 11 SDK. Version 11.0.0 or above.
The application
The hooks have been added to .claude/settings.json. There are three examples:
PreToolUse- Runs just before Claude Code uses a toolPostToolUse- Runs after Claude Code has finished using a toolStop- Runs after Claude Code has finished responding
With Stop, you should see Claude Code building and running the unit tests after it's finished.
Download this code example
Enter your email and we'll send you a download link.
Related code examples
Get the technical documents and Claude project we used to build a real ASP.NET Core app from scratch using AI. Download and use them yourself.
Get the CLAUDE.md file and .NET project we used to migrate Controllers over to Minimal APIs using Claude Code prompts.
Download this code example
Enter your email and we'll send you a download link.