dotnet-performance

Optimizes .NET applications through async correctness, efficient data access, caching, and measured hotspot tuning.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/MartiXDev/ai-dev-strategy --skill dotnet-performance-martixdev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-performance
Source: https://github.com/MartiXDev/ai-dev-strategy/tree/main/plugins/dotnet-performance/skills/dotnet-performance
Command: npx skills add https://github.com/MartiXDev/ai-dev-strategy --skill dotnet-performance-martixdev

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? .NET applications often suffer from hidden performance issues like blocking sync-over-async calls, N+1 database queries, and poorly designed caching. This Skill provides a structured methodology to find and fix these bottlenecks with measurable results. ## Core Features & Use Cases - Async Correctness: Eliminates blocking anti-patterns like .Result, .Wait(), and GetAwaiter().GetResult(), and ensures CancellationToken propagation through service, repository, and HTTP/database calls. - Data-Access Efficiency: Reduces over-fetching with projections and AsNoTracking(), eliminates N+1 query patterns, and applies server-side filtering and pagination. - Caching Strategy: Implements cache-aside patterns with TTL, key versioning, stampede protection, and correct scoping between IMemoryCache and distributed caches. - Use Case: When an API endpoint shows high p99 latency, use this Skill to profile it with dotnet-counters, remove blocking calls, reshape the Entity Framework queries, add cache-aside for hot reads, and validate the improvement with before/after metrics. ## Quick Start Ask the AI to review a slow .NET endpoint or service for blocking calls, N+1 queries, and caching opportunities, then validate the fixes with measured latency and allocation metrics.

Frequently Asked Questions about dotnet-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix sync-over-async blocking calls in C#?

Replace `.Result`, `.Wait()`, and `GetAwaiter().GetResult()` with proper `await` usage propagated end-to-end through the call stack. Avoid wrapping I/O in `Task.Run`; instead fix the underlying blocking dependency so the entire hot path is async.

How to eliminate N+1 queries in Entity Framework Core?

Use explicit `Include` statements, batching, or query reshaping to load related data in fewer round trips. Combine this with `Select` projections to fetch only required columns and `AsNoTracking()` for read-only queries.

When should I use IMemoryCache vs distributed cache in .NET?

Use `IMemoryCache` for single-node deployments where data can be rebuilt locally. Choose a distributed cache when running multiple nodes that need consistent cached state, and always partition keys for tenant or user-scoped data.

When is ValueTask appropriate in high-performance C# code?

Use `ValueTask` only on truly high-frequency paths where synchronous completion is common and profiling validates the benefit. For typical async I/O paths, standard `Task` remains the correct default.

How do I prevent cache stampede on hot keys?

Apply single-flight locking, jittered expirations, or stale-while-revalidate patterns so concurrent misses do not all hit the backing store simultaneously. Combine with explicit TTLs and key versioning for predictable invalidation.