--- name: skill-create description: 分析本地 Git 歷史紀錄以擷取開發模式,並生成 SKILL.md 檔案。此為 Skill Creator GitHub App 的本地版本。 allowed_tools: ["Bash", "Read", "Write", "Grep", "Glob"] --- # /skill-create - 本地技能生成 分析儲存庫的 Git 歷史紀錄,以擷取程式碼開發模式並生成 SKILL.md 檔案,用來教導 Claude 熟悉您團隊的開發實踐。 ## 使用方式 ```bash /skill-create # 分析目前的儲存庫 /skill-create --commits 100 # 分析最近 100 次提交 (Commits) /skill-create --output ./skills # 指定輸出目錄 /skill-create --instincts # 同時為 continuous-learning-v2 生成直覺 (Instincts) ``` ## 功能說明 1. **解析 Git 歷史** - 分析提交、檔案變動與模式。 2. **偵測開發模式** - 識別重複出現的工作流與慣例。 3. **生成 SKILL.md** - 建立有效的 Claude Code 技能檔案。 4. **選擇性建立直覺** - 用於 continuous-learning-v2 系統。 ## 分析步驟 ### 步驟 1:獲取 Git 數據 ```bash # 獲取最近的提交及其檔案變動 git log --oneline -n ${COMMITS:-200} --name-only --pretty=format:"%H|%s|%ad" --date=short # 按檔案統計提交頻率 git log --oneline -n 200 --name-only | grep -v "^$" | grep -v "^[a-f0-9]" | sort | uniq -c | sort -rn | head -20 # 獲取提交訊息模式 git log --oneline -n 200 | cut -d' ' -f2- | head -50 ``` ### 步驟 2:偵測模式 尋找以下類型的模式: | 模式 | 偵測方法 | |---------|-----------------| | **提交慣例** | 對提交訊息進行 Regex 匹配 (feat:, fix:, chore:) | | **檔案關聯變動** | 總是同時被修改的檔案群組 | | **工作流序列** | 重複出現的檔案修改模式 | | **架構慣例** | 資料夾結構與命名規範 | | **測試模式** | 測試檔案位置、命名、覆蓋率 | ### 步驟 3:生成 SKILL.md 輸出格式範例: ```markdown --- name: {repo-name}-patterns description: 從 {repo-name} 擷取的開發模式 version: 1.0.0 source: local-git-analysis analyzed_commits: {count} --- # {Repo Name} 開發模式 ## 提交慣例 {偵測到的提交訊息模式} ## 程式架構 {偵測到的資料夾結構與組織方式} ## 工作流 {偵測到的重複性檔案變動模式} ## 測試模式 {偵測到的測試慣例} ``` ### 步驟 4:生成直覺 (若包含 --instincts) 用於 continuous-learning-v2 整合: ```yaml --- id: {repo}-commit-convention trigger: "當撰寫提交訊息時" confidence: 0.8 domain: git source: local-repo-analysis --- # 使用約定式提交 (Conventional Commits) ## 行動 在提交訊息前加上:feat:, fix:, chore:, docs:, test:, refactor: ## 證據 - 分析了 {n} 次提交 - {percentage}% 遵循約定式提交格式 ``` ## 輸出範例 在 TypeScript 專案中執行 `/skill-create` 可能會產出: ```markdown --- name: my-app-patterns description: 來自 my-app 儲存庫的開發模式 version: 1.0.0 source: local-git-analysis analyzed_commits: 150 --- # My App 開發模式 ## 提交慣例 此專案使用 **約定式提交 (Conventional Commits)**: - `feat:` - 新功能 - `fix:` - 錯誤修復 - `chore:` - 維護任務 - `docs:` - 文件更新 ## 程式架構 ``` src/ ├── components/ # React 元件 (PascalCase.tsx) ├── hooks/ # 自定義 Hooks (use*.ts) ├── utils/ # 工具函式 ├── types/ # TypeScript 型別定義 └── services/ # API 與外部服務 ``` ## 工作流 ### 新增元件 1. 建立 `src/components/ComponentName.tsx` 2. 在 `src/components/__tests__/ComponentName.test.tsx` 加入測試 3. 從 `src/components/index.ts` 匯出 ### 資料庫遷移 1. 修改 `src/db/schema.ts` 2. 執行 `pnpm db:generate` 3. 執行 `pnpm db:migrate` ## 測試模式 - 測試檔案:`__tests__/` 目錄或 `.test.ts` 字尾 - 覆蓋率目標:80% 以上 - 框架:Vitest ``` ## GitHub App 整合 針對進階需求 (1 萬次以上提交、團隊共享、自動 PR),請使用 [Skill Creator GitHub App](https://github.com/apps/skill-creator): - 安裝連結:[github.com/apps/skill-creator](https://github.com/apps/skill-creator) - 在任何 Issue 中留言 `/skill-creator analyze` - 即可收到包含生成技能的 PR ## 相關指令 - `/instinct-import` - 匯入生成的直覺 - `/instinct-status` - 查看學到的直覺 - `/evolve` - 將直覺聚類為技能/Agent --- *屬於 [Everything Claude Code](https://github.com/affaan-m/everything-claude-code) 專案的一部分*