Gitmoji + Conventional Commits
請生成嚴格遵循 Conventional Commits(commitlint config-conventional)且以 Gitmoji 短碼為前綴的提交訊息。這些規則很嚴格:請精確遵守,不要自行發明其他格式,並且只輸出提交訊息本身——不要有任何開場白、解釋或周邊註解。當要呈現訊息給使用者複製時,可以使用圍欄式程式碼區塊;當要直接提交時,直接傳入訊息即可。
工作流程
當被要求生成提交時:
- 確定實際改變的內容——從暫存區的 diff、已修改的檔案或使用者的描述中判斷。不要猜測;如果變更不明確且你可以檢查,請先檢查。
- 選擇最恰當的單一 Gitmoji 及其對應的
type。一次提交 = 一個邏輯變更 = 一個 gitmoji。 - 在長度限制內撰寫標題(第 1 行)。
- 只有當正文能提供真正有用的資訊時才加入正文;只有在有破壞性變更或 issue 參考時才加入頁尾。
- 輸出訊息,除此之外不要有其他內容。
格式
<emoji_shortcode> <type>(<scope>): <subject>
<body>
<footer>
標題規則(第 1 行)
- 以 Gitmoji 短碼開頭,例如
:sparkles:(採用 literal:colon:形式,不是 Unicode 表情符號 ✨),後接一個空格。 - 然後是
type(scope): subject。 - 總長度 ≤ 72 個字元。
- 主詞使用祈使語氣、小寫、結尾無句號。
- scope 為選填;只在能清楚識別受影響區域(資料夾、模組、功能)時使用。
- 對於破壞性變更,在 scope 或 type 後加上
!:type(scope)!: subject。
允許的 type(commitlint config-conventional)
feat、fix、docs、style、refactor、perf、test、build、ci、chore、revert
Gitmoji 與 type 的對應(選擇最恰當的)
| 短碼 | 類型 | 用途 |
|---|---|---|
:sparkles: | feat | 新功能 |
:bug: | fix | 錯誤修正 |
:ambulance: | fix | 緊急修補 |
:adhesive_bandage: | fix | 小修正 |
:memo: | docs | 文件 |
:lipstick: | style | UI / CSS |
:art: | style | 程式碼結構 / 格式 |
:recycle: | refactor | 重構 |
:zap: | perf | 效能 |
:white_check_mark: | test | 新增/更新測試 |
:test_tube: | test | 失敗的測試 |
:heavy_plus_sign: | build | 新增依賴 |
:heavy_minus_sign: | build | 移除依賴 |
:arrow_up: | build | 升級依賴 |
:arrow_down: | build | 降級依賴 |
:wrench: | chore | 設定檔 |
:hammer: | chore | 開發腳本 |
:construction_worker: | ci | CI |
:green_heart: | ci | 修復 CI |
:rewind: | revert | 還原 |
:fire: | chore | 移除程式碼/檔案 |
:truck: | refactor | 重新命名或移動檔案 |
:rotating_light: | fix | Linter 警告 |
:lock: | fix | 安全性 |
:boom: | feat 或 refactor | 破壞性變更 |
:bookmark: | chore | 發佈 / 版本標籤 |
:rocket: | chore | 部署相關 |
正文規則(選填,標題後空一行)
- 說明做了什麼與為什麼,絕對不要說明如何做。
- 使用簡短段落提供背景脈絡,若有多項具體變更則使用項目符號列表。
- 每行長度限制 72 個字元。
- 使用祈使語氣,與主詞相同。
頁尾規則(選填,正文後空一行)
BREAKING CHANGE: <description>用於破壞性變更。Closes #<issue>或Refs #<issue>用於 issue 連結。
風格
- 使用祈使語氣(「add」,不是「added」/「adds」)。
- 簡潔、具體、不廢話——禁止寫「fix bug」;要寫明修正了哪個 bug。
- 使用英文,主詞小寫。
- 標題 / 正文 / 頁尾之間空一行。
- 永遠不要包含 AI 署名行、簽名、共同作者尾綴或尾隨註解。
不確定的時候
- 若有多個 type 符合,選擇對使用者最明顯的:
feat>fix>refactor>chore。 - 若 scope 不明確,省略它,不要猜測。
- 若正文沒有提供有意義的資訊,省略它。
- 永遠不要自行編造 issue 編號或共同作者。
範例
範例 1 — 功能加上正文與變更列表:
:sparkles: feat(auth): add oauth2 login flow
Implement Google and GitHub providers with refresh token rotation.
- add /auth/google and /auth/github routes
- store tokens in httpOnly cookies
- update User model with provider field
範例 2 — 錯誤修正加上 issue 連結:
:bug: fix(api): handle empty payload in webhook handler
Return 400 instead of crashing when webhook body is empty.
Closes #142
範例 3 — 僅有標題的依賴升級:
:arrow_up: build(deps): upgrade pillow to 11.0.0
範例 4 — 破壞性變更:
:boom: feat(api)!: rename user.email to user.primaryEmail
BREAKING CHANGE: clients must use primaryEmail. The old email field
is no longer returned by /v1/users endpoints.