# .NET Best Practice Checker

> Checks a .NET codebase against 30 named best-practice rules and writes a severity-ranked report with file:line evidence and a fix for each finding. Read-only. Use when you want a pre-review sweep of a C# solution. Do not use for architecture or layering review.

.NET Best Practice Checker is a free AI agent skill on Agensi by Nick Zdanovych, in Code Quality & Review. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Nick Zdanovych](https://www.agensi.io/creators/nick-zdanovych)
- Category: [Code Quality & Review](https://www.agensi.io/skills/code-quality-review)
- Uses: 4
- Version: 1.1
- Last updated: 2026-10-28
- Security: scan passed (2026-10-17); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/net-best-practice-checker
- Tags: code-review, dotnet, csharp, aspnet-core, ef-core, best-practices, async, nuget

## About this skill

Checks a .NET codebase against 30 concrete best-practice rules and writes a severity-ranked report. Each finding names the rule, the file and line, the offending code, one sentence on why it matters here, and a fix. The skill reads your code and changes nothing.

Use when you want a pre-review sweep of a C# solution, a "what would a reviewer flag" pass, or a first look at an inherited codebase.

Do not use for layering or architecture review, performance profiling, new feature work, single-snippet questions, or non-.NET code.

The 30 rules cover async and cancellation, exception handling, logging, HttpClient and certificate validation, time and disposal, dependency injection, secrets in config, EF Core queries and raw SQL, performance hygiene, target framework support, package versions and vulnerabilities, and test smells. Every rule has a search pattern, a way to confirm the hit in context, a fix, and a list of cases that are not findings, so an `async void` event handler or a `.Result` after `Task.WhenAll` is dropped instead of reported. The report ends with the hits it dropped and the rules it could not check.

Two optional steps run `dotnet` and the skill asks before either: an analyzer pass (`dotnet build` with `AnalysisMode=All`, filtered to the analyzer IDs the rules name) and a NuGet vulnerability check (`dotnet list package --vulnerable`). Without them the skill uses only the Read and Grep tools.

### Features

- 30 named rules in 8 groups, each with severity, confirm step, fix and a "not a finding" list.
- Report ordered by severity with a summary table, checked-and-clean rules, rules not checked, and hits dropped.
- Evidence is `path:line` plus the code. Secret values are never printed; findings show the key name and `***`.
- Findings that depend on something the scan cannot see are marked Likely, with what would settle them.
- Optional analyzer pass and NuGet advisory check, each only after you agree.
- A real sample report from a synthetic solution is included (`examples/sample-report.md`).
- Free, MIT licensed.

### Who it is for

.NET developers and reviewers who use an AI coding agent and want a repeatable pre-review check of an ASP.NET Core, EF Core or class-library solution.

### Requirements

- An agent that reads skill folders and gives the model file read and search tools (tested only in Claude Code 2.1.301).
- The .NET SDK, only for the two optional steps.
- No API keys, accounts or environment variables.

### Supported environments

| Environment | Status |
|---|---|
| Claude Code 2.1.301 on Windows, Sonnet model | Tested on one synthetic solution (see `docs/VALIDATION.md`) |
| Other Claude models | Untested |
| Cursor, GitHub Copilot, Codex CLI, Gemini CLI | Untested |
| Linux, macOS | Untested |

### Limitations

- It is a text-based scan. It does not resolve types, DI lifetimes or runtime configuration, so some findings are marked Likely.
- The rules are one author's judgment of common review findings, not Microsoft guidance, and not a complete security audit.
- Tuned and tested on one synthetic solution that I wrote. The false-positive rate on real projects is unknown.
- .NET support dates were read from Microsoft's support policy page on 2026-10-17. Check the page before relying on them later.
- Large solutions: matches beyond 25 per rule are counted but not all reviewed, and the report says so.

### Network and external references (disclosure)

- The scan makes no network calls and sends no repository content anywhere.
- The optional `dotnet list package --vulnerable` step queries the NuGet feeds in your repo's configuration. The optional `dotnet build` restores packages from the same feeds and writes `bin/` and `obj/`.
- The skill asks before running either step.
- The package contains Markdown only: no scripts and no binaries.

### Use cases

- Sweep a pull-request branch or a whole solution before human review.
- Take a first look at an inherited .NET codebase and see what to fix first.
- Find blocking calls, swallowed exceptions, disabled certificate validation, committed secrets and SQL built by string concatenation.
- Check target frameworks and NuGet packages against support dates and known advisories.

## Requires

- Optional: .NET SDK

The .NET SDK is only for the optional analyzer pass and NuGet vulnerability check.

## Known limitations

- It is a text-based scan. It does not resolve types, DI lifetimes or runtime configuration, so some findings are marked Likely.
- The rules are one author's judgment of common review findings, not Microsoft guidance, and not a complete security audit.
- Tuned and tested on one synthetic solution that I wrote. The false-positive rate on real projects is unknown.
- .NET support dates were read from Microsoft's support policy page on 2026-10-17. Check the page before relying on them later.
- Large solutions: matches beyond 25 per rule are counted but not all reviewed, and the report says so.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the .NET Best Practice Checker skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### Does it change my code?

No. It edits nothing until you read the report and ask for fixes, which it applies one rule at a time with a build and test run.

### Does it send my code anywhere?

The skill sends nothing. The model in your agent reads the files as it would for any request.

### Is it a replacement for Roslyn analyzers?

No. It is a text scan with human-readable reasons. The optional analyzer pass adds compiler evidence for some rules, and the report says which rules the analyzers cannot see.

### How accurate is it?

In its latest run on one synthetic solution it reported all 48 planted problems and none of 22 look-alikes; an earlier run missed one. That solution was written by the skill's author and used to tune the skill, so treat it as a smoke test, not an accuracy figure.

### Why does the report say "Likely" for some findings?

The scan cannot see callers, environment variables or DI lifetimes. A Likely finding says what would settle it.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
