/dotnet-diagnostics:dotnet-diagnosticsfrom dotnet-diagnostics
Collects runtime evidence from running or crashed .NET processes (dotnet-counters, dotnet-trace, dotnet-dump, dotnet-monitor, PerfView, perfcollect, container and Kubernetes dumps, mobile crash symbolication) and sets the measurement rules for performance work: BenchmarkDotNet, hot-path gate, SIMD. Use for high CPU, memory growth, hangs, crashes in production, capturing a dump, slow C# code, or writing and comparing benchmarks.
Ships in dotnet-diagnostics. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Not for general diagnosis method (problem-solving), metrics, dashboards and alerting (observability-instrumentation), C# fixes once the cause is known (csharp), build failures and slow builds (msbuild), EF Core query tuning (ef-core), or cluster and image changes beyond diagnostics (kubernetes, docker).
This skill picks the right collection tool for the environment, gives exact commands, and hands the artifact to the right analysis tool. Collect first, then reason from what the trace, dump or counters show. For code that is merely slow, it also holds the rule that nothing is optimised without a measurement, and the BenchmarkDotNet rules (see Performance work).
DOTNET_DbgEnableMiniDump or other env vars on a deployment (that restarts pods), installing tools into a running container, adding capabilities or privileged sidecars, kubectl debug, editing core_pattern or the Windows WER registry. Show the command and what it changes, then wait.curl or wget into a shell. Save the file, check it (file shows an ELF or PE executable, not an HTML error page; read a script such as perfcollect before running it as root), then chmod +x and run it.-p <PID> command (dotnet-trace ps, dotnet-dump ps, ps in the container), even when the app is expected to be PID 1.TMPDIR; otherwise the dotnet-* tools time out connecting to the diagnostic port.dotnet-trace collect-linux); CoreCLR or NativeAOT.dotnet-counters monitor -p <PID> --counters System.Runtime shows CPU, GC heap, allocation rate, thread pool queue length and lock contention in one view. Read references/dotnet-counters.md for install and counter names.| Environment | Preferred | Fallback | Reference |
|---|---|---|---|
| Windows, modern .NET, admin | PerfView | dotnet-trace without admin | references/perfview.md |
| Windows, .NET Framework | PerfView (needs admin) | Without admin: dumps only (procdump -ma, Task Manager); no trace option exists | references/perfview.md |
| Windows containers | PerfView on the host with /EnableEventsInContainers | dotnet-trace inside the image | references/perfview.md |
| Linux, .NET 10+, root, kernel 6.4+ | dotnet-trace collect-linux (native and kernel stacks) | dotnet-trace collect | references/dotnet-trace.md |
| Linux, before .NET 10 | dotnet-trace collect | perfcollect (root) when native stacks are needed | references/dotnet-trace.md, references/perfcollect.md |
| Container or k8s, console access | dotnet-trace / dotnet-dump inside the container | perfcollect in a privileged sidecar | references/dotnet-trace.md |
| Container or k8s, no console | dotnet-monitor sidecar | references/dotnet-monitor.md |
Trade-offs to state when recommending: PerfView gives the richest data but needs admin and Windows; dotnet-trace collect is cross-platform and needs no admin but shows managed frames only; perfcollect and collect-linux add native stacks but need root; dotnet-monitor needs no tools in the app image but needs a sidecar and auth setup.
Dumps answer "what is on the heap" (leaks, two dumps diffed) and "what is each thread waiting on" (deadlocks). They do not show GC behavior or where CPU time goes; take a trace for those.
strings "$(readlink /proc/<pid>/exe)" | grep -q CorExeMain && echo CoreCLR || echo "NativeAOT or native". A process that loads clr.dll on Windows is .NET Framework: use procdump -ma <pid> or Task Manager's "Create memory dump file".DOTNET_DbgEnableMiniDump, on-demand dotnet-dump collect): references/dumps.mdcreatedump, gcore, lldb, WER): references/dumps-nativeaot.mdSYS_PTRACE, volumes, pod specs), read with one of the above: references/dumps-containers.mdAn Android tombstone or an Apple .ips crash log with frames in libcoreclr, libmonosgen-2.0 or libSystem.*: symbolicate the .NET runtime frames with symbols from the Microsoft symbol server, following references/mobile-symbolication.md. Pure Java, Kotlin, Swift or Objective-C crashes are out of scope.
Measure first, change one thing, measure again the same way. A speedup counts only when a like-for-like BenchmarkDotNet comparison or a before/after profile shows it. Check the TFM and SDK (dotnet --version, <TargetFramework>) before suggesting an API: many fixes need .NET 7, 8 or 9.
Gate: is this a hot path? Before rewriting code for speed, establish one of:
EventPipeProfiler),Without any of these, say the change matters only if profiling shows the code is hot; never trade readability for a micro-optimization in code that runs rarely, and report only critical findings (deadlock, crash, unbounded regex, a regression over 10x). If the profile shows low CPU but high latency, the time is outside the code (database, network, locks, thread-pool starvation): collect counters and a trace with the workflow above instead of tuning allocations.
Benchmarks. Read references/benchmarkdotnet.md before writing or running one, and references/benchmarkdotnet-config.md for diagnosers, exporters, job presets or unstable results. Core rules:
[Benchmark(Baseline = true)] or a job's .AsBaseline()) so the table shows Ratio.dotnet add package BenchmarkDotNet without a version (or the repo's CPM file). Build in Release.--filter every time (BenchmarkSwitcher otherwise waits for interactive input) and check the entry point forwards args.--job Dry first, iterate with --job Short, report with the default job. Redirect output to a file and read *-report-github.md.[Params], set up in [GlobalSetup], no manual loops, materialize LINQ. Add [MemoryDiagnoser].Vectorizing a loop (TensorPrimitives, Vector128<T>): references/simd.md.
| Artifact | Open with |
|---|---|
.nettrace | PerfView or Visual Studio on Windows; dotnet-trace convert --format Speedscope for speedscope.app; dotnet-trace report <file> topN for a quick text summary |
.etl / .etl.zip | PerfView |
*.trace.zip from perfcollect | PerfView on Windows, or ./perfcollect view on Linux |
| CoreCLR dump | dotnet-dump analyze (SOS: clrstack -all, dumpheap -stat, gcroot, syncblk), WinDbg or lldb with SOS; diff two heap dumps in PerfView |
| NativeAOT core | lldb or gdb with the app's own debug symbols |
.crashreport.json | Read it; it lists threads and frames at the crash |
--providers on dotnet-trace collect drops the default profiles; add --profile dotnet-common,dotnet-sampled-thread-time back when you still want the thread-time samples.--duration takes dd:hh:mm:ss (00:00:00:30 is 30 seconds).collect-linux is a preview verb with a newer .nettrace format; open its output in a current PerfView, as convert and report may not read it yet.DOTNET_DiagnosticPorts suspends app startup until a tool connects, unless the value ends in ,nosuspend.Stopwatch loop over a few iterations measures tier-0 code.DOTNET_ environment variables such as DOTNET_TieredPGO=0 or DOTNET_EnableAVX2=0 don't affect code precompiled with ReadyToRun or Native AOT.dotnet-trace collect --clrevents assemblyloader -- ./myapp.references/benchmarkdotnet-config.md (opens in a new tab)references/benchmarkdotnet.md (opens in a new tab)references/dotnet-counters.md (opens in a new tab)references/dotnet-monitor.md (opens in a new tab)references/dotnet-trace.md (opens in a new tab)references/dumps-containers.md (opens in a new tab)references/dumps-nativeaot.md (opens in a new tab)references/dumps.md (opens in a new tab)references/mobile-symbolication.md (opens in a new tab)references/perfcollect.md (opens in a new tab)references/perfview.md (opens in a new tab)references/simd.md (opens in a new tab)references/symptoms.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub adminhead/claude-plugins --plugin dotnet-diagnostics