Conventional Commits

コミットメッセージに構造化されたフォーマットを適用し、変更履歴の自動生成やバージョニングを可能にする規約

Git自動化

Conventional Commits とは

Conventional Commits は、コミットメッセージに type(scope): description の構造化フォーマットを適用する規約である。変更履歴 (CHANGELOG) の自動生成、セマンティックバージョニングの自動判定、コミット履歴の検索性向上を実現する。

フォーマット

<type>(<scope>): <description>

[body]

[footer]
feat(auth): add OAuth2 login with Google
fix(api): handle null response from DynamoDB
docs(readme): update installation instructions
refactor(db): extract connection pool to separate module
chore(deps): bump typescript from 5.3 to 5.4

BREAKING CHANGE: remove deprecated /v1/users endpoint

type の種類

type 説明 バージョン影響
feat 新機能 minor (1.x.0)
fix バグ修正 patch (1.0.x)
docs ドキュメント なし
style フォーマット (動作に影響なし) なし
refactor リファクタリング なし
perf パフォーマンス改善 patch
test テストの追加・修正 なし
chore ビルド、CI、依存関係 なし
ci CI 設定の変更 なし

BREAKING CHANGE がフッターにある場合は major (x.0.0) バージョンアップ。

commitlint で強制

npm install -D @commitlint/cli @commitlint/config-conventional
// commitlint.config.js
module.exports = { extends: ['@commitlint/config-conventional'] };
# .husky/commit-msg
npx commitlint --edit $1

規約に従わないコミットメッセージはブロックされる。

CHANGELOG の自動生成

npx standard-version
# または
npx semantic-release
# Changelog

## [1.2.0] - 2026-04-01
### Features
- **auth**: add OAuth2 login with Google

### Bug Fixes
- **api**: handle null response from DynamoDB

セマンティックバージョニングとの連携

feat  minor: 1.1.0  1.2.0
fix   patch: 1.2.0  1.2.1
BREAKING CHANGE  major: 1.2.1  2.0.0

CI/CD パイプラインで semantic-release を使えば、コミットメッセージからバージョン番号の決定、タグ付け、npm publish、GitHub Release の作成まで自動化できる。

体系的に学ぶなら関連書籍を参照してほしい。

関連用語