Analyzing Dotnet Performance logo

Analyzing Dotnet Performance

OrganizationPopular
dotnet
analyzing-dotnet-performance

Scans .NET code for ~50 performance anti-patterns across async, memory, strings, collections, LINQ, regex, serialization, and I/O with tiered severity classification. Use when analyzing .NET code for optimization opportunities, reviewing hot paths, or auditing allocation-heavy patterns.

Overview

Publisherdotnet
Repositoryskills
Skill nameanalyzing-dotnet-performance
Stars
5.4K
Forks
416
Bundled files
7
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 7 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by dotnet on GitHub. Read the source before you install it.

Installation

Install the Analyzing Dotnet Performance AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dotnet/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/plugins/dotnet-diag/skills/analyzing-dotnet-performance .claude/skills/analyzing-dotnet-performance
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Analyzing Dotnet Performance in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Analyzing Dotnet Performance on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Analyzing Dotnet Performance is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

.NET Performance Patterns

Scan C#/.NET code for performance anti-patterns and produce prioritized findings with concrete fixes. Patterns sourced from the official .NET performance blog series, distilled to customer-actionable guidance.

When to Use

  • Reviewing C#/.NET code for performance optimization opportunities
  • Auditing hot paths for allocation-heavy or inefficient patterns
  • Systematic scan of a codebase for known anti-patterns before release
  • Second-opinion analysis after manual performance review

When Not to Use

  • Algorithmic complexity analysis — this skill targets API usage patterns, not algorithm design
  • Code not on a hot path with no performance requirements — avoid premature optimization

Inputs

InputRequiredDescription
Source codeYesC# files, code blocks, or repository paths to scan
Hot-path contextRecommendedWhich code paths are performance-critical
Target frameworkRecommended.NET version (some patterns require .NET 8+)
Scan depthOptionalcritical-only, standard (default), or comprehensive

Workflow

Step 1: Load Critical Reference

Resolve bundled paths from the directory that contains this SKILL.md, not from the user's workspace. Load this reference file first:

  • references/critical-patterns.md

If a direct read fails, list this skill's references/ directory once and retry only when the listing shows the expected file. Do not use workspace file or text search to locate the skill installation.

Step 2: Detect Code Signals and Select Topic Recipes

Scan the code for signals that indicate which pattern categories to check. Use the ## Detection section from the critical reference when available and the inline recipes in Step 3 for initial signal detection.

After detecting signals, load only the topic-specific references selected by scan depth:

  • critical-only: No additional references (use only critical-patterns.md)
  • standard (default): Load references matching detected signals from this list:
    • references/async-patterns.md — async/Task/ValueTask signals
    • references/memory-and-strings.md — Span/Memory/string allocation signals
    • references/regex-patterns.md — Regex signals
    • references/collections-and-linq.md — Dictionary/List/LINQ signals
    • references/io-and-serialization.md — JsonSerializer/HttpClient/Stream signals
    • references/structural-patterns.md — always loaded (unsealed classes checked regardless)
  • comprehensive: Load all six topic-specific references above

For coverage reporting, the selected references are references/critical-patterns.md plus only the topic-specific references selected above. If any selected reference remains unavailable after retry, use the inline recipes in Step 3 for the missing coverage. Include Reference coverage: reduced; unavailable: <paths>; used inline recipes for missing references. in the final report, with <paths> replaced by the missing relative paths of the selected references only.

Use the ## Detection sections from loaded reference files and the inline recipes in Step 3 for categories whose reference files are unavailable.

