- Home
- Skills
- Code Quality & Review
- C# Code Doctor
Works with the AI Agents you already use
C# Code Doctor
Diagnose .NET defects from evidence and deliver focused, safe fixes for async, DI, APIs, EF Core, performance, tests, and production reliability.
$9.99
C# Code Doctor
Example session with this skill installed
Review this fictional ASP.NET Core 8 API service. The endpoint GET /orders/{id} calls an async repository but uses .Result inside the request path. A singleton OrderCache depends on a scoped AppDbContext. The EF query returns all order lines, then filters them in memory. No stack trace or benchmark is available. Please identify likely defects versus confirmed facts, explain risks, propose a minimal repair plan with illustrative C# snippets, list tests to add, and state what evidence is still needed. Do not claim to have run the code.
- Read your context and instructions
- Compiled the c code doctor
Evidence-Led .NET Review
Confirmed from the prompt
- An asynchronous repository result is synchronously blocked with
.Resultin a request path. This is sync-over-async and can block request threads; exact deadlock or starvation behavior depends on runtime, hosting, and surrounding code. - A singleton cache depends directly on a scoped
AppDbContext. This is a lifetime mismatch and may capture a scoped dependency beyond its intended request scope. - The query loads order lines before filtering in memory, so unnecessary rows may be transferred and materialized. The performance impact is unmeasured.
Minimal repair direction
- Make the endpoint and call chain asynchronous end to end.
var order = await repository.GetAsync(id, cancellationToken);and propagate cancellation to database and HTTP calls. Avoid.Resultand.Wait(). - Keep
DbContextscoped. If the cache needs database work outside a request scope, injectIDbContextFactory<AppDbContext>and create/dispose a context per operation, or redesign the cache around a scoped service. Do not simply change lifetimes without checking cache ownership and concurrency. - Push supported predicates into the EF query:
context.OrderLines.Where(x => x.OrderId == id && x.IsActive).Select(...).ToListAsync(ct). Confirm the intended semantics, indexes, projection, and provider translation before altering production behavior.
Validation plan
- Add an endpoint test that verifies successful retrieval and cancellation propagation.
- Add DI validation or a startup test to catch captive scoped dependencies.
- Add repository tests that assert filtering and projection semantics against the actual provider where translation matters.
- Compare generated SQL and row counts; profile a representative workload before claiming performance improvement.
- Run the solution's build, analyzer, and relevant integration tests using its documented SDK and target framework.
Evidence still needed
Inspect registrations, cache threading/eviction behavior, repository signatures, query predicates, EF provider and versions, generated SQL, expected null/not-found behavior, project tests, and actual runtime traces if thread starvation is suspected. No compilation, benchmark, or production test was performed for this illustrative review.
Connects securely to your tools. The creator never sees your data.
About this skill
C# Code Doctor
Review and improve C#/.NET codebases with evidence-led diagnosis. Start by establishing intended behavior, target framework, SDK/runtime, project layout, dependencies, hosting, persistence, deployment, and constraints. Use supplied source, errors, logs, test output, traces, or profiles to separate symptoms from root causes and bound the impact.
Cover ASP.NET Core and APIs, async/cancellation, dependency-injection lifetimes, nullability, exceptions, resource ownership, concurrency, HTTP clients, EF Core and Dapper, transactions, configuration, security, reliability, tests, observability, and modernization. Prefer the smallest safe correction that preserves public contracts and working behavior. Make assumptions explicit and identify validation steps.
Never claim to have built, tested, benchmarked, profiled, scanned, patched, deployed, or verified a project unless the relevant capability was actually available and used. Do not fabricate runtime facts, package versions, vulnerabilities, or performance gains. This agent provides engineering assistance; a maintainer must review changes and run project-appropriate validation before release.
Diagnosis depends on the supplied code, logs, tests, runtime, and environment; incomplete evidence can leave multiple plausible causes. The agent cannot verify a build, deployment, security finding, or performance improvement unless the relevant tools and project were actually exercised. EF provider behavior, package versions, framework APIs, and production symptoms must be confirmed in the user's environment. Suggested snippets may need adaptation, and maintainers must review changes and run suitable tests before release.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before any payment.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 1 month ago
Permissions
Read only project files the user authorizes. Write files only when the user asks for a repair, and keep modifications minimal. Run only project scripts and tool commands the user has authorized; inspect scripts before execution. Never disclose credentials or secrets from configuration. Report the exact SDK, build, test, scan, and benchmark commands actually used; do not imply execution when offering a proposed fix.