← ClaudeAtlas

commit-message-checkerlisted

Conventional Commits 形式チェック(feat/fix/docs/style/refactor/test/chore + scope + 件名 50 文字以内)。push 前にローカルで形式違反を検出する。
ttamakijp/dev-templates · ★ 0 · Code & Development · score 69
Install: claude install-skill ttamakijp/dev-templates
# commit-message-checker コミットメッセージが Conventional Commits 形式に準拠しているか検証する。 ## 形式 ``` <type>(<scope>): <subject> <body> <footer> ``` ### type(必須) | type | 用途 | |------|------| | `feat` | 新機能追加 | | `fix` | バグ修正 | | `docs` | ドキュメントのみ | | `style` | フォーマット(コード意味変更なし) | | `refactor` | リファクタリング(機能変更なし) | | `test` | テスト追加・修正 | | `chore` | ビルド・補助ツール変更 | | `perf` | パフォーマンス改善 | | `ci` | CI 設定変更 | | `revert` | revert コミット | ### scope(任意) 変更対象のモジュール名(例: `feat(auth)`, `fix(api)`)。 ### subject(必須・50 文字以内) - 命令形・現在形("add" not "added") - 末尾ピリオドなし - 大文字始まり推奨だが日本語は許容 ## 検証手順 ### 1. 直近コミットのチェック ```bash git log -1 --pretty=%s ``` 正規表現: ``` ^(feat|fix|docs|style|refactor|test|chore|perf|ci|revert)(\([a-z0-9-]+\))?: .{1,50}$ ``` ### 2. ブランチ全体(main 比較) ```bash git log main..HEAD --pretty=%s | while read -r msg; do if ! echo "$msg" | grep -qE '^(feat|fix|docs|style|refactor|test|chore|perf|ci|revert)(\([a-z0-9-]+\))?: .{1,72}$'; then echo "INVALID: $msg" fi done ``` ### 3. commit-msg フック化 `.git/hooks/commit-msg`: ```bash #!/bin/sh msg=$(head -1 "$1") echo "$msg" | grep -qE '^(feat|fix|docs|style|refactor|test|chore|perf|ci|revert)(\([a-z0-9-]+\))?: .{1,72}$' \ || { echo "Conventional Commits 形式違反: $msg"; exit 1; } ``` ## チェックリスト - [ ] type が許可リストに含まれる - [ ] subject が 50(最大 72)文字以内 - [ ] 命令形・現在形 - [ ] 末尾ピリオドなし - [ ] body と subject の間に空行 - [ ] BREAKING CHANGE は footer に明記