/ 目录 / 演练场 / .NET Skills
● 社区 Aaronontheweb ⚡ 即开即用

.NET Skills

作者 Aaronontheweb · Aaronontheweb/dotnet-skills

Claude 中地道的 .NET 8/9 写法——包含 xUnit 测试、BenchmarkDotNet 性能、NuGet 打包、async/await 正确性和 C# 代码风格。

Aaron Stannard 的 .NET Skills 是面向严肃 .NET 开发者的成熟工具集。超越简单的代码生成,覆盖模型经常写错的那些细节:async 取消、ConfigureAwait 用法、IDisposable、struct vs 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

审计一个服务的 async/await 正确性

👤 .NET 后端团队 ⏱ ~45 min advanced

何时使用: 你接手了一个间歇性死锁的服务,怀疑是 async 问题。

前置条件
  • 已安装 skill — git clone https://github.com/Aaronontheweb/dotnet-skills ~/.claude/skills/dotnet
步骤
  1. 扫描
    dotnet-skills 对 src/ 执行 async 审计,标记:库代码中缺少 ConfigureAwait(false)、.Result/.Wait 调用、async void(非事件)、缺少 CancellationToken 传播。✓ 已复制
    → 具体的 file:line 列表,附严重性
  2. 修复一批
    选出最高严重性的问题集群(死锁风险)。逐文件提出修复方案,展示 diff。✓ 已复制
    → 外科式补丁,不是整文件重写

结果: async 卫生度提升;一个间歇性死锁根源消除。

注意事项
  • ConfigureAwait 修复破坏了 UI 线程代码 — skill 区分库代码和应用代码;遵守这条边界
搭配使用: filesystem

用 BenchmarkDotNet 对热路径进行基准测试

👤 关注性能的 .NET 开发者 ⏱ ~60 min advanced

何时使用: Profiler 指向某个方法,你需要严格的数据。

步骤
  1. 搭建基准项目
    Skill:为 OrderCalc.Compute 搭建 BenchmarkDotNet 项目,多个输入大小,开启 Memory Diagnoser,开启 Markdown 导出器。✓ 已复制
    → 基准项目编译通过;在 Release 模式下可运行
  2. 运行并解读
    运行基准测试,报告 mean、allocated、gen0,主要分配在哪里?✓ 已复制
    → 具体归因到分配者(通常是字符串拼接或 LINQ)
  3. 修复并重测
    用手写循环替换 LINQ,重新运行,展示修改前后对比。✓ 已复制
    → 分配量可量化地下降

结果: 量化的性能提升,而不是凭感觉。

注意事项
  • 在 Debug 模式下运行 — BenchmarkDotNet 拒绝 Debug 构建;确保 Release

准备将库发布到 NuGet

👤 开源库作者 ⏱ ~30 min intermediate

何时使用: 第一次 NuGet 发布,你想让它看起来专业。

步骤
  1. 审计打包配置
    dotnet-skills:审计 MyLib.csproj 的 NuGet 就绪度,检查 Description、Authors、License、RepositoryUrl、source-link、多目标。✓ 已复制
    → 具体缺失字段列表
  2. API 面审查
    生成公开 API 面;标记任何泄漏的 internal 类型或命名奇怪的 public 成员。✓ 已复制
    → API 面清单,附关注点

结果: 干净的包,可以直接推送。

注意事项
  • license 不一致(LICENSE 文件与 <PackageLicenseExpression> 不匹配) — skill 会捕获到;对齐两者

组合

与其他 MCP 搭配,撬动十倍杠杆

dotnet-skills-aaronontheweb + filesystem

在项目中应用补丁

对 src/ 应用 async_audit 补丁,每个文件一次提交。✓ 已复制
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 配额
不适用
每次调用 Token 数
审计需要扫描代码,token 用量较大;每次 5k–30k
费用
免费
提示
每次审计一个项目;不要在 monorepo 上一次性扇出

安全

权限、密钥、影响范围

最小权限: filesystem-read filesystem-write
凭据存储:
数据出站:

故障排查

常见错误与修复

审计结果太多

指定严重性阈值;skill 默认显示全部

基准测试无法运行

必须是 Release 构建;BenchmarkDotNet 拒绝 Debug

验证: dotnet build -c Release
API 面包含 internal 类型

确认 InternalsVisibleTo 设置正确;skill 按实际配置报告

替代方案

.NET Skills 对比其他方案

替代方案何时用它替代权衡
仓库中的 Roslyn 分析器你想在 CI 时强制执行更多配置;不是交互式的
ReSharper / Rider你想在 IDE 中即时修复付费;非 LLM 驱动
Aspire / .NET Cloud Native skills聚焦云原生不同范围

更多

资源

📖 阅读 GitHub 上的官方 README

🐙 查看未解决的 issue

🔍 浏览全部 400+ MCP 服务器和 Skills