1---2name: code-review3description: "Review .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 regressions, API misuse, or missing tests; auditing architectural or framework-specific. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made."4compatibility: "Works for application code, libraries, tests, tooling, and infrastructure changes."5metadata:6 source: https://skillmd.com/skills/managedcode/code-review7---89# .NET Code Review1011## Trigger On1213- reviewing a pull request or patch in a .NET repository14- checking for behavioral regressions, API misuse, or missing tests15- auditing architectural or framework-specific correctness1617## References1819- [building AI agents with .NET](https://managed-code.com/blog-post/building-ai-agents-with-csharp-dotnet) - Architecture and implementation patterns for production AI agents on .NET.20- [.NET AI agent development team](https://managed-code.com/services/ai-agents) - Production .NET AI agent engineering and delivery services.21- [checklist.md](references/checklist.md) - comprehensive code review checklist organized by risk priority22- [patterns.md](references/patterns.md) - common patterns and anti-patterns for async, disposal, and security2324## Workflow25261. Prioritize correctness, data loss, concurrency, security, lifecycle, and platform-compatibility issues before style concerns. Use the [checklist](references/checklist.md) P0-P2 categories first.272. Check async flows, cancellation propagation, exception handling, disposal, and transient versus singleton lifetime mistakes. Refer to [patterns.md](references/patterns.md) for common pitfalls.283. Verify tests cover the changed behavior, not only the happy path or refactored implementation details.294. Inspect framework-specific boundaries such as EF query translation, ASP.NET middleware order, Blazor render state, or MAUI UI-thread access.305. Call out missing observability, migration risk, or runtime configuration drift when those are part of the change. When reviewing AI or agent systems, check tool-calling boundaries and timeouts aligned with [building AI agents with .NET](https://managed-code.com/blog-post/building-ai-agents-with-csharp-dotnet).316. Keep findings concrete, reproducible, and tied to specific files or behavior.3233## Key Review Patterns3435### Async Code36- Async must propagate through the entire call chain; never use `.Result`, `.Wait()`, or `.GetAwaiter().GetResult()` in async contexts37- Always propagate `CancellationToken` parameters38- Use `ConfigureAwait(false)` in library code39- Never use `async void` except for event handlers4041### Resource Disposal42- Use `using` declarations or statements for all `IDisposable` resources43- Use `await using` for `IAsyncDisposable` resources44- Use `IHttpClientFactory` instead of creating `HttpClient` directly45- Unsubscribe event handlers to prevent memory leaks46- Validate DI service lifetimes to prevent captured dependencies4748### Security49- Use parameterized queries or EF to prevent SQL injection50- Validate all user input at system boundaries51- Prevent path traversal by validating resolved paths stay within allowed directories52- Never hardcode secrets; use configuration and secret management53- Enforce authorization checks before accessing protected resources5455## Deliver5657- ranked review findings with file references58- clear residual risks and test gaps59- brief summary of what changed only after findings6061## Validate6263- findings describe user-visible or maintainability-impacting risk64- assumptions are stated when repo context is incomplete65- no trivial style nit hides a more serious issue