一键导入
dotnet-perf
Performance analysis — EF query plans, async bottlenecks, GC pressure, BenchmarkDotNet setup, allocation profiling. Spawns performance-profiler agent.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Performance analysis — EF query plans, async bottlenecks, GC pressure, BenchmarkDotNet setup, allocation profiling. Spawns performance-profiler agent.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Full-project health audit — spawns 5 specialists (dotnet-reviewer, security-analyzer, testing-reviewer, performance-profiler, deployment-validator) in parallel. Use for onboarding or pre-release.
Analyze project/namespace boundaries, detect circular refs and layering violations via dotnet-depends and solution graph. Use before major refactors or to validate Clean Architecture.
Senior-engineer challenge mode — aggressively question the current approach, hunt for N+1 queries, captive deps, missing auth, sync-over-async, leaks. Use before finalizing significant changes.
Capture a solved problem as institutional knowledge. Writes `.claude/solutions/{category}/{slug}.md` with symptoms, root cause, fix, category, tags. Use after notable fixes.
Generate or update documentation — XML doc comments, README, architecture docs, OpenAPI descriptions. Uses code as source of truth; no hallucinated features.
Extract durable lessons from a just-finished fix — propose CLAUDE.md rule, Iron Law addition, or Solution doc. Use after resolving a surprising/repeatable bug.
| name | dotnet:perf |
| description | Performance analysis — EF query plans, async bottlenecks, GC pressure, BenchmarkDotNet setup, allocation profiling. Spawns performance-profiler agent. |
| argument-hint | <file|endpoint|scenario> |
| effort | high |
Systematic performance investigation for .NET code.
Not for: micro-nits in cold paths. Measure before optimizing.
performance-profiler agentAsNoTracking, missing .AsSplitQuery for
multi-include, cartesian explosion, client-side evaluationConfigureAwait(false) in
libraries, Task.Run on the hot path to "avoid async"string.Format/interpolation
in logs, ToList() where IEnumerable suffices, boxing of
value typesHttpCompletionOption.ResponseHeadersRead for
streaming, HttpClient per-request, missing response compressionlock on hot path, unnecessary SemaphoreSlim,
ConcurrentDictionary misuseAssembly.Load calls, large DI graphdotnet-counters, dotnet-trace, dotnet-gcdump[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net80)]
public class OrderQueryBenchmarks
{
private AppDbContext _ctx = null!;
[GlobalSetup] public void Setup() { /* ... */ }
[Benchmark(Baseline = true)]
public async Task<int> WithTracking() =>
await _ctx.Orders.Where(o => o.Status == "Open").CountAsync();
[Benchmark]
public async Task<int> NoTracking() =>
await _ctx.Orders.AsNoTracking().Where(o => o.Status == "Open").CountAsync();
}
AsNoTracking() on read queriesIHttpClientFactory (socket exhaustion otherwise).Result (deadlocks look like slow code).claude/audit/perf-{scenario}.md:
# Perf Analysis: <scenario>
## Observed
- p99 latency: 1.8s
- Memory steady-state: 450 MB, growing to 900 MB under load
## Hypotheses (ranked by expected impact)
### 1. 🔴 N+1 query in /api/orders list
- File: src/Api/Orders/OrdersController.cs:47
- Current: foreach order { _ctx.Customer.Find(order.CustomerId) }
- Expected fix: .Include(o => o.Customer), or projected DTO
- Measurement: BenchmarkDotNet or logged EF queries
### 2. 🟠 Missing response compression
- ...
## Recommended Order
1. Fix N+1 (est -700ms p99)
2. Add compression (est -30% payload)
3. Profile with dotnet-counters if still slow
${CLAUDE_SKILL_DIR}/references/bench-patterns.md —
BenchmarkDotNet setup, attributes, pitfalls${CLAUDE_SKILL_DIR}/references/ef-query-analysis.md — query plan
inspection, Include vs projection, split queries${CLAUDE_SKILL_DIR}/references/gc-pressure.md — allocation-free
patterns, Span<T>, ArrayPool, ValueTask${CLAUDE_SKILL_DIR}/references/diagnostic-tools.md —
dotnet-counters, dotnet-trace, dotnet-gcdump, PerfViewToList() is faster than IEnumerable" (it's not — it materializes)Task.Run around awaited code "for perf"Stopwatch instead of BenchmarkDotNet