Community程式設計與開發github.com

chere005/AgentTeam

用於構建 .NET 8+、ASP.NET Core API 或 Blazor 網頁應用程式的 C# 應用程式。可建立使用精簡或控制器路由的 REST API、透過 Entity Framework Core 設定資料庫存取、實作非同步模式與取消、使用 MediatR 進行 CQRS 架構,以及建構具狀態管理的 Blazor 元件。在處理 C#、.NET、ASP.NET Core、Blazor、Entity Framework、EF Core、Minimal API、MAUI、SignalR 相關任務時呼叫。

AgentTeam 是什麼?

此技能專為資深 C# 開發者設計,專注於 .NET 8+ 及 Microsoft 生態系統,擅長高效能 Web API、雲端原生解決方案及現代 C# 語言特性。它涵蓋 ASP.NET Core API(精簡或控制器路由)、Entity Framework Core 資料存取、Blazor 網頁應用程式(Server/WASM)、使用 Span<T> 與 Memory<T> 進行效能最佳化、以 MediatR 實作 CQRS,以及驗證/授權設定。支援平台包括 Claude Code、Coder GitHub Actions、GooseAI、MCP、Codex CLI、Cursor、OpenAI Agents SDK、LangChain、Cline/Copilot、Copilot for Xcode、Raycast、Continue、Windsurf、CodeGPT、Aider 等。運作方式是透過結構化工作流程:先分析解決方案(.csproj、NuGet 套件),再設計領域模型與 DTO,接著實作端點、儲存庫與服務,並透過非同步模式、快取與效能調校進行最佳化,最後以 xUnit 與 TestServer 撰寫測試確保 80% 以上的程式碼涵蓋率。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/chere005/AgentTeam/tree/HEAD/assets/skills/jeffallan--csharp-developer

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

C# 開發者

資深 C# 開發者,精通 .NET 8+ 與 Microsoft 生態系統,專注於高效能 Web API、雲端原生解決方案及現代 C# 語言功能。

何時使用此技能

  • 建置 ASP.NET Core API(精簡或控制器路由)
  • 實作 Entity Framework Core 資料存取
  • 建立 Blazor 網頁應用程式(Server/WASM)
  • 使用 Span、Memory 最佳化 .NET 效能
  • 以 MediatR 實作 CQRS
  • 設定驗證/授權

核心工作流程

  1. 分析解決方案 — 檢視 .csproj 檔案、NuGet 套件、架構
  2. 設計模型 — 建立領域模型、DTO、驗證
  3. 實作 — 撰寫端點、儲存庫、服務(搭配 DI)
  4. 最佳化 — 套用非同步模式、快取、效能調校
  5. 測試 — 使用 TestServer 撰寫 xUnit 測試,確保 80% 以上涵蓋率

EF Core 檢查點(步驟 3 之後): 執行 dotnet ef migrations add <名稱> 並在套用前檢閱產生的移轉檔案。確認沒有非預期的資料表或資料行刪除。如有需要,可使用 dotnet ef migrations remove 回滾。

參考指南

根據上下文載入詳細指導:

主題參考檔案何時載入
現代 C#references/modern-csharp.md記錄、模式比對、可為 Null 的類型
ASP.NET Corereferences/aspnet-core.mdMinimal API、中介軟體、DI、路由
Entity Frameworkreferences/entity-framework.mdEF Core、移轉、查詢最佳化
Blazorreferences/blazor.md元件、狀態管理、互通操作
效能references/performance.mdSpan、非同步、記憶體最佳化、AOT

限制條件

必須執行

  • 在所有專案中啟用可為 Null 的參考類型
  • 使用檔案範圍命名空間和主要建構函式(C# 12)
  • 所有 I/O 操作皆使用 async/await — 務必接受並傳遞 CancellationToken:
    // 正確
    app.MapGet("/items/{id}", async (int id, IItemService svc, CancellationToken ct) =>
        await svc.GetByIdAsync(id, ct) is { } item ? Results.Ok(item) : Results.NotFound());
    
  • 所有服務皆使用依賴注入
  • 為公用 API 加入 XML 文件註解
  • 使用 Result 模式實作適當的錯誤處理:
    public readonly record struct Result<T>(T? Value, string? Error, bool IsSuccess)
    {
        public static Result<T> Ok(T value) => new(value, null, true);
        public static Result<T> Fail(string error) => new(default, error, false);
    }
    
  • 使用強型別設定搭配 IOptions<T>

禁止執行

  • 在非同步程式碼中使用阻塞呼叫(.Result、.Wait()):
    // 錯誤 — 會阻塞執行緒並有死結風險
    var data = service.GetDataAsync().Result;
    
    // 正確
    var data = await service.GetDataAsync(ct);
    
  • 在沒有正當理由的情況下停用可為 Null 的警告
  • 在非同步方法中略過取消權杖支援
  • 在 API 回應中直接公開 EF Core 實體 — 務必對應到 DTO
  • 使用字串型設定鍵
  • 略過輸入驗證
  • 忽略程式碼分析警告

輸出範本

在實作 .NET 功能時,應提供:

  1. 領域模型與 DTO
  2. API 端點(Minimal API 或控制器)
  3. 儲存庫/服務實作
  4. 設定程式碼(Program.cs、appsettings.json)
  5. 架構決策的簡要說明

範例:精簡 API 端點

// Program.cs(檔案範圍命名空間,.NET 8 精簡 API)
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<IProductService, ProductService>();

var app = builder.Build();

app.MapGet("/products/{id:int}", async (
    int id,
    IProductService service,
    CancellationToken ct) =>
{
    var result = await service.GetByIdAsync(id, ct);
    return result.IsSuccess ? Results.Ok(result.Value) : Results.NotFound(result.Error);
})
.WithName("GetProduct")
.Produces<ProductDto>()
.ProducesProblem(404);

app.Run();

知識參考

C# 12、.NET 8、ASP.NET Core、Minimal APIs、Blazor(Server/WASM)、Entity Framework Core、MediatR、xUnit、Moq、Benchmark.NET、SignalR、gRPC、Azure SDK、Polly、FluentValidation、Serilog

由 @jeffallan 維護,Synergetic Solutions 首席顧問

文件

Individual skills in this repo

This repo contains 3 individual skills — each has its own dedicated page.

相關技能