skills/generate-editorconfig-by-techstack/SKILL.md
依專案技術棧與 .NET 框架版本,從範本過濾出對應的 .editorconfig 段落並補齊,保留既有自訂偏好。
npx skillsauth add CloudyWing/ai-dotfiles generate-editorconfig-by-techstackInstall 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.
本 Skill 的規則內容以 ~/.ai-agents/templates/.editorconfig 為單一來源。修改建議規則時,只改範本檔,不改 SKILL.md。SKILL.md 僅描述執行流程與過濾邏輯。
範本檔位於使用者家目錄下的 .ai-agents/ 專案。執行時若找不到範本檔,告知使用者後流程終止,不自行重建內容。
範本含 # @profile: <name> 段落標記,由本 Skill 依技術棧過濾:
| Profile | 適用情境 | 過濾規則 |
| --- | --- | --- |
| 未標記 | 所有技術棧通用 | 一律保留 |
| csharp-modern | C# 8+ / .NET Core / .NET 5+ | <TargetFramework> 為 net5+ / netcoreapp* / net8.0-* 等現代框架時保留;net4x 時整段移除 |
| dotnet-framework | .NET Framework 4.x | <TargetFramework> 為 net4x 時保留;現代 .NET 時整段移除 |
非 .NET 技術棧執行時,所有 .NET / C# 相關段落(含未標記的 [*.{cs,vb}]、[*.cs] 與兩個 profile 段)一律跳過。
掃描專案根目錄:
| 偵測依據 | 識別結果 |
| --- | --- |
| *.csproj、*.sln、*.slnx | C# / .NET 專案 |
| package.json | Node.js / 前端 |
| *.py、pyproject.toml | Python |
| go.mod | Go |
| Dockerfile | Docker |
| *.ps1 | PowerShell |
偵測到 .NET 專案時,必須進一步讀取 *.csproj 的 <TargetFramework> 或 <TargetFrameworks> 欄位,判定屬於:
net4x,如 net472、net48)→ 套用 dotnet-framework profilenet5.0 以上、netcoreapp*、net8.0-windows 等)→ 套用 csharp-modern profile<TargetFrameworks> 同時含 Framework 與 Modern)→ 兩個 profile 都套用,由 IDE 依檔案副檔名與 pattern 解析若 solution 內多個專案目標框架不一致,以最舊的為準(最保守,避免新設定漏給舊專案)。
讀取 ~/.ai-agents/templates/.editorconfig,解析三類段落:
[*]、[*.md]、[*.{json,...}]、[*.py]、[*.ps1]、[*.{csv,bat,cmd}]、[*.{cs,vb}]、[*.cs](不含 # @profile 標記)csharp-modern 段落:標記 # @profile: csharp-modern 之後到下一個 # @profile 或檔尾之間的所有段落dotnet-framework 段落:標記 # @profile: dotnet-framework 之後到下一個 # @profile 或檔尾之間的所有段落依步驟 1 的偵測結果,組合最終輸出:
| 偵測結果 | 套用的範本段落 |
| --- | --- |
| 純 .NET Framework | 通用段落 + dotnet-framework,移除所有 .NET 相關段落以外的非 .NET 技術段(若專案無 Python / Go 等) |
| 純 Modern .NET | 通用段落 + csharp-modern |
| 多目標 .NET | 通用段落 + csharp-modern + dotnet-framework |
| 非 .NET 技術棧 | 通用段落,但移除 [*.{cs,vb}] 與 [*.cs](純 C# 設定對非 .NET 專案無用) |
| 混合 .NET + 其他 | 通用段落 + 對應 .NET profile |
非 .NET 通用段落([*.py]、[*.ps1] 等)即使該專案無此檔案類型也保留,因為 glob filter 不會誤套用,且未來新增該類型檔案時可直接生效。
若 .editorconfig 已存在:
indent_size、end_of_line 等)。若不存在,後續步驟以步驟 3 的過濾結果建立全新檔案。
若已存在 .editorconfig,比對現有設定鍵與本次過濾後內容的差異:
indent_size = 2,範本為 4)。特別注意以下既有設定不可靜默覆蓋:
[*.{cs,vb,aspx,master}] charset 設定(與 BOM 策略相關,必須確認)。dotnet_diagnostic.*.severity(影響建置警告等級)。dotnet_naming_*)。若無衝突,直接進入步驟 6。
顯示完整的 .editorconfig 預覽內容(或僅顯示新增/修改的段落),停止等待使用者確認後再執行寫入。確認格式:
偵測技術棧:[結果]
套用 Profile:[結果]
以下是將要寫入的 .editorconfig 內容(新增段落):
[*]
charset = utf-8
...
確認後將寫入,請回覆「確認」。
若使用者要求調整,修改後重新顯示確認。
已存在 .editorconfig:使用 Merge 模式,將缺少的段落或設定鍵插入對應位置,不移動或覆蓋已有內容。寫入時必須移除所有 # @profile: ... 標記行(標記僅供範本與 skill 過濾使用,不應出現在最終專案檔案中)。
不存在 .editorconfig:依步驟 3 的過濾結果建立新檔,同樣移除 # @profile 標記。
輸出:
<TargetFramework>。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、筆數核對與抽樣比對降低整合錯誤。