Signal in CodeTopic
async, await, Task, ValueTaskAsync patterns
Span<, Memory<, stackalloc, ArrayPool, string.Substring, .Replace(, .ToLower(), += in loops, paramsMemory & strings
Regex, [GeneratedRegex], Regex.Match, RegexOptions.CompiledRegex patterns
Dictionary<, List<, .ToList(), .Where(, .Select(, LINQ methods, static readonly Dictionary<Collections & LINQ
JsonSerializer, HttpClient, Stream, FileStreamI/O & serialization

Always check structural patterns (unsealed classes) regardless of signals.

Scan depth controls scope:

  • critical-only: Only critical patterns (deadlocks, >10x regressions)
  • standard (default): Critical + detected topic patterns
  • comprehensive: All pattern categories

Step 3: Scan and Report

For files under 500 lines, read the entire file first — you'll spot most patterns faster than running individual grep recipes. Use grep to confirm counts and catch patterns you might miss visually.

For each relevant pattern category, run the detection recipes below. Report exact counts, not estimates.

Core scan recipes (run these when reference files aren't available):

# Strings & memory
grep -n '\.IndexOf(\"' FILE                    # Missing StringComparison
grep -n '\.Substring(' FILE                    # Substring allocations
grep -En '\.(StartsWith|EndsWith|Contains)\s*\(' FILE  # Missing StringComparison
grep -n '\.ToLower()\|\.ToUpper()' FILE        # Culture-sensitive + allocation
grep -n '\.Replace(' FILE                      # Chained Replace allocations
grep -n 'params ' FILE                         # params array allocation

# Collections & LINQ
grep -n '\.Select\|\.Where\|\.OrderBy\|\.GroupBy' FILE  # LINQ on hot path
grep -n '\.All\|\.Any' FILE                    # LINQ on string/char
grep -n 'new Dictionary<\|new List<' FILE      # Per-call allocation
grep -n 'static readonly Dictionary<' FILE     # FrozenDictionary candidate

# Regex
grep -n 'RegexOptions.Compiled' FILE           # Compiled regex budget
grep -n 'new Regex(' FILE                      # Per-call regex
grep -n 'GeneratedRegex' FILE                  # Positive: source-gen regex

# Structural
grep -n 'public class \|internal class ' FILE  # Unsealed classes
grep -n 'sealed class' FILE                    # Already sealed
grep -n ': IEquatable' FILE                    # Positive: struct equality

Rules:

  • Run every relevant recipe for the detected pattern categories
  • Emit a scan execution checklist before classifying findings — list each recipe and the hit count
  • A result of 0 hits is valid and valuable (confirms good practice)
  • If reference files were loaded, also run their ## Detection recipes

Verify-the-Inverse Rule: For absence patterns, always count both sides and report the ratio (e.g., "N of M classes are sealed"). The ratio determines severity — 0/185 is systematic, 12/15 is a consistency fix.

Step 3b: Cross-File Consistency Check

If an optimized pattern is found in one file, check whether sibling files (same directory, same interface, same base class) use the un-optimized equivalent. Flag as 🟡 Moderate with the optimized file as evidence.

Step 3c: Compound Allocation Check

After running scan recipes, look for these multi-allocation patterns that single-line recipes miss:

  1. Branched .Replace() chains: Methods that call .Replace() across multiple if/else branches — report total allocation count across all branches, not just per-line.
  2. Cross-method chaining: When a public method delegates to another method that itself allocates intermediates (e.g., A calls B which does 3 regex replaces, then A calls C), report the total chain cost as one finding.
  3. Compound += with embedded allocating calls: Lines like result += $"...{Foo().ToLower()}" are 2+ allocations (interpolation + ToLower + concatenation) — flag the compound cost, not just the .ToLower().
  4. string.Format specificity: Distinguish resource-loaded format strings (not fixable) from compile-time literal format strings (fixable with interpolation). Enumerate the actionable sites.

Step 4: Classify and Prioritize Findings

Assign each finding a severity:

SeverityCriteriaAction
🔴 CriticalDeadlocks, crashes, security vulnerabilities, >10x regressionMust fix
🟡 Moderate2-10x improvement opportunity, best practice for hot pathsShould fix on hot paths
ℹ️ InfoPattern applies but code may not be on a hot pathConsider if profiling shows impact

Prioritization rules:

  1. If the user identified hot-path code, elevate all findings in that code to their maximum severity
  2. If hot-path context is unknown, report 🔴 Critical findings unconditionally; report 🟡 Moderate findings with a note: "Impactful if this code is on a hot path"
  3. Never suggest micro-optimizations on code that is clearly not performance-sensitive

Scale-based severity escalation: When the same pattern appears across many instances, escalate severity:

  • 1-10 instances of the same anti-pattern → report at the pattern's base severity
  • 11-50 instances → escalate ℹ️ Info patterns to 🟡 Moderate
  • 50+ instances → escalate to 🟡 Moderate with elevated priority; flag as a codebase-wide systematic issue

Always report exact counts (from scan recipes), not estimates or agent summaries.

Step 5: Generate Findings

Keep findings compact. Each finding is one short block — not an essay. Group by severity (🔴 → 🟡 → ℹ️), not by file.

Format per finding:

#### ID. Title (N instances)
**Impact:** one-line impact statement
**Files:** file1.cs:L1, file2.cs:L2, ... (list locations, don't build tables)
**Fix:** one-line description of the change (e.g., "Add `StringComparison.Ordinal` parameter")
**Caveat:** only if non-obvious (version requirement, correctness risk)

Rules for compact output:

  • No ❌/✅ code blocks for trivial fixes (adding a keyword, parameter, or type change). A one-line fix description suffices.
  • Only include code blocks for non-obvious transformations (e.g., replacing a LINQ chain with a foreach loop, or hoisting a closure).
  • File locations as inline comma-separated list, not a table. Use File.cs:L42 format.
  • No explanatory prose beyond the Impact line — the severity icon already conveys urgency.
  • Merge related findings that share the same fix (e.g., all .ToLower() calls go in one finding, not split by file).
  • Positive findings in a bullet list, not a table. One line per pattern: ✅ Pattern — evidence.

End with a summary table and disclaimer:

markdown
| Severity | Count | Top Issue |
|----------|-------|-----------|
| 🔴 Critical | N | ... |
| 🟡 Moderate | N | ... |
| ℹ️ Info | N | ... |

> ⚠️ **Disclaimer:** These results are generated by an AI assistant and are non-deterministic. Findings may include false positives, miss real issues, or suggest changes that are incorrect for your specific context. Always verify recommendations with benchmarks and human review before applying changes to production code.

Validation

Before delivering results, verify:

  • All critical patterns were checked (from reference files or inline recipes)
  • Topic-specific recipes run only when matching signals detected
  • Each finding includes a concrete code fix
  • Scan execution checklist is complete (all recipes run)
  • Summary table included at end

Common Pitfalls

PitfallCorrect Approach
Flagging every Dictionary as needing FrozenDictionaryOnly flag if the dictionary is never mutated after construction
Suggesting Span<T> in async methodsUse Memory<T> in async code; Span<T> only in sync hot paths
Reporting LINQ outside hot pathsOnly flag LINQ in identified hot paths or tight loops; LINQ is acceptable in code that runs infrequently. Since .NET 7, LINQ Min/Max/Sum/Average are vectorized — blanket bans on LINQ are misguided
Suggesting ConfigureAwait(false) in app codeOnly applicable in library code; not primarily a performance concern
Recommending ValueTask everywhereOnly for hot paths with frequent synchronous completion
Flagging new HttpClient() in DI servicesCheck if IHttpClientFactory is already in use
Suggesting [GeneratedRegex] for dynamic patternsOnly flag when the pattern string is a compile-time literal
Suggesting CollectionsMarshal.AsSpan broadlyOnly for ultra-hot paths with benchmarked evidence; adds complexity and fragility
Suggesting unsafe code for micro-optimizationsAvoid unsafe except where absolutely necessary — do not recommend it for micro-optimizations that don't matter. Safe alternatives like Span<T>, stackalloc in safe context, and ArrayPool cover the vast majority of performance needs

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Analyzing Dotnet Performance AI skill do?

Scans .NET code for ~50 performance anti-patterns across async, memory, strings, collections, LINQ, regex, serialization, and I/O with tiered severity classification. Use when analyzing .NET code for optimization opportunities, reviewing hot paths, or auditing allocation-heavy patterns.

Why use Analyzing Dotnet Performance on TypingMind?

Because you install it once and use it with any model. Analyzing Dotnet Performance is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Analyzing Dotnet Performance in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dotnet/skills/tree/main/plugins/dotnet-diag/skills/analyzing-dotnet-performance. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Analyzing Dotnet Performance?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Analyzing Dotnet Performance?

As many as you like. As long as a model supports skills, you can use Analyzing Dotnet Performance with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Analyzing Dotnet Performance AI skill free?

Yes. It is published on GitHub by dotnet under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