SKILL.md
唯讀
名稱
commit-helper
描述
協助遵循 Conventional Commits 規範撰寫 Git commit 訊息。當使用者要求提交變更、撰寫 commit 訊息、格式化 commit 或提到 git commit 時,請使用此 Skill。
Commit 訊息小幫手
這是一個用於建立符合 Conventional Commits 規範且格式正確的 Git commit 訊息 Skill。
何時觸發此 Skill
當您進行以下操作時將觸發此 Skill:
- 要求提交變更
- 提及 commit 訊息
- 請求格式化 git commit
- 說出「commit」或「git commit」
Commit 訊息格式
<type>(<scope>): <subject>
<body>
<footer>
類型 (Types)
| 類型 | 說明 |
|---|---|
feat |
新功能 |
fix |
修復 Bug |
docs |
僅包含文件變更 |
style |
不影響程式碼本意與邏輯的變更(排版、格式化等) |
refactor |
既不修復 Bug 也不新增功能的程式碼重構 |
perf |
提升效能的程式碼變更 |
test |
新增缺失的測試或修正現有測試 |
chore |
對建置流程或輔助工具的變更 |
ci |
對 CI 設定檔與腳本的變更 |
build |
影響建置系統或外部依賴項的變更 |
範圍 (Scope)
範圍應標明受影響的程式碼庫區域:
- 前端:
components、hooks、store、styles、utils - 後端:
api、models、services、database、auth - 開發營運 (DevOps):
ci、deploy、docker - 專案自訂的專屬範圍亦可接受
撰寫準則
標題列 (Subject)
- 使用祈使句(例如「add feature」,而非「added feature」或「adds feature」)
- 結尾請勿加上句號
- 最多 50 個字元
- 保持具體且精簡
內文 (Body)
- 標題與內文之間請留一行空白行
- 使用內文解釋做了什麼以及為什麼要這樣做,而非怎麼做的
- 每行上限為 72 個字元,請適當換行
- 註明任何破壞性變更 (Breaking changes)
註腳 (Footer)
- 參照 Issue:
Closes #123、Fixes #456、Refs #789 - 多個 Issue:
Closes #123, #456, #789 - 破壞性變更:以
BREAKING CHANGE:開頭,後跟詳細說明
範例
良好的範例
feat(auth): add OAuth2 login support
Implement OAuth2 authentication flow to allow users to log in
with their Google or GitHub accounts.
This change adds:
- New OAuth2 middleware for handling callbacks
- Updated login UI with social login buttons
- User profile synchronization
Closes #123
fix(api): resolve race condition in user creation
The concurrent user creation requests could result in duplicate
email entries. Added unique constraint and proper error handling.
Fixes #456
refactor(user): simplify profile update logic
Extracted common validation logic into a reusable function
to reduce code duplication across profile update endpoints.
docs: update API documentation with new endpoints
Added documentation for the v2 user management endpoints
including request/response examples and error codes.
不良的範例
updated stuff # 太過模糊,缺少 type/scope
fixed bug # 缺乏關於修復了哪個 bug 的上下文
feat: added feature # 語意贅述(「feat」已代表新功能)
Feat(User): Add Login # 大小寫不正確
feat: A really really really long subject line that exceeds the recommended limit # 標題太長
破壞性變更 (Breaking Changes)
當引入破壞性變更時,請在註腳加入 BREAKING CHANGE::
feat(api): migrate to REST v2
The API endpoints have been restructured for better consistency.
Old endpoints are deprecated and will be removed in v3.0.
BREAKING CHANGE: `/api/v1/users` is now `/api/v2/users`.
All consumers must update their integration by 2025-03-01.
工作流程
撰寫 commit 訊息時的步驟:
- 檢視變更 - 執行
git diff以瞭解變更內容 - 確認類型 - 確定變更的 type
- 確認範圍 - 確定受影響的 scope
- 撰寫標題 - 建立清晰且精簡的 subject 行
- 撰寫內文 - 解釋內容與原因(如有需要)
- 新增註腳 - 參照 Issue 或註記破壞性變更
驗證
使用驗證腳本檢查 commit 訊息格式:
python3 scripts/validate_commit.py "feat(scope): add behavior"
參考文件
- 完整規範請參閱
references/conventional-commits.md - 更多範例請參閱
references/examples.md - 建議的範圍命名請參閱
references/scopes.md






