Design, implement, optimize, and review SIMD code in .NET.
.NET Diagnostics MCP
Use dotnet-diagnostics-mcp for MCP-driven .NET CPU, allocation, GC, and test-host profiling. USE FOR: profiling unit tests or investigating runtime bottlenecks. DO NOT USE FOR: writing test assertions, coverage collection, or precise microbenchmark timing. INVOKES: connect the MCP server, select target processes, collect bounded profiles, and attribute hotspots to source.
Trigger On
- The user asks to install or use
dotnet-diagnostics-mcpfor .NET performance investigation. - The user asks: "Profile all unit tests and identify bottlenecks in the code tested."
- An MCP-connected agent needs runtime evidence for CPU hotspots, allocation pressure, GC pauses, or waiting in a .NET application.
Use this skill for this MCP server's workflow. Use the test framework's guidance for assertions and test authoring, and a benchmark workflow when the question needs precise per-operation timing.
Workflow
- Identify the requested workload, runtime, test runner, and unit-test projects. Build Release binaries with matching PDBs before the measured run. Keep build/restore time separate from test execution.
- For all-unit-test requests, follow test profiling: inventory projects, retain normal test parallelism, start the suite, and discover the actual test host or application process by command line. Record every relevant PID and its capture window.
- Resolve an explicit
processIdwithinspect_process(view="list", commandLineContains=...). Useview="info"to verify its identity. For a long-lived app,view="triage"can choose the next collector; avoid spending a short test host's lifetime on preliminary captures. - Capture CPU and managed allocations together with
collect_batch; optionally add GC and counters, up to four entries. Usedepth="compact"and read the returned digest and per-entry errors before querying handles. - Follow the hot path into the code under test. Separate product methods from runner, fixture, mocking, assertion, JIT, and profiler overhead. Use tool patterns for collector selection and evidence limits.
- Reproduce a suspected hotspot with the runner's native test filter, preserving unrelated parallel execution. Compare equal workload, runtime, configuration, concurrency, and capture duration. Change code only within the user's requested scope, then rerun correctness checks and the same profile.
flowchart LR
A["Release build and unit-test inventory"] --> B["Run tests with normal parallelism"]
B --> C["inspect_process: actual test-host PIDs"]
C --> D["collect_batch: CPU + allocation"]
D --> E["query_snapshot: product hot paths"]
E --> F["Focused reproduction and equal-workload comparison"]
F --> G["Rank bottlenecks and disclose capture gaps"]Deliver
- Record tool/runtime versions, test command, configuration, normal concurrency, projects and test counts, PID identities, capture windows, and test exit status.
- Rank bottlenecks by measured evidence: product method and source location when available, sample share or allocated-byte signal, affected test group, interpretation, and a concrete next change or measurement.
- Report test-harness overhead separately. State missing hosts, missed execution intervals, failed collectors, unresolved symbols, and sampling limits. A passing suite and one captured PID do not prove every test was profiled.
- Preserve useful bounded artifacts or exported traces and their paths. Handles expire and normally belong to the current MCP server session.
Validate
- Confirm the MCP connection and advertised tool schemas; use current tool names and supported argument values.
- Confirm samples came from the test host or app being tested, rather than the build process or SDK wrapper.
- Check each batch entry for errors and verify the measured window overlaps real test execution. An empty profile is inconclusive.
- Attribute EventPipe CPU results as stack-frequency evidence and allocation results as sampling evidence. Validate suspected waiting with counters, contention events, or a supported blocking collector.
- Retain native test progress and ANSI. Show Warning/Error diagnostics plus one concise result; cap each diagnostic response at 80 lines / 8 KiB, preserve the runner exit code, and keep necessary artifacts size-bounded outside model context.
Source: dotnet-diagnostics. Read test profiling for suite coverage and tool patterns for setup, drilldown, settings, and source links.
Related skills
Use the open-source free `Asynkron.Profiler` dotnet tool for CLI-first CPU, allocation, exception, contention, and heap profiling of .NET commands or existing trace artifacts.
Use the open-source CodeQL ecosystem for .NET security analysis.
Building AI agents on .NET?
Managed Code builds production AI agents in C# and .NET.