$npx -y skills add managedcode/dotnet-skills --skill code-reviewReview .NET changes for bugs, regressions, architectural drift, missing tests, incorrect async or disposal behavior, and platform-specific pitfalls before you approve or merge them. USE FOR: reviewing a pull request or patch in a .NET repository; checking for behavioral regressio
| 1 | # .NET Code Review |
| 2 | |
| 3 | ## Trigger On |
| 4 | |
| 5 | - reviewing a pull request or patch in a .NET repository |
| 6 | - checking for behavioral regressions, API misuse, or missing tests |
| 7 | - auditing architectural or framework-specific correctness |
| 8 | |
| 9 | ## References |
| 10 | |
| 11 | - [checklist.md](references/checklist.md) - comprehensive code review checklist organized by risk priority |
| 12 | - [patterns.md](references/patterns.md) - common patterns and anti-patterns for async, disposal, and security |
| 13 | |
| 14 | ## Workflow |
| 15 | |
| 16 | 1. Prioritize correctness, data loss, concurrency, security, lifecycle, and platform-compatibility issues before style concerns. Use the [checklist](references/checklist.md) P0-P2 categories first. |
| 17 | 2. Check async flows, cancellation propagation, exception handling, disposal, and transient versus singleton lifetime mistakes. Refer to [patterns.md](references/patterns.md) for common pitfalls. |
| 18 | 3. Verify tests cover the changed behavior, not only the happy path or refactored implementation details. |
| 19 | 4. Inspect framework-specific boundaries such as EF query translation, ASP.NET middleware order, Blazor render state, or MAUI UI-thread access. |
| 20 | 5. Call out missing observability, migration risk, or runtime configuration drift when those are part of the change. |
| 21 | 6. Keep findings concrete, reproducible, and tied to specific files or behavior. |
| 22 | |
| 23 | ## Key Review Patterns |
| 24 | |
| 25 | ### Async Code |
| 26 | - Async must propagate through the entire call chain; never use `.Result`, `.Wait()`, or `.GetAwaiter().GetResult()` in async contexts |
| 27 | - Always propagate `CancellationToken` parameters |
| 28 | - Use `ConfigureAwait(false)` in library code |
| 29 | - Never use `async void` except for event handlers |
| 30 | |
| 31 | ### Resource Disposal |
| 32 | - Use `using` declarations or statements for all `IDisposable` resources |
| 33 | - Use `await using` for `IAsyncDisposable` resources |
| 34 | - Use `IHttpClientFactory` instead of creating `HttpClient` directly |
| 35 | - Unsubscribe event handlers to prevent memory leaks |
| 36 | - Validate DI service lifetimes to prevent captured dependencies |
| 37 | |
| 38 | ### Security |
| 39 | - Use parameterized queries or EF to prevent SQL injection |
| 40 | - Validate all user input at system boundaries |
| 41 | - Prevent path traversal by validating resolved paths stay within allowed directories |
| 42 | - Never hardcode secrets; use configuration and secret management |
| 43 | - Enforce authorization checks before accessing protected resources |
| 44 | |
| 45 | ## Deliver |
| 46 | |
| 47 | - ranked review findings with file references |
| 48 | - clear residual risks and test gaps |
| 49 | - brief summary of what changed only after findings |
| 50 | |
| 51 | ## Validate |
| 52 | |
| 53 | - findings describe user-visible or maintainability-impacting risk |
| 54 | - assumptions are stated when repo context is incomplete |
| 55 | - no trivial style nit hides a more serious issue |