managedcode

dotnet-profiling

1
0
# Install this skill:
npx skills add managedcode/dotnet-skills --skill "dotnet-profiling"

Install specific skill from multi-skill repository

# Description

Use the free official .NET diagnostics CLI tools for profiling and runtime investigation in .NET repositories. Use when a repo needs CPU tracing, live counters, GC and allocation investigation, exception or contention tracing, heap snapshots, or startup diagnostics without GUI-only tooling.

# SKILL.md


name: dotnet-profiling
version: "1.0.0"
category: "Metrics"
description: "Use the free official .NET diagnostics CLI tools for profiling and runtime investigation in .NET repositories. Use when a repo needs CPU tracing, live counters, GC and allocation investigation, exception or contention tracing, heap snapshots, or startup diagnostics without GUI-only tooling."
compatibility: "Requires a .NET app or process to inspect; respects the repo's AGENTS.md commands first."


.NET Profiling

Trigger On

  • the repo needs performance or runtime profiling for a .NET application
  • the user asks about slow code, high CPU, GC pressure, allocation growth, exception storms, lock contention, or startup diagnostics
  • the team wants official CLI-based diagnostics without depending on dnx

Value

  • produce a concrete project delta: code, docs, config, tests, CI, or review artifact
  • reduce ambiguity through explicit planning, verification, and final validation skills
  • leave reusable project context so future tasks are faster and safer

Do Not Use For

  • replacing realistic performance tests or load tests with ad-hoc tracing alone
  • production heap collection when the pause risk has not been accepted
  • GUI-only workflows that the repo cannot automate or document

Inputs

  • the nearest AGENTS.md
  • target application, process, or startup path
  • the symptom being investigated: CPU, memory, GC, contention, exceptions, or startup

Quick Start

  1. Read the nearest AGENTS.md and confirm scope and constraints.
  2. Run this skill's Workflow through the Ralph Loop until outcomes are acceptable.
  3. Return the Required Result Format with concrete artifacts and verification evidence.

Workflow

  1. Build and run a realistic target first:
  2. prefer Release
  3. prefer realistic config, inputs, and data volume
  4. Start with the lightest useful tool:
  5. dotnet-counters for live health signals
  6. dotnet-trace for CPU, exception, contention, GC, and startup traces
  7. dotnet-gcdump for managed heap inspection when memory shape matters
  8. Prefer installed CLI tools over dnx one-shot execution so the repo commands stay stable and reproducible.
  9. Capture one focused profile at a time instead of mixing every signal into one run.
  10. For CPU and general runtime hotspots, start with dotnet-trace collect.
  11. For live triage, start with dotnet-counters monitor on System.Runtime.
  12. For heap analysis, use dotnet-gcdump carefully and document the pause risk.
  13. After each change, rerun the same measurement path and compare before versus after.

Bootstrap When Missing

If official .NET profiling tools are not available yet:

  1. Detect current state:
  2. dotnet --info
  3. dotnet tool list --global
  4. command -v dotnet-counters
  5. command -v dotnet-trace
  6. command -v dotnet-gcdump
  7. Choose the install path deliberately:
  8. preferred machine-level install:
    • dotnet tool install --global dotnet-counters
    • dotnet tool install --global dotnet-trace
    • dotnet tool install --global dotnet-gcdump
  9. direct-download fallback when global tools are not suitable:
    • use the official Microsoft Learn download links for dotnet-counters, dotnet-trace, and dotnet-gcdump
  10. Verify the installed tools resolve correctly:
  11. dotnet-counters --version
  12. dotnet-trace --version
  13. dotnet-gcdump --version
  14. Record exact profiling commands in AGENTS.md, for example:
  15. dotnet-counters monitor --process-id PID --counters System.Runtime
  16. dotnet-trace collect --process-id PID --profile dotnet-common,dotnet-sampled-thread-time -o trace.nettrace
  17. dotnet-gcdump collect --process-id PID --output heap.gcdump
  18. Run one bounded command and return status: configured or status: improved.
  19. If the repo intentionally standardizes on another profiling stack and does not want these tools, return status: not_applicable.

Deliver

  • explicit official .NET profiling commands
  • a clear profiling path for CPU, counters, and heap inspection
  • reproducible diagnostics commands that humans and agents can rerun

Validate

  • the chosen tool matches the actual symptom
  • commands target a realistic process and configuration
  • before/after comparisons use the same scenario
  • heap collection warnings are explicit when dotnet-gcdump is used

Ralph Loop

Use the Ralph Loop for every task, including docs, architecture, testing, and tooling work.

  1. Plan first (mandatory):
  2. analyze current state
  3. define target outcome, constraints, and risks
  4. write a detailed execution plan
  5. list final validation skills to run at the end, with order and reason
  6. Execute one planned step and produce a concrete delta.
  7. Review the result and capture findings with actionable next fixes.
  8. Apply fixes in small batches and rerun the relevant checks or review steps.
  9. Update the plan after each iteration.
  10. Repeat until outcomes are acceptable or only explicit exceptions remain.
  11. If a dependency is missing, bootstrap it or return status: not_applicable with explicit reason and fallback path.

Required Result Format

  • status: complete | clean | improved | configured | not_applicable | blocked
  • plan: concise plan and current iteration step
  • actions_taken: concrete changes made
  • validation_skills: final skills run, or skipped with reasons
  • verification: commands, checks, or review evidence summary
  • remaining: top unresolved items or none

For setup-only requests with no execution, return status: configured and exact next commands.

Load References

  • read references/commands.md for dotnet-trace, dotnet-counters, dotnet-dump, and dotnet-gcdump CLI commands
  • read references/patterns.md for CPU, memory, GC, contention, and exception profiling patterns

Example Requests

  • "Profile this .NET app for CPU hotspots."
  • "Investigate GC pressure in this service."
  • "Capture counters and a trace from startup."
  • "Set up official .NET profiling tools for local investigations."

# Supported AI Coding Agents

This skill is compatible with the SKILL.md standard and works with all major AI coding agents:

Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.