/cook-zh-tw:commit-messagefrom cook-zh-tw
Generates a git commit message from staged changes (git diff --staged) and copies it to the clipboard. Supports conventional, gitmoji, and angular formats, auto-detects project commitlint config and language, and detects breaking changes.
Claude never picks this command on its own
Its frontmatter has no description. Without a description, Claude Code leaves it out of the list Claude chooses from. Typing /cook-zh-tw:commit-message still runs it.
從暂存的更改 (git diff --staged) 生成合適的提交消息。仅生成消息並復制到剪贴板,不執行 git 命令。
/commit-message [選項]
--format <格式> : 指定消息格式 (conventional, gitmoji, angular)--lang <語言> : 強制指定消息語言 (en, zh-tw)--breaking : 檢測並記錄 Breaking Change# 從暂存的更改生成消息 (自動判定語言)
# 主要候選會自動復制到剪贴板
/commit-message
# 強制指定語言
/commit-message --lang zh-tw
/commit-message --lang en
# 檢測 Breaking Change
/commit-message --breaking
重要: 此命令仅分析暂存的更改。需要先使用 git add 暂存更改。
# 如果没有暂存更改,會顯示警告
$ /commit-message
没有暂存的更改。請先執行 git add。
生成的主要候選會以 git commit -m "消息" 的完整格式自動復制到剪贴板。可以直接在終端粘贴執行。
實現注意事項:
pbcopy 時,應與消息輸出分開執行printf 而不是 echo 以避免末尾換行重要: 如果存在項目特有的規範,將優先使用。
從以下文件自動檢測配置:
commitlint.config.jscommitlint.config.mjscommitlint.config.cjscommitlint.config.ts.commitlintrc.js.commitlintrc.json.commitlintrc.yml.commitlintrc.yamlpackage.json 的 commitlint 部分# 搜索配置文件
find . -name "commitlint.config.*" -o -name ".commitlintrc.*" | head -1
項目特有類型示例:
// commitlint.config.mjs
export default {
extends: ["@commitlint/config-conventional"],
rules: {
"type-enum": [
2,
"always",
[
"feat",
"fix",
"docs",
"style",
"refactor",
"test",
"chore",
"wip", // 進行中
"hotfix", // 紧急修復
"release", // 發布
"deps", // 依賴更新
"config", // 配置更改
],
],
},
};
// 項目使用繁体字中文消息時
export default {
rules: {
"subject-case": [0], // 為支持繁体字中文而禁用
"subject-max-length": [2, "always", 72], // 為繁体字中文調整字符數限制
},
};
# 從最近的提交學習使用模式
git log --oneline -50 --pretty=format:"%s"
# 使用類型統計
git log --oneline -100 --pretty=format:"%s" | \
grep -oE '^[a-z]+(\([^)]+\))?' | \
sort | uniq -c | sort -nr
根據以下條件自動切換繁体字中文/英文:
默認為英文。判定為繁体字中文項目時生成繁体字中文消息。
<type>: <description>
重要: 必须生成單行提交消息。不生成多行消息。
注意: 如果項目有特有規範,將優先使用。
必须類型:
feat: 新功能 (用戶可見的功能添加)fix: 缺陷修復可選類型:
build: 構建系統或外部依賴的更改chore: 其他更改 (不影響發布)ci: CI 配置文件或腳本的更改docs: 仅文檔更改style: 不影響代碼含義的更改 (空格、格式、分号等)refactor: 既不修復缺陷也不添加功能的代碼更改perf: 性能改進test: 添加或更正測試$ /commit-message
📝 提交消息建議
━━━━━━━━━━━━━━━━━━━━━━━━━
✨ 主要候選:
feat: implement JWT-based authentication system
📋 備選方案:
1. feat: add user authentication with JWT tokens
2. fix: resolve token validation error in auth middleware
3. refactor: extract auth logic into separate module
✅ `git commit -m "feat: implement JWT-based authentication system"` 已復制到剪贴板
實現示例 (更正版):
# 先將提交命令復制到剪贴板 (無換行)
printf 'git commit -m "%s"' "$COMMIT_MESSAGE" | pbcopy
# 然後顯示消息
cat << EOF
📝 提交消息建議
━━━━━━━━━━━━━━━━━━━━━━━━━
✨ 主要候選:
$COMMIT_MESSAGE
📋 備選方案:
1. ...
2. ...
3. ...
✅ `git commit -m "$COMMIT_MESSAGE"` 已復制到剪贴板
EOF
$ /commit-message
📝 提交消息建議
━━━━━━━━━━━━━━━━━━━━━━━━━
✨ 主要候選:
feat: 實作 JWT 認證系統
📋 備選方案:
1. feat: 新增基於 JWT 令牌的使用者認證
2. fix: 解決認證中介軟體的令牌驗證錯誤
3. docs: 將認證邏輯分離到獨立模組
✅ `git commit -m "feat: 實作 JWT 認證系統"` 已復制到剪贴板
git diff --staged 的內容注意: 此命令不執行 git add 或 git commit。仅生成提交消息並復制到剪贴板。
featfixtestchoredocs.gitmessage 文件CONTRIBUTING.md 中的規範# 判定基準 (優先級)
1. 從 git diff --staged 的內容判定語言
2. 暂存文件的注釋分析
3. git log --oneline -20 的語言分析
4. 項目主要語言設置
分析使用的資訊 (仅讀取):
git diff --staged --name-only - 更改文件列表git diff --staged - 實際更改內容git status --porcelain - 文件狀態当有 API 破坏性更改時:
英文:
feat!: change user API response format
BREAKING CHANGE: user response now includes additional metadata
或
feat(api)!: change authentication flow
繁体字中文:
feat!: 更改用戶 API 響應格式
BREAKING CHANGE: 響應現在包含额外的元數據
或
feat(api)!: 更改認證流程
英文:
feat: add user registration endpoint
fix: resolve memory leak in cache manager
docs: update API documentation
繁体字中文:
feat: 添加用戶注冊端點
fix: 解決緩存管理器內存洩漏
docs: 更新 API 文檔
# 與暂存更改結合使用
git add -p # 交互式暂存
/commit-message
"生成最優的提交消息"
# 仅暂存特定文件後分析
git add src/auth/*.js
/commit-message --lang zh-tw
"為認證相關更改生成合適的消息"
# Breaking Change 檢測和應對
git add -A
/commit-message --breaking
"如有破坏性更改請適当標記"
git add 暂存Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub foreveryh/claude-code-cookbook --plugin cook-zh-tw39 commands in this plugin
/analyze-dependencies分析專案依賴關係並評估架構健全性分析項目的依賴關系,評估架構的健康狀况。/analyze-performance基於 Core Web Vitals 的效能分析和 UX 評分從使用者體驗的角度分析應用程式效能,並量化透過最佳化實現的感知速度提升。基於 Core Web Vitals 計算 UX 分數,並提出有優先序的最佳化策略。/check-fact透過程式碼庫和文件驗證資訊準確性參考項目內的代碼庫、文檔 (docs/、README.md 等),確認所給資訊的正確性。/check-prompt評估並改進 AI 提示詞品質AI Agent 提示詞質量評估與改進的全面最佳實践集。基于實際提示詞改進過程中积累的經驗,系統化地涵蓋了消除歧義、資訊整合、強制力強化、追蹤系統、持續改進等所有重要方面。/context7透過 Context7 MCP 搜尋技術文件使用 MCP 的 Context7 搜索技術文檔。/design-patterns建議設計模式並評估 SOLID 原則提出可應用于代碼庫的設計模式,評估 SOLID 原則的遵守情况。2 plugins ship this exact command · first indexed Jul 16, 2026
Other plugins' commands for the same job