skills/generate-api-doc/SKILL.md
為 ASP.NET Core Controller 或 Minimal API 自動補齊 XML 文件與 Swagger Attributes,讓 OpenAPI 文件完整呈現。
npx skillsauth add CloudyWing/ai-dotfiles generate-api-docInstall 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.
為指定的 ASP.NET Core Controller 或 Minimal API 端點補齊 XML 文件註解與 Swagger Attributes。
/generate-api-doc [Controller 檔案路徑或類別名稱]
若未傳入參數,掃描當前專案中所有 *Controller.cs 檔案,列出清單供使用者選擇。
讀取指定的 Controller 或 Minimal API 端點定義,識別:
[HttpGet]、[Route] 等)依 csharp-docs skill 規範,為每個 Public 方法補齊:
/// <summary>
/// [動詞開頭的第三人稱現在式說明,描述 What 與 Why]
/// </summary>
/// <param name="[paramName]">[參數說明]</param>
/// <returns>[回傳值說明]</returns>
規則:
<summary> 以第三人稱現在式動詞開頭(Gets、Creates、Updates、Deletes、Processes)。<inheritdoc />,保留不覆蓋。依 HTTP 方法與回傳型別判斷要加入的 Attributes:
[ProducesResponseType(typeof(ResponseDto), StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
判斷規則:
void 或 IActionResult 且邏輯無回傳體時。[FromBody] 或 [FromQuery] 參數時,且無 [ApiController] 自動驗證(或明確使用 ModelState.IsValid)時補加。[Authorize] 時補加。[Authorize(Roles = ...)] 或 Policy 授權時補加。NotFound() 呼叫時補加。若 Controller 層級已有 [Produces] 或 [ProducesResponseType],不重複在 Action 層級加入。
若 Action 方法尚無 [EndpointSummary](Minimal API)或 XML <summary> 已覆蓋 Swagger 顯示,則不額外加入。
Controller API 的 Swagger 摘要來自 XML <summary>,確保存在即可。
在實際寫入檔案前,以下列格式向使用者顯示完整修改預覽:
// [方法名稱] — 將新增以下內容:
/// <summary>
/// [說明]
/// </summary>
[ProducesResponseType(typeof(ResponseDto), StatusCodes.Status200OK)]
顯示完整預覽後,停止等待使用者確認(回覆「確認」或「OK」後)才繼續執行步驟 6。若使用者要求調整,依其指示修改預覽內容後再次確認。
直接修改原始檔案。完成後輸出摘要:
## 修改摘要:OrderController.cs
| 方法 | 補齊 XML 文件 | 補齊 Attributes |
| --- | --- | --- |
| GetById | ✅ | ✅ 200、404 |
| Create | ⏭️ 已存在 | ✅ 201、400、422 |
| Delete | ✅ | ✅ 204、404 |
.editorconfig 與 csharp-style skill 的風格規範。Swashbuckle.AspNetCore 以外的 OpenAPI 套件,輸出前確認 Attribute 名稱是否相容。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.
data-ai
多份資料檔整合流程。當需要將兩份以上的資料檔(如 JSON、CSV)合併、補齊闕漏欄位或去重成單一檔案時使用。以 dry-run、筆數核對與抽樣比對降低整合錯誤。