| name | commit |
| description | Use this skill when committing changes. This skill enforces writing meaningful commit messages with both Why and What sections, and provides Git workflow guidelines. |
Commit
このスキルはコミットのワークフロー全体をカバーする。
絶対禁止事項
git commit --amendは禁止: 履歴を直線的に保つためgit reset --soft|hardは禁止: 変更の巻き戻しは行わない- 一行だけの what コミットは禁止: 必ず Why を記述する
- 会話中に作業していない変更をコミットすることは禁止:
git statusで表示された変更であっても、その会話セッション中に自分が行った変更のみをコミットすること。関係のない変更が存在する場合は無視する - GitHub の Issue/PR 参照は禁止:
Closes #123、Fixes #123、https://github.com/.../issues/123、https://github.com/.../pull/123などの issue/PR 参照は一切記載しない。OSS の issue や PR にリンクされることを避けるため
コミットの粒度
- 論理的なチェックポイントでコミットすること
- 1 つの機能、1 つの修正、または 1 つのまとまった変更につき 1 コミット
- 複数の独立した変更を 1 コミットにまとめない
コミットメッセージフォーマット
<scope>: <subject>
<body>
Subject line (1 行目)
- スコープ: 変更対象の設定ディレクトリを指定 (例:
zsh,nvim,tmux,bin)- 機能単位やスクリプト名で細分化可能 (例:
zsh/history,nvim/cmp,bin/tmux-session-fzf) - 複数スコープの場合は
,で区切る (例:claude, bin)
- 機能単位やスクリプト名で細分化可能 (例:
- 説明: 小文字で始まり、現在形の命令形を使用 (例:
add,fix,refactor,update,remove) - 問題を解決する場合: 「何をした」ではなく「何を直した」を書く
- Good:
fix EDITOR being set to "nvim not found" - Bad:
simplify EDITOR to use nvim directly
- Good:
Body (2 行目以降)
必須。空行を挟んで Why と What を記述する。
- Why: なぜこの変更が必要なのか。問題の原因、背景、動機を説明
- What (任意): 変更内容の詳細。subject だけで十分に説明できている場合は省略可
良い例
zsh: fix EDITOR being set to "nvim not found"
`$(which nvim)` was executed before mise initialized PATH, causing
`which nvim` to output "nvim not found" which was then set as EDITOR.
This broke git rebase -i by opening "not" and "found" as files.
tmux: add visual distinction for inactive panes
In multi-pane layouts, it was difficult to identify which pane was
active. Add dimmed styling to inactive panes to make the active pane
more obvious.
nvim/cmp: disable completion in comment contexts
Autocompletion in comments was triggering unnecessarily and
interrupting the writing flow.
悪い例
zsh: simplify EDITOR to use nvim directly
- 問題: Why がない。なぜ simplify が必要だったのか不明
zsh: update vim.zsh
- 問題: 何をしたのか分からない。body もない
fix bug
- 問題: scope がない。何のバグか分からない。body もない
コミット手順
git statusで変更内容を確認git diffでステージング前の差分を確認git log --oneline -5で最近のコミットスタイルを確認- 変更を add してコミット (HEREDOC を使用してフォーマットを保持):
git add <files>
git commit -m "$(cat <<'EOF'
<scope>: <subject>
<body - Why と What を記述>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)"
git statusで成功を確認
pre-commit フック
- フックが失敗した場合: 問題を修正し、元のメッセージを使用して再度コミット
- フックがファイルを変更した場合 (フォーマッタなど): 変更されたファイルを add して再度コミット
セルフチェック
コミット前に以下を確認:
- Why が書かれているか?
- Subject は「何を直した」になっているか? (問題解決の場合)
- 1 つの論理的なまとまりになっているか?