/ 目錄 / 演練場 / .NET Skills
● 社群 Aaronontheweb ⚡ 即開即用

.NET Skills

作者 Aaronontheweb · Aaronontheweb/dotnet-skills

Claude 中慣用的 .NET 8/9 — 涵蓋 xUnit 測試、BenchmarkDotNet 效能、NuGet 套件、async/await 正確性與 C# 程式碼風格的 skills 集。

Aaron Stannard 的 .NET Skills 是為嚴肅 .NET 開發者準備的實戰驗證套件。除了簡單的程式碼生成之外,它涵蓋了模型習慣性出錯的部分:async 取消、ConfigureAwait 用法、IDisposable、struct 對 class 的取捨、BenchmarkDotNet 模式、NuGet 套件中繼資料,以及現代 xUnit + FluentAssertions 風格。

為什麼要用

核心特性

即時演示

實際使用效果

就緒

安裝

選擇你的客戶端

~/Library/Application Support/Claude/claude_desktop_config.json  · Windows: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "dotnet-skills-aaronontheweb": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/Aaronontheweb/dotnet-skills",
        "~/.claude/skills/dotnet"
      ],
      "_inferred": true
    }
  }
}

開啟 Claude Desktop → Settings → Developer → Edit Config。儲存後重啟應用。

~/.cursor/mcp.json · .cursor/mcp.json
{
  "mcpServers": {
    "dotnet-skills-aaronontheweb": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/Aaronontheweb/dotnet-skills",
        "~/.claude/skills/dotnet"
      ],
      "_inferred": true
    }
  }
}

Cursor 使用與 Claude Desktop 相同的 mcpServers 格式。專案級設定優先於全域。

VS Code → Cline → MCP Servers → Edit
{
  "mcpServers": {
    "dotnet-skills-aaronontheweb": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/Aaronontheweb/dotnet-skills",
        "~/.claude/skills/dotnet"
      ],
      "_inferred": true
    }
  }
}

點擊 Cline 側欄中的 MCP Servers 圖示,然後選 "Edit Configuration"。

~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "dotnet-skills-aaronontheweb": {
      "command": "git",
      "args": [
        "clone",
        "https://github.com/Aaronontheweb/dotnet-skills",
        "~/.claude/skills/dotnet"
      ],
      "_inferred": true
    }
  }
}

格式與 Claude Desktop 相同。重啟 Windsurf 生效。

~/.continue/config.json
{
  "mcpServers": [
    {
      "name": "dotnet-skills-aaronontheweb",
      "command": "git",
      "args": [
        "clone",
        "https://github.com/Aaronontheweb/dotnet-skills",
        "~/.claude/skills/dotnet"
      ]
    }
  ]
}

Continue 使用伺服器物件陣列,而非映射。

~/.config/zed/settings.json
{
  "context_servers": {
    "dotnet-skills-aaronontheweb": {
      "command": {
        "path": "git",
        "args": [
          "clone",
          "https://github.com/Aaronontheweb/dotnet-skills",
          "~/.claude/skills/dotnet"
        ]
      }
    }
  }
}

加入 context_servers。Zed 儲存後熱重載。

claude mcp add dotnet-skills-aaronontheweb -- git clone https://github.com/Aaronontheweb/dotnet-skills ~/.claude/skills/dotnet

一行命令搞定。用 claude mcp list 驗證,claude mcp remove 移除。

使用場景

實戰用法: .NET Skills

稽核 Service 的 async/await 正確性

👤 後端 .NET 團隊 ⏱ ~45 min advanced

何時使用: 你接手了一個偶爾發生死鎖的 Service,懷疑是 async 問題。

前置條件
  • 已安裝 Skill — git clone https://github.com/Aaronontheweb/dotnet-skills ~/.claude/skills/dotnet
步驟
  1. 掃描
    dotnet-skills async 稽核 src/。標記:函式庫中缺少 ConfigureAwait(false)、.Result/.Wait、async void(非事件處理器)、缺少 CancellationToken 傳播。✓ 已複製
    → 附有嚴重程度的具體 file:line 清單
  2. 修復一個叢集
    選取最高嚴重程度的叢集(死鎖風險)。逐檔案提議修補程式。顯示差異。✓ 已複製
    → 手術式修補,而非整個檔案重寫

結果: Async 衛生得到改善;一個偶發性死鎖的根源已消除。

注意事項
  • ConfigureAwait 修復破壞了 UI 執行緒程式碼 — Skill 區分函式庫與應用程式程式碼;遵守這個邊界
搭配使用: filesystem

使用 BenchmarkDotNet 對熱路徑進行基準測試

👤 注重效能的 .NET 開發者 ⏱ ~60 min advanced

何時使用: 性能分析器指向某個方法;你需要嚴格的數字。

步驟
  1. 建立基準測試架構
    Skill:為 OrderCalc.Compute 建立 BenchmarkDotNet 專案。多個輸入大小。開啟 Memory diagnoser。Markdown 匯出器。✓ 已複製
    → 基準測試專案可編譯;在 Release 下執行
  2. 執行 + 解讀
    執行基準測試。回報平均值、已分配記憶體、gen0。主要的記憶體分配在哪裡?✓ 已複製
    → 具體歸因到分配者(可能是字串串接或 LINQ)
  3. 修補 + 重新測試
    用手動迴圈替換 LINQ。重新執行。顯示改前/改後。✓ 已複製
    → 記憶體分配可量測地下降

結果: 量化的效能改善,而非憑感覺。

注意事項
  • 執行 Debug 建置 — BenchmarkDotNet 拒絕 Debug;確保使用 Release

為 NuGet 發佈準備函式庫

👤 OSS 作者 ⏱ ~30 min intermediate

何時使用: 你的函式庫第一次 NuGet 發佈;你想讓它精緻。

步驟
  1. 稽核套件設定
    dotnet-skills:稽核 MyLib.csproj 的 NuGet 就緒狀態。檢查 Description、Authors、License、RepositoryUrl、source-link、多目標。✓ 已複製
    → 具體的缺少欄位清單
  2. API 介面審查
    生成公開 API 介面;標記任何洩漏的內部類型或命名奇怪的公開成員。✓ 已複製
    → 帶有注意事項的 API 介面傾印

結果: 乾淨的套件,準備好推送發佈。

注意事項
  • 授權不一致(LICENSE 檔案對 <PackageLicenseExpression>) — Skill 會抓到這個;讓它們一致

組合

與其他 MCP 搭配,撬動十倍槓桿

dotnet-skills-aaronontheweb + filesystem

跨專案套用修補程式

跨 src/ 套用 async_audit 修補程式。每個檔案一次 commit。✓ 已複製
dotnet-skills-aaronontheweb + github

PR 基準測試結果

開一個帶有效能修補程式以及在說明中的改前/改後基準測試數字的 PR。✓ 已複製

工具

此 MCP 暴露的能力

工具輸入參數何時呼叫成本
async_audit path 程式碼庫健康檢查 0
scaffold_benchmark target_method 效能工作 0
interpret_bench bench_md 執行基準測試後 0
nuget_audit csproj 發佈前 0
api_surface assembly_or_proj API 審查 0
test_conventions_check test_path PR 審查 0

成本與限制

運行它的成本

API 配額
N/A
每次呼叫 Token 數
稽核會掃描程式碼 = token 消耗較大;每次 5k–30k
費用
免費
提示
一次稽核一個專案;不要同時對整個 monorepo 進行扇出

安全

權限、密鑰、影響範圍

最小權限: filesystem-read filesystem-write
憑證儲存:
資料出站:

故障排查

常見錯誤與修復

稽核結果太嘈雜

指定嚴重程度閾值;Skill 預設顯示全部

基準測試無法執行

必須是 Release 建置;BenchmarkDotNet 拒絕 Debug

驗證: dotnet build -c Release
API 介面包含內部類型

確保 InternalsVisibleTo 設定正確;Skill 依配置回報

替代方案

.NET Skills 對比其他方案

替代方案何時用它替代權衡
倉庫中的 Roslyn 分析器你想要 CI 時強制執行設定較多;互動性較低
ReSharper / Rider你想要 IDE 時修復付費;非 LLM 驅動
Aspire / .NET Cloud Native skills雲端原生焦點不同範圍

更多

資源

📖 閱讀 GitHub 上的官方 README

🐙 查看未解決的 issue

🔍 瀏覽全部 400+ MCP 伺服器和 Skills