dotnet-best-practices

Reviews .NET/C# code against solution-specific best practices and coding standards.

2|1|Updated May 11, 2019
One-click install
npx skills add https://github.com/guitarrapc/dotfiles-win --skill dotnet-best-practices-guitarrapc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-best-practices
Source: https://github.com/guitarrapc/dotfiles-win/tree/main/HOME/.agents/skills/dotnet-best-practices
Command: npx skills add https://github.com/guitarrapc/dotfiles-win --skill dotnet-best-practices-guitarrapc

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Ensuring .NET/C# code consistently follows project-specific conventions—naming, async patterns, dependency injection, testing, and performance rules—is hard to enforce manually during code review. This Skill applies a comprehensive, opinionated checklist of best practices to selected code so reviews are consistent and nothing is missed. ## Core Features & Use Cases - Comprehensive Code Review Rules: Covers XML documentation, primary constructors, Command Handler patterns, DI lifetimes, ResourceManager localization, async/await, structured logging, and modern C# 13 syntax. - Testing Standards Enforcement: Validates MSTest/xUnit conventions, FluentAssertions, Moq usage, AAA pattern, and edge-case coverage. - Allocation-Aware Performance Guidance: Flags hot-path allocations, enforces Span/Memory/ArrayPool discipline, stackalloc budgets, and caching of invariant computations. - Use Case: Select a newly written service class and ask for a best-practices review—the Skill checks DI registration, null validation, async correctness, naming conventions, and unit test coverage in one pass. ## Quick Start Review the selected C# file against the .NET best practices and list every violation with suggested fixes.

Frequently Asked Questions about dotnet-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I review C# code against .NET best practices automatically?

Select the C# code and invoke this Skill to check it against rules for dependency injection, async/await, naming conventions, XML documentation, and testing patterns. It reports violations with concrete guidance aligned to the project's established conventions.

What testing frameworks does this .NET review cover?

The Skill enforces MSTest with FluentAssertions and Moq for mocking, plus xUnit conventions for algorithm tests. It checks AAA pattern structure, edge-case coverage, and null parameter validation tests.

Does it check async/await and performance issues in C#?

Yes. It verifies async/await usage for I/O operations, Task return types, and ConfigureAwait, plus hot-path allocation rules covering Span, Memory, ArrayPool, stackalloc budgets, and caching of invariant computations.

Can I use Memory<T> with ArrayPool rented buffers in C#?

No. The Skill flags exposing rented ArrayPool buffers as Memory<T> or storing them in struct fields, since struct copies lose the return obligation and cause pool corruption. Lend a Span<T> from the renting scope instead.

What naming conventions does the Skill enforce for C# code?

It enforces PascalCase for constants, interface names prefixed with 'I', no underscore or s_ prefixes for fields, and preferring var for local variables, following standard .NET coding guidelines.