Files
dotnet__skills/.gitignore
T
Art Leonard 0cee0843ca Add .NET performance analysis skill and optimizing agent (#6)
* Add .NET deep performance fixer agent and performance patterns skill

Introduce a dotnet-performance-optimizer agent and the
dotnet-performance-patterns skill with reference guides covering:
- Async patterns
- Collections and LINQ
- Critical performance patterns
- I/O and serialization
- Memory and strings
- Regex patterns

* Align agent and skill performance reporting workflow

- Add two-pass analysis methodology (Pass 1: LLM-only, Pass 2: skill-based)
- Consolidate skill references to match actual reference files
- Remove references to non-existent skills (dotnet-jit-optimization, dotnet-async-patterns, dotnet-sync-primitives)
- Update pattern count to 85+ to reflect current reference corpus

* Update performance patterns skill with expanded reference coverage

- Add structural-patterns.md reference file
- Expand collections-and-linq, memory-and-strings, regex patterns references
- Update critical-patterns with refined rules
- Expand SKILL.md with additional workflow guidance

* Add missing structural-patterns.md reference to agent skill list

* Add non-deterministic results disclaimer to agent and skill output

* Trim agent per skill authoring best practices

Apply recommendations from platform.claude.com best practices:
- Remove sections Claude already knows (Core Expertise, Edge Cases,
  Key Principles, When to Ask, Tone) - these waste context tokens
- Remove skill internal reference file listing (skill handles its
  own progressive disclosure)
- Condense 138 lines to 55 lines (-60%)
- Keep only what Claude needs: two-pass workflow, output format,
  skill reference, escalation guidance

* Trim SKILL.md per skill authoring best practices

Apply recommendations from platform.claude.com best practices:
- Remove Purpose section (redundant with description frontmatter)
- Remove When to Use (redundant with description triggers)
- Consolidate signal table (11 rows → 5, merging same-reference rows)
- Remove 50-line checklist example template (keep the rule, not the example)
- Remove 25-line Recipe Completeness Verification (redundant with gate)
- Remove 40-line Output Format example (Claude knows markdown)
- Trim Validation from 8 items + gate to 5 essential items
- Trim Common Pitfalls from 3-column to 2-column
- Condense Steps 5+6 into single Step 5
- 311 lines → 134 lines (-57%)

* Trim reference files per Claude skill authoring best practices

Apply 'Claude is already smart' principle to reference files:
- Remove 6 patterns Claude already knows (Interlocked, SemaphoreSlim dup,
  Array.Empty, Any() vs Count(), Enum.HasFlag, Random.Shared)
- Remove IEquatable<T> duplicate (kept in structural-patterns.md)
- Remove 'Why a Separate File' meta-commentary from structural-patterns.md
- Remove all horizontal rules between patterns
- Remove explanatory prose and obvious inline comments
- Preserve all Detection sections, scan recipes, and Impact statements

Total: 1,819 → 1,372 lines (-25%)

* Rename skill and agent to gerund form per naming conventions

- dotnet-performance-patterns → analyzing-dotnet-performance
- dotnet-performance-optimizer → optimizing-dotnet-performance
- Update all cross-references in frontmatter and agent skill list

* Rewrite descriptions per effective description guidelines

- Agent: Replace second-person trigger phrases and verbose examples with
  concise third-person description stating what it does and when to use it
- Skill: Add specificity (85+ patterns, tiered severity) and clearer triggers
- Both now follow: third person, specific key terms, what + when format

* Refine performance report structure and findings format for clarity and conciseness

* Remove outdated reference link from SKILL.md for clarity

* Remove further reading section from SKILL.md for conciseness

* Add compound allocation check to performance analysis workflow

* Add performance analysis scenarios for critical patterns, collections, I/O, and struct issues

* Address PR #6 review feedback from Stephen Toub

Remove 15 patterns that are correctness-only, redundant, or not actionable:
- async void, lock+async, Async All the Way Down, NonBacktracking,
  Regex timeouts, Cache Regex, Budget Compiled Regex, Seal Classes stub,
  ConfigureAwait(false), Parallel.ForEachAsync, async lambda Action,
  C#10 Interpolation Handlers, Span-Based Comparison, Utf8JsonWriter,
  JsonSerializerContext for AOT

Clarify 3 patterns where rationale was unclear:
- IEquatable<T>: explain boxing via EqualityComparer<T>.Default
- IsMatch guard: explain Replace always allocates even on no-match
- Chained strings: split into 3 distinct anti-pattern/fix pairs

Rework 3 patterns per feedback:
- CollectionsMarshal.AsSpan: qualified to ultra-hot-path-only
- LINQ guardrail: moved to Common Pitfalls table
- params overloads: added params ReadOnlySpan<T> as .NET 9+ alternative

Fix nits:
- Title: arrays → substring for slicing pattern
- Remove try/finally from ArrayPool example
- Qualify impact statement on boxing
- Remove numbered headings for consistency across reference files
- Add unsafe code pitfall to Common Pitfalls
- Update pattern count 85→70, critical count 24→17

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Move skill, agent, and tests to src/dotnet/ component layout

Restructure to match upstream directory conventions:
- skills/ → src/dotnet/skills/
- agents/ → src/dotnet/agents/
- skill tests → src/dotnet/tests/
- Update eval.yaml fixture source paths

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix eval.yaml source paths to resolve relative to skill directory

The validator resolves source paths via join(skillPath, source),
so fixture references need ../../tests/ prefix from the skill dir.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Remove validator results from tracking and add to .gitignore

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Replace synthetic eval fixtures with Humanizer-derived needle-in-haystack test suite

Replace 4 synthetic Contoso fixtures with 11 realistic test fixtures modeled
on patterns from the Humanizer library performance analysis (Runs A-J).

10 eval scenarios with 51 rubric items (up from 4 scenarios / 19 rubric items):
- Scenarios 1-9: patterns the skill outperformed naked model on (J vs B)
- Scenario 10: baseline patterns J missed (Span inconsistencies, unsealed classes)

Each fixture is 240-380 lines with ~80% clean haystack code surrounding
the anti-pattern needles, including decoys, positive findings, and correct
patterns as contrast.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Split scenario 10 into two focused scenarios for truncation and unsealed classes

The combined scenario was timing out at 120s with 2 files and 6 rubric items.
Split into:
- Scenario 10: Span inconsistencies and compound method chains (Truncation.cs, 3 rubric items)
- Scenario 11: Unsealed leaf classes and locale hierarchy (Locales.cs, 3 rubric items)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Increase timeout to 180s for scenarios 7 and 10

These scenarios consistently timed out at 120s before the agent could
synthesize findings, causing weak/negative improvement scores despite
the skill detecting correct patterns.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Increase timeout to 180s for scenarios 4, 8, 9

All three timed out at 120s — agent spent time loading skill references
and running grep recipes, never reaching synthesis before cutoff.
Scenarios 7 and 10 already at 180s from prior fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Tune SKILL.md for sandboxed eval and add results report

SKILL.md changes:
- Add fallback for missing reference files (skip filesystem search)
- Inline core scan recipes so agent works without reference files
- Add 'read small files first' guidance to reduce grep overhead
- Update validation checklist for reference-optional workflow

Results: 73.7% overall improvement, 11/11 scenarios strong (≥60%)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Addressing @danmoseley feedback

* Update src/dotnet/skills/analyzing-dotnet-performance/references/critical-patterns.md

Co-authored-by: Dan Moseley <danmose@microsoft.com>

* Address PR #6 review feedback: skill docs and fixture fixes

Skill/reference changes:
- Remove CollectionsMarshal.AsSpan section (too much churn per stephentoub)
- Remove startup/initialization as examples of non-perf-sensitive code
- Split Contains into own grep with false-positive note
- Clarify 'exact counts' means grep match counts
- GeneratedRegex: ALWAYS for static patterns, always beneficial
- Rewrite regex engine section: static->GeneratedRegex, never remove NonBacktracking
- Sealed class grep catches protected and file classes
- StringComparison grep uses proper ERE, catches variable args

Test fixture fixes:
- Fix invalid regex character class in inflector-and-regex.cs
- Fix Hungarian converter cache key (use original number)
- Add truncation guard for truncationString >= length
- Use explicit ordered array instead of dictionary keys for Farsi/Kurdish
- Preserve negative sign in ToMetric null-symbol fallback
- Remove stray double semicolon

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Dan Moseley <danmose@microsoft.com>
2026-02-26 11:15:27 +01:00

7.2 KiB