commit-detection について
ステージ済み・未ステージのGit変更から、Conventional Commitsの種類とスコープを推定するスキルです。変更に合うコミットコマンドを選ぶための提案を行いますが、コミット自体は実行しません。
主な機能
- 01パターンに基づく変更ファイル分類
- 02差分キーワードによる種類判定
- 03変更ディレクトリからスコープを提案
- 04Conventional Commitsの種類ルール適用
- 05該当するコミットコマンドへの振り分け
活用シーン
- 01ドキュメントのみの変更にコミット種類を選定
- 02ファイルと差分テキストからバグ修正を分類
- 03ソースディレクトリの変更にスコープを提案
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ fusengine/ agents --skill commit-detectionインストール後、Claude Code で/commit-detectionを入力して読み込まれたか確認します。
詳細
ステージ済みおよび未ステージの git 変更から、ファイルパターンによる分類(docs/test/config/ci/build/src)と diff 内のキーワードに基づくヒューリスティック(「fix」「bug」「optimize」など)を使用して、最適な Conventional Commit タイプ(feat/fix/docs/style/refactor/perf/test/build/ci/chore)を検出し、主な変更ディレクトリからスコープ候補を導き出します(例:`src/api/auth.ts` → `auth`)。検出アルゴリズム全体、ルールの適用順序、スコープの抽出、実例を網羅します。コミット自体は実行せず、該当する `/commit-pro:` コマンドに振り分けます。どのルールにも明確に当てはまらない場合は、詳細なスマート分析を行う `commit` スキルに振り分けます。
コミットタイプ検出スキル
最適な Conventional Commit タイプを検出するための専門知識です。
検出アルゴリズム
ステップ 1:データを収集
# Get modified files
git diff --name-only
git diff --staged --name-only
# Get change statistics
git diff --stat
git diff --staged --stat
# Check for keywords in diff
git diff | grep -i "fix\|bug\|error" | head -5
ステップ 2:ファイルを分類
| カテゴリー | ファイルパターン |
|---|---|
| docs | *.md、*.txt、*.rst、README*、CHANGELOG* |
| test | *.test.*、*.spec.*、__tests__/*、test/* |
| config | *.json、*.yml、*.yaml、*.toml、.*rc |
| ci | .github/*、.gitlab-ci.yml、Jenkinsfile |
| build | package.json、Makefile、webpack.*、vite.* |
| style | 空白とフォーマットのみの変更 |
| src | *.ts、*.js、*.py、*.go、*.rs など |
ステップ 3:ルールを適用
IF only docs files changed:
→ docs
IF only test files changed:
→ test
IF only config/build files changed:
→ chore
IF only CI files changed:
→ ci
IF diff contains "fix", "bug", "error", "issue", "resolve":
→ fix
IF new files added with business logic:
→ feat
IF files renamed/moved without logic change:
→ refactor
IF performance keywords ("optimize", "perf", "speed", "cache"):
→ perf
IF formatting only (whitespace, semicolons):
→ style
DEFAULT:
→ Use /commit-pro:commit for smart analysis
ステップ 4:スコープを決定
主なディレクトリからスコープを抽出します:
src/components/Button.tsx → ui or button
src/api/auth.ts → auth
lib/utils/date.ts → utils
server/routes/user.ts → user
クイックリファレンス
| タイプ | 該当する場合 | バージョンの更新 |
|---|---|---|
feat | 新機能 | PATCH |
fix | バグ修正 | PATCH |
docs | ドキュメントのみ | PATCH |
style | フォーマットのみ | PATCH |
refactor | コードの再構成 | PATCH |
perf | パフォーマンス | PATCH |
test | テストのみ | PATCH |
build | ビルド/依存関係 | PATCH |
ci | CI/CD 設定 | PATCH |
chore | メンテナンス | PATCH |
MINOR/MAJOR の更新はユーザーが手動で決定し、自動では行われません。
コミット後の処理
すべてのリポジトリで共通の CHANGELOG、バージョン更新、タグのロジックについては、post-commit スキルを参照してください。
例
例 1:README のみを変更
Files: README.md
→ /commit-pro:docs
例 2:新しいコンポーネントとテスト
Files: src/Button.tsx, src/Button.test.tsx
→ /commit-pro:feat (primary is new feature)
例 3:既存ファイルの修正
Files: src/api/auth.ts
Diff contains: "fix login bug"
→ /commit-pro:fix
コメント
Markdown 対応