skills/csharp-async/SKILL.md
C# 非同步設計最佳實踐:強制套用 Task/ValueTask 與 ConfigureAwait 等非同步開發規範。
npx skillsauth add CloudyWing/ai-dotfiles csharp-asyncInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
當使用者要求撰寫或重構 C# 非同步 (Asynchronous) 程式碼時,請自動套用以下準則。底線規則(Task/Task<T> 回傳型別、ConfigureAwait(false)、禁止 .Result/.Wait())由全域規範管理,本 Skill 僅涵蓋延伸最佳實踐。
Async 後綴。GetDataAsync() 對應 GetData())。async void 例外:僅事件處理函式允許使用,其他情境一律使用 Task。ValueTask<T>:高頻或效能敏感場景中,為減少記憶體配置可考慮使用,但不作為預設選型。await 運算式包裝在 try/catch 區塊中,確保例外正確傳播,避免靜默吞噬。Task 但不使用 async 關鍵字,以 Task.FromException() 傳遞例外,不使用 throw。Task.WhenAll() 併發執行多個不相依的工作。Task.WhenAny() 處理逾時機制或取得第一個完成的工作。return DoSomethingAsync();),不加 async/await。CancellationToken。await 或妥善處置,不得靜默丟棄。tools
PowerShell 腳本撰寫規範:嚴格模式、錯誤處理、參數宣告、Verb-Noun 命名與 5.1 相容語法邊界。當撰寫或修改 `*.ps1` / `*.psm1` 腳本時自動套用。
tools
產生或補齊 .gitattributes,統一行尾處理、二進位識別與 lock files 標記,保留既有自訂偏好。
development
產生或補齊前端 Lint 設定(Prettier + ESLint Flat Config),統一格式化與程式碼品質規則,保留既有自訂偏好。
testing
依據事實校閱報告修改技術文件:以事實層為不可違反的約束,由改檔者負責表達層的措辭與行文連貫。Use when the user asks to apply fact-check results to a document, or to edit a document based on a previously produced fact-check-report.md.