[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74ET9P7WRRFAP1EY0H34EQ0":3,"skill-same:01M74ET9P7WRRFAP1EY0H34EQ0":87},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":15,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":13,"repositoryHtmlUrl":27,"repositoryHomepageUrl":28,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M74ET9P7WRRFAP1EY0H34EQ0","analyzing-dotnet-performance",null,"Scans .NET code for about 50 performance anti-patterns across async, memory, strings, collections, LINQ, regex, serialization, and input\u002Foutput, with tiered severity. Use when analyzing .NET code for optimization opportunities, reviewing hot paths, or auditing allocation-heavy patterns. Not for measuring or profiling a running process (use profiling or microbenchmarking) or for SIMD work (use vectorization).","Cratis\u002FArchitecture","Cratis","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F16456213?v=4","01M6BXRH290K4C8RS4PTKK3HXQ","01M74ET2PT8TQK44HAHJBABW28",0,"MIT","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: analyzing-dotnet-performance\ndescription: 'Scans .NET code for about 50 performance anti-patterns across async, memory, strings, collections, LINQ, regex, serialization, and input\u002Foutput, with tiered severity. Use when analyzing .NET code for optimization opportunities, reviewing hot paths, or auditing allocation-heavy patterns. Not for measuring or profiling a running process (use profiling or microbenchmarking) or for SIMD work (use vectorization).'\nlicense: MIT\n---\n\u003C!-- cratis-ai-managed: skills\u002Fanalyzing-dotnet-performance\u002FSKILL.md -->\n\n\u003C!-- Modified by Cratis from dotnet's original (MIT): frontmatter, applicability, navigation and the changes listed in NOTICE. Upstream: https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills (plugins\u002Fdotnet-diag\u002Fskills\u002Fanalyzing-dotnet-performance\u002FSKILL.md; see NOTICE) -->\n\n# .NET Performance Patterns\n\nCratis rules in `.cratis\u002Fai\u002Frules\u002F` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ.\n\nScan C#\u002F.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.\n\n## When to Use\n\n- Reviewing C#\u002F.NET code for performance optimization opportunities\n- Auditing hot paths for allocation-heavy or inefficient patterns\n- Systematic scan of a codebase for known anti-patterns before release\n- Second-opinion analysis after manual performance review\n\n## When Not to Use\n\n- **Algorithmic complexity analysis** — this skill targets API usage patterns, not algorithm design\n- **Code not on a hot path** with no performance requirements — avoid premature optimization\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Source code | Yes | C# files, code blocks, or repository paths to scan |\n| Hot-path context | Recommended | Which code paths are performance-critical |\n| Target framework | Recommended | .NET version (some patterns require .NET 8+) |\n| Scan depth | Optional | `critical-only`, `standard` (default), or `comprehensive` |\n\n## Workflow\n\n### Step 1: Load Critical Reference\n\nResolve bundled paths from the directory that contains this `SKILL.md`, not from the user's workspace. Load this reference file first:\n\n- `references\u002Fcritical-patterns.md`\n\nIf a direct read fails, list this skill's `references\u002F` 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.\n\n### Step 2: Detect Code Signals and Select Topic Recipes\n\nScan 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.\n\nAfter detecting signals, load only the topic-specific references selected by scan depth:\n\n- `critical-only`: No additional references (use only `critical-patterns.md`)\n- `standard` (default): Load references matching detected signals from this list:\n  - `references\u002Fasync-patterns.md` — async\u002FTask\u002FValueTask signals\n  - `references\u002Fmemory-and-strings.md` — Span\u002FMemory\u002Fstring allocation signals\n  - `references\u002Fregex-patterns.md` — Regex signals\n  - `references\u002Fcollections-and-linq.md` — Dictionary\u002FList\u002FLINQ signals\n  - `references\u002Fio-and-serialization.md` — JsonSerializer\u002FHttpClient\u002FStream signals\n  - `references\u002Fstructural-patterns.md` — always loaded (unsealed classes checked regardless)\n- `comprehensive`: Load all six topic-specific references above\n\nFor coverage reporting, the selected references are `references\u002Fcritical-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: \u003Cpaths>; used inline recipes for missing references.` in the final report, with `\u003Cpaths>` replaced by the missing relative paths of the selected references only.\n\nUse the `## Detection` sections from loaded reference files and the inline recipes in Step 3 for categories whose reference files are unavailable.\n\n| Signal in Code | Topic |\n|----------------|-------|\n| `async`, `await`, `Task`, `ValueTask` | Async patterns |\n| `Span\u003C`, `Memory\u003C`, `stackalloc`, `ArrayPool`, `string.Substring`, `.Replace(`, `.ToLower()`, `+=` in loops, `params` | Memory & strings |\n| `Regex`, `[GeneratedRegex]`, `Regex.Match`, `RegexOptions.Compiled` | Regex patterns |\n| `Dictionary\u003C`, `List\u003C`, `.ToList()`, `.Where(`, `.Select(`, LINQ methods, `static readonly Dictionary\u003C` | Collections & LINQ |\n| `JsonSerializer`, `HttpClient`, `Stream`, `FileStream` | I\u002FO & serialization |\n\nAlways check structural patterns (unsealed classes) regardless of signals.\n\n**Scan depth controls scope:**\n- `critical-only`: Only critical patterns (deadlocks, >10x regressions)\n- `standard` (default): Critical + detected topic patterns\n- `comprehensive`: All pattern categories\n\n### Step 3: Scan and Report\n\n**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.\n\nFor each relevant pattern category, run the detection recipes below. Report exact counts, not estimates.\n\n**Core scan recipes** (run these when reference files aren't available):\n```\n# Strings & memory\ngrep -n '\\.IndexOf(\\\"' FILE                    # Missing StringComparison\ngrep -n '\\.Substring(' FILE                    # Substring allocations\ngrep -En '\\.(StartsWith|EndsWith|Contains)\\s*\\(' FILE  # Missing StringComparison\ngrep -n '\\.ToLower()\\|\\.ToUpper()' FILE        # Culture-sensitive + allocation\ngrep -n '\\.Replace(' FILE                      # Chained Replace allocations\ngrep -n 'params ' FILE                         # params array allocation\n\n# Collections & LINQ\ngrep -n '\\.Select\\|\\.Where\\|\\.OrderBy\\|\\.GroupBy' FILE  # LINQ on hot path\ngrep -n '\\.All\\|\\.Any' FILE                    # LINQ on string\u002Fchar\ngrep -n 'new Dictionary\u003C\\|new List\u003C' FILE      # Per-call allocation\ngrep -n 'static readonly Dictionary\u003C' FILE     # FrozenDictionary candidate\n\n# Regex\ngrep -n 'RegexOptions.Compiled' FILE           # Compiled regex budget\ngrep -n 'new Regex(' FILE                      # Per-call regex\ngrep -n 'GeneratedRegex' FILE                  # Positive: source-gen regex\n\n# Structural\ngrep -n 'public class \\|internal class ' FILE  # Unsealed classes\ngrep -n 'sealed class' FILE                    # Already sealed\ngrep -n ': IEquatable' FILE                    # Positive: struct equality\n```\n\n**Rules:**\n- Run every relevant recipe for the detected pattern categories\n- **Emit a scan execution checklist** before classifying findings — list each recipe and the hit count\n- A result of **0 hits** is valid and valuable (confirms good practice)\n- If reference files were loaded, also run their `## Detection` recipes\n\n**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\u002F185 is systematic, 12\u002F15 is a consistency fix.\n\n### Step 3b: Cross-File Consistency Check\n\nIf 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.\n\n### Step 3c: Compound Allocation Check\n\nAfter running scan recipes, look for these multi-allocation patterns that single-line recipes miss:\n\n1. **Branched `.Replace()` chains:** Methods that call `.Replace()` across multiple `if\u002Felse` branches — report total allocation count across all branches, not just per-line.\n2. **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.\n3. **Compound `+=` with embedded allocating calls:** Lines like `result += $\"...{Foo().ToLower()}\"` are 2+ allocations (interpolation + ToLower + concatenation) — flag the compound cost, not just the `.ToLower()`.\n4. **`string.Format` specificity:** Distinguish resource-loaded format strings (not fixable) from compile-time literal format strings (fixable with interpolation). Enumerate the actionable sites.\n\n### Step 4: Classify and Prioritize Findings\n\nAssign each finding a severity:\n\n| Severity | Criteria | Action |\n|----------|----------|--------|\n| 🔴 **Critical** | Deadlocks, crashes, security vulnerabilities, >10x regression | Must fix |\n| 🟡 **Moderate** | 2-10x improvement opportunity, best practice for hot paths | Should fix on hot paths |\n| ℹ️ **Info** | Pattern applies but code may not be on a hot path | Consider if profiling shows impact |\n\n**Prioritization rules:**\n1. If the user identified hot-path code, elevate all findings in that code to their maximum severity\n2. 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\"_\n3. Never suggest micro-optimizations on code that is clearly not performance-sensitive\n\n**Scale-based severity escalation:**\nWhen the same pattern appears across many instances, escalate severity:\n- 1-10 instances of the same anti-pattern → report at the pattern's base severity\n- 11-50 instances → escalate ℹ️ Info patterns to 🟡 Moderate\n- 50+ instances → escalate to 🟡 Moderate with elevated priority; flag as a codebase-wide systematic issue\n\nAlways report exact counts (from scan recipes), not estimates or agent summaries.\n\n### Step 5: Generate Findings\n\n**Keep findings compact.** Each finding is one short block — not an essay. Group by severity (🔴 → 🟡 → ℹ️), not by file.\n\nFormat per finding:\n\n```\n#### ID. Title (N instances)\n**Impact:** one-line impact statement\n**Files:** file1.cs:L1, file2.cs:L2, ... (list locations, don't build tables)\n**Fix:** one-line description of the change (e.g., \"Add `StringComparison.Ordinal` parameter\")\n**Caveat:** only if non-obvious (version requirement, correctness risk)\n```\n\n**Rules for compact output:**\n- **No ❌\u002F✅ code blocks** for trivial fixes (adding a keyword, parameter, or type change). A one-line fix description suffices.\n- **Only include code blocks** for non-obvious transformations (e.g., replacing a LINQ chain with a foreach loop, or hoisting a closure).\n- **File locations as inline comma-separated list**, not a table. Use `File.cs:L42` format.\n- **No explanatory prose** beyond the Impact line — the severity icon already conveys urgency.\n- **Merge related findings** that share the same fix (e.g., all `.ToLower()` calls go in one finding, not split by file).\n- **Positive findings** in a bullet list, not a table. One line per pattern: `✅ Pattern — evidence`.\n\nEnd with a summary table and disclaimer:\n\n```markdown\n| Severity | Count | Top Issue |\n|----------|-------|-----------|\n| 🔴 Critical | N | ... |\n| 🟡 Moderate | N | ... |\n| ℹ️ Info | N | ... |\n\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.\n```\n\n## Validation\n\nBefore delivering results, verify:\n\n- [ ] All critical patterns were checked (from reference files or inline recipes)\n- [ ] Topic-specific recipes run only when matching signals detected\n- [ ] Each finding includes a concrete code fix\n- [ ] Scan execution checklist is complete (all recipes run)\n- [ ] Summary table included at end\n\n## Common Pitfalls\n\n| Pitfall | Correct Approach |\n|---------|-----------------|\n| Flagging every `Dictionary` as needing `FrozenDictionary` | Only flag if the dictionary is never mutated after construction |\n| Suggesting `Span\u003CT>` in async methods | Use `Memory\u003CT>` in async code; `Span\u003CT>` only in sync hot paths |\n| Reporting LINQ outside hot paths | Only flag LINQ in identified hot paths or tight loops; LINQ is acceptable in code that runs infrequently. Since .NET 7, LINQ Min\u002FMax\u002FSum\u002FAverage are vectorized — blanket bans on LINQ are misguided |\n| Suggesting `ConfigureAwait(false)` in app code | Only applicable in library code; not primarily a performance concern |\n| Recommending `ValueTask` everywhere | Only for hot paths with frequent synchronous completion |\n| Flagging `new HttpClient()` in DI services | Check if `IHttpClientFactory` is already in use |\n| Suggesting `[GeneratedRegex]` for dynamic patterns | Only flag when the pattern string is a compile-time literal |\n| Suggesting `CollectionsMarshal.AsSpan` broadly | Only for ultra-hot paths with benchmarked evidence; adds complexity and fragility |\n| Suggesting `unsafe` code for micro-optimizations | Avoid `unsafe` except where absolutely necessary — do not recommend it for micro-optimizations that don't matter. Safe alternatives like `Span\u003CT>`, `stackalloc` in safe context, and `ArrayPool` cover the vast majority of performance needs |\n","\u003C!-- cratis-ai-managed: skills\u002Fanalyzing-dotnet-performance\u002FSKILL.md -->\n\n\u003C!-- Modified by Cratis from dotnet's original (MIT): frontmatter, applicability, navigation and the changes listed in NOTICE. Upstream: https:\u002F\u002Fgithub.com\u002Fdotnet\u002Fskills (plugins\u002Fdotnet-diag\u002Fskills\u002Fanalyzing-dotnet-performance\u002FSKILL.md; see NOTICE) -->\n\n# .NET Performance Patterns\n\nCratis rules in `.cratis\u002Fai\u002Frules\u002F` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ.\n\nScan C#\u002F.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.\n\n## When to Use\n\n- Reviewing C#\u002F.NET code for performance optimization opportunities\n- Auditing hot paths for allocation-heavy or inefficient patterns\n- Systematic scan of a codebase for known anti-patterns before release\n- Second-opinion analysis after manual performance review\n\n## When Not to Use\n\n- **Algorithmic complexity analysis** — this skill targets API usage patterns, not algorithm design\n- **Code not on a hot path** with no performance requirements — avoid premature optimization\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| Source code | Yes | C# files, code blocks, or repository paths to scan |\n| Hot-path context | Recommended | Which code paths are performance-critical |\n| Target framework | Recommended | .NET version (some patterns require .NET 8+) |\n| Scan depth | Optional | `critical-only`, `standard` (default), or `comprehensive` |\n\n## Workflow\n\n### Step 1: Load Critical Reference\n\nResolve bundled paths from the directory that contains this `SKILL.md`, not from the user's workspace. Load this reference file first:\n\n- `references\u002Fcritical-patterns.md`\n\nIf a direct read fails, list this skill's `references\u002F` 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.\n\n### Step 2: Detect Code Signals and Select Topic Recipes\n\nScan 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.\n\nAfter detecting signals, load only the topic-specific references selected by scan depth:\n\n- `critical-only`: No additional references (use only `critical-patterns.md`)\n- `standard` (default): Load references matching detected signals from this list:\n  - `references\u002Fasync-patterns.md` — async\u002FTask\u002FValueTask signals\n  - `references\u002Fmemory-and-strings.md` — Span\u002FMemory\u002Fstring allocation signals\n  - `references\u002Fregex-patterns.md` — Regex signals\n  - `references\u002Fcollections-and-linq.md` — Dictionary\u002FList\u002FLINQ signals\n  - `references\u002Fio-and-serialization.md` — JsonSerializer\u002FHttpClient\u002FStream signals\n  - `references\u002Fstructural-patterns.md` — always loaded (unsealed classes checked regardless)\n- `comprehensive`: Load all six topic-specific references above\n\nFor coverage reporting, the selected references are `references\u002Fcritical-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: \u003Cpaths>; used inline recipes for missing references.` in the final report, with `\u003Cpaths>` replaced by the missing relative paths of the selected references only.\n\nUse the `## Detection` sections from loaded reference files and the inline recipes in Step 3 for categories whose reference files are unavailable.\n\n| Signal in Code | Topic |\n|----------------|-------|\n| `async`, `await`, `Task`, `ValueTask` | Async patterns |\n| `Span\u003C`, `Memory\u003C`, `stackalloc`, `ArrayPool`, `string.Substring`, `.Replace(`, `.ToLower()`, `+=` in loops, `params` | Memory & strings |\n| `Regex`, `[GeneratedRegex]`, `Regex.Match`, `RegexOptions.Compiled` | Regex patterns |\n| `Dictionary\u003C`, `List\u003C`, `.ToList()`, `.Where(`, `.Select(`, LINQ methods, `static readonly Dictionary\u003C` | Collections & LINQ |\n| `JsonSerializer`, `HttpClient`, `Stream`, `FileStream` | I\u002FO & serialization |\n\nAlways check structural patterns (unsealed classes) regardless of signals.\n\n**Scan depth controls scope:**\n- `critical-only`: Only critical patterns (deadlocks, >10x regressions)\n- `standard` (default): Critical + detected topic patterns\n- `comprehensive`: All pattern categories\n\n### Step 3: Scan and Report\n\n**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.\n\nFor each relevant pattern category, run the detection recipes below. Report exact counts, not estimates.\n\n**Core scan recipes** (run these when reference files aren't available):\n```\n# Strings & memory\ngrep -n '\\.IndexOf(\\\"' FILE                    # Missing StringComparison\ngrep -n '\\.Substring(' FILE                    # Substring allocations\ngrep -En '\\.(StartsWith|EndsWith|Contains)\\s*\\(' FILE  # Missing StringComparison\ngrep -n '\\.ToLower()\\|\\.ToUpper()' FILE        # Culture-sensitive + allocation\ngrep -n '\\.Replace(' FILE                      # Chained Replace allocations\ngrep -n 'params ' FILE                         # params array allocation\n\n# Collections & LINQ\ngrep -n '\\.Select\\|\\.Where\\|\\.OrderBy\\|\\.GroupBy' FILE  # LINQ on hot path\ngrep -n '\\.All\\|\\.Any' FILE                    # LINQ on string\u002Fchar\ngrep -n 'new Dictionary\u003C\\|new List\u003C' FILE      # Per-call allocation\ngrep -n 'static readonly Dictionary\u003C' FILE     # FrozenDictionary candidate\n\n# Regex\ngrep -n 'RegexOptions.Compiled' FILE           # Compiled regex budget\ngrep -n 'new Regex(' FILE                      # Per-call regex\ngrep -n 'GeneratedRegex' FILE                  # Positive: source-gen regex\n\n# Structural\ngrep -n 'public class \\|internal class ' FILE  # Unsealed classes\ngrep -n 'sealed class' FILE                    # Already sealed\ngrep -n ': IEquatable' FILE                    # Positive: struct equality\n```\n\n**Rules:**\n- Run every relevant recipe for the detected pattern categories\n- **Emit a scan execution checklist** before classifying findings — list each recipe and the hit count\n- A result of **0 hits** is valid and valuable (confirms good practice)\n- If reference files were loaded, also run their `## Detection` recipes\n\n**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\u002F185 is systematic, 12\u002F15 is a consistency fix.\n\n### Step 3b: Cross-File Consistency Check\n\nIf 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.\n\n### Step 3c: Compound Allocation Check\n\nAfter running scan recipes, look for these multi-allocation patterns that single-line recipes miss:\n\n1. **Branched `.Replace()` chains:** Methods that call `.Replace()` across multiple `if\u002Felse` branches — report total allocation count across all branches, not just per-line.\n2. **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.\n3. **Compound `+=` with embedded allocating calls:** Lines like `result += $\"...{Foo().ToLower()}\"` are 2+ allocations (interpolation + ToLower + concatenation) — flag the compound cost, not just the `.ToLower()`.\n4. **`string.Format` specificity:** Distinguish resource-loaded format strings (not fixable) from compile-time literal format strings (fixable with interpolation). Enumerate the actionable sites.\n\n### Step 4: Classify and Prioritize Findings\n\nAssign each finding a severity:\n\n| Severity | Criteria | Action |\n|----------|----------|--------|\n| 🔴 **Critical** | Deadlocks, crashes, security vulnerabilities, >10x regression | Must fix |\n| 🟡 **Moderate** | 2-10x improvement opportunity, best practice for hot paths | Should fix on hot paths |\n| ℹ️ **Info** | Pattern applies but code may not be on a hot path | Consider if profiling shows impact |\n\n**Prioritization rules:**\n1. If the user identified hot-path code, elevate all findings in that code to their maximum severity\n2. 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\"_\n3. Never suggest micro-optimizations on code that is clearly not performance-sensitive\n\n**Scale-based severity escalation:**\nWhen the same pattern appears across many instances, escalate severity:\n- 1-10 instances of the same anti-pattern → report at the pattern's base severity\n- 11-50 instances → escalate ℹ️ Info patterns to 🟡 Moderate\n- 50+ instances → escalate to 🟡 Moderate with elevated priority; flag as a codebase-wide systematic issue\n\nAlways report exact counts (from scan recipes), not estimates or agent summaries.\n\n### Step 5: Generate Findings\n\n**Keep findings compact.** Each finding is one short block — not an essay. Group by severity (🔴 → 🟡 → ℹ️), not by file.\n\nFormat per finding:\n\n```\n#### ID. Title (N instances)\n**Impact:** one-line impact statement\n**Files:** file1.cs:L1, file2.cs:L2, ... (list locations, don't build tables)\n**Fix:** one-line description of the change (e.g., \"Add `StringComparison.Ordinal` parameter\")\n**Caveat:** only if non-obvious (version requirement, correctness risk)\n```\n\n**Rules for compact output:**\n- **No ❌\u002F✅ code blocks** for trivial fixes (adding a keyword, parameter, or type change). A one-line fix description suffices.\n- **Only include code blocks** for non-obvious transformations (e.g., replacing a LINQ chain with a foreach loop, or hoisting a closure).\n- **File locations as inline comma-separated list**, not a table. Use `File.cs:L42` format.\n- **No explanatory prose** beyond the Impact line — the severity icon already conveys urgency.\n- **Merge related findings** that share the same fix (e.g., all `.ToLower()` calls go in one finding, not split by file).\n- **Positive findings** in a bullet list, not a table. One line per pattern: `✅ Pattern — evidence`.\n\nEnd with a summary table and disclaimer:\n\n```markdown\n| Severity | Count | Top Issue |\n|----------|-------|-----------|\n| 🔴 Critical | N | ... |\n| 🟡 Moderate | N | ... |\n| ℹ️ Info | N | ... |\n\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.\n```\n\n## Validation\n\nBefore delivering results, verify:\n\n- [ ] All critical patterns were checked (from reference files or inline recipes)\n- [ ] Topic-specific recipes run only when matching signals detected\n- [ ] Each finding includes a concrete code fix\n- [ ] Scan execution checklist is complete (all recipes run)\n- [ ] Summary table included at end\n\n## Common Pitfalls\n\n| Pitfall | Correct Approach |\n|---------|-----------------|\n| Flagging every `Dictionary` as needing `FrozenDictionary` | Only flag if the dictionary is never mutated after construction |\n| Suggesting `Span\u003CT>` in async methods | Use `Memory\u003CT>` in async code; `Span\u003CT>` only in sync hot paths |\n| Reporting LINQ outside hot paths | Only flag LINQ in identified hot paths or tight loops; LINQ is acceptable in code that runs infrequently. Since .NET 7, LINQ Min\u002FMax\u002FSum\u002FAverage are vectorized — blanket bans on LINQ are misguided |\n| Suggesting `ConfigureAwait(false)` in app code | Only applicable in library code; not primarily a performance concern |\n| Recommending `ValueTask` everywhere | Only for hot paths with frequent synchronous completion |\n| Flagging `new HttpClient()` in DI services | Check if `IHttpClientFactory` is already in use |\n| Suggesting `[GeneratedRegex]` for dynamic patterns | Only flag when the pattern string is a compile-time literal |\n| Suggesting `CollectionsMarshal.AsSpan` broadly | Only for ultra-hot paths with benchmarked evidence; adds complexity and fragility |\n| Suggesting `unsafe` code for micro-optimizations | Avoid `unsafe` except where absolutely necessary — do not recommend it for micro-optimizations that don't matter. Safe alternatives like `Span\u003CT>`, `stackalloc` in safe context, and `ArrayPool` cover the vast majority of performance needs |\n",{"name":5,"license":14,"description":7},"main","68f67ef8a166617b7a614aae2545f77d3c7d5ab8",".cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture","https:\u002F\u002Fwww.cratis.io\u002Farchitecture\u002F","https:\u002F\u002Fgithub.com\u002FCratis","https:\u002F\u002Fwww.cratis.io","Open-source (MIT) event sourcing and CQRS for .NET and beyond: Chronicle, Arc, Components and Screenplay.","2026-11-14 06:37:25",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add Cratis\u002FArchitecture --skill analyzing-dotnet-performance",{"tool":39,"command":40},"bunx","bunx skills add Cratis\u002FArchitecture --skill analyzing-dotnet-performance",{"tool":42,"command":43},"pnpm","pnpm dlx skills add Cratis\u002FArchitecture --skill analyzing-dotnet-performance","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002FSKILL.md",true,[47,51,57,63,67,71,75,79,83],{"path":48,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":15},"LICENSE","许可证",1181,{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"NOTICE","OTHER","其他",1698,"https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002FNOTICE",{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"references\u002Fasync-patterns.md","REFERENCE","参考文档",3369,"https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002Freferences\u002Fasync-patterns.md",{"path":64,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fcollections-and-linq.md",8350,"https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002Freferences\u002Fcollections-and-linq.md",{"path":68,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":69,"sourceHtmlUrl":70},"references\u002Fcritical-patterns.md",7023,"https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002Freferences\u002Fcritical-patterns.md",{"path":72,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fio-and-serialization.md",4160,"https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002Freferences\u002Fio-and-serialization.md",{"path":76,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fmemory-and-strings.md",6465,"https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002Freferences\u002Fmemory-and-strings.md",{"path":80,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fregex-patterns.md",3417,"https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002Freferences\u002Fregex-patterns.md",{"path":84,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fstructural-patterns.md",1974,"https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fanalyzing-dotnet-performance\u002Freferences\u002Fstructural-patterns.md",[88,96,104,112,120,128],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":92,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M74EZHX4AJ09G25KF026Q7P5","vectorization","Designs, implements, optimizes, and reviews SIMD code in .NET: vectorizing scalar loops with TensorPrimitives, Vector64, Vector128, Vector256, Vector512, or hardware intrinsics, and reviewing existing SIMD code, including the generic Vector type, for contract equivalence, tail handling, memory safety, portability, fallbacks, and measured performance. Use when a .NET loop or SIMD routine is being written or reviewed. Not for performance work unrelated to SIMD.","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fvectorization\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fvectorization\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":100,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M74EZD5Y0JQAJATM11TTSZRA","target-authoring","Canonical patterns for writing custom MSBuild targets: DependsOnTargets versus BeforeTargets and AfterTargets, the Build-to-CoreBuild three-level pattern, and the XxxDependsOn chain-extension pattern. Use when diagnosing or fixing custom-target anti-patterns: Directory.Build.targets redefining SDK targets, targets that replace CompileDependsOn instead of extending it, Outputs versus Returns misuse that returns stale results, missing Inputs\u002FOutputs causing needless rebuilds, or missing FileWrites registration. Not for incremental build tuning or general anti-pattern review (use the msbuild skill), or non-MSBuild build systems.","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Ftarget-authoring\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Ftarget-authoring\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":108,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":19},"01M74EZ8ZSW7M8ZR2WBDED4YNA","run-tests","Chooses and runs the repository-compatible .NET test command: classic, VSTest, bridged MTP, or native MTP syntax for MSTest, xUnit, NUnit, and TUnit. Use before running .NET tests or answering with a test command or flags: run the tests, one test, class, category, trait or target framework, combined filters, --filter-query, --no-build, --diag, TRX, coverage collection, crash or hang dumps, filter errors, or unrecognized options. Not for platform identification alone (use platform-detection), writing or debugging test code, interpreting a coverage report (use coverage-analysis), CI investigation, migration, or a persistent hot-reload loop.","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Frun-tests\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Frun-tests\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":116,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":19},"01M74EZ4Q0W4B632KY77V6K5EP","profiling","Uses the free official .NET diagnostics CLI tools for profiling and runtime investigation in a repository: CPU, GC pressure, allocation growth, exception storms, lock contention, and slow code. Use when a .NET application needs performance or runtime profiling. Not for replacing realistic performance or load tests with ad-hoc tracing, production heap collection without a pause-risk plan, crash dumps (use dump-collect), or benchmark design (use microbenchmarking).","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fprofiling\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fprofiling\u002FSKILL.md",[],[],{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":124,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":19},"01M74EZ08N8PGKKZY6Z1DRR5YS","platform-detection","Identifies a .NET project's test platform, framework, command mode, and SDK-style versus classic project system, resolving global.json, project, packages.config, Directory.Build.props, and Directory.Packages.props precedence for MSTest, xUnit, NUnit, and TUnit. Use when asking \"which test platform or framework?\", \"VSTest or MTP?\", or \"what runner does this project use?\", including bridge settings, UseVSTest opt-outs, and conflicting VSTest\u002FMTP configuration. Not for running or filtering tests, commands, flags, TRX, dumps, or test-command errors (use run-tests), or for hot-reload or migration requests.","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fplatform-detection\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Fplatform-detection\u002FSKILL.md",[],[],{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":132,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":19},"01M74EYW35N2Y22QQXANX9TQ1V","orleans","Designs Microsoft Orleans systems from each primitive's purpose and failure model: grains, digital twins, state versus databases, transactions, messaging, streams, timers, reminders, Durable Jobs, stateless workers, grain services, startup, and hosting. Use when a task needs an Orleans design decision: inspect version and topology, choose the primitive, implement, and validate. Not for other actor stacks, batch processing, relational-only CRUD, or advice without an Orleans decision.","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Forleans\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FCratis\u002FArchitecture\u002Fblob\u002Fmain\u002F.cratis\u002Fai\u002Fskills\u002Forleans\u002FSKILL.md",[],[]]