Other

Claude Code hooks for .NET: make it build and run your tests

Round The Code (David Grace) David Grace
Other

Claude Code can report a .NET task as finished without ever building the solution or running the tests. A Stop hook whose command builds and tests the solution, exiting with code 2 on failure, blocks the agent until both pass.

Key points

Real-world use

  • An ASP.NET Core minimal API where an agent edits a validator and must prove the whole solution still compiles before stopping
  • Allowing free products by changing a FluentValidation rule, where the existing unit test has to be updated before the agent can finish
  • Preventing an agent from hand-writing EF Core migrations so it runs dotnet ef migrations add instead
  • Formatting every C# file an agent edits with dotnet format through a PostToolUse hook

This summary was generated by the agent from the original post on Round The Code (David Grace). The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message