Why?
A clear, consistent commit message format helps:
- Quickly understand project history
- Filter and find specific changes (e.g. documentation vs. code)
- Generate changelogs automatically (see below for details)
Recommended Format
Use the Conventional Commits standard:
<type>(<scope>): <description>
[optional body]
[optional footer]
- Header/Subject (
type
+scope
+description
) is required- Keep the subject line under 72 characters
- Body and footer are optional
Common Types
Type | Description |
---|---|
feat | New feature |
fix | Bug fix |
docs | Documentation changes |
style | Formatting, whitespace, etc. (no code change) |
refactor | Code refactor (no bug fix or feature) |
perf | Performance improvement |
test | Adding or updating tests |
chore | Routine tasks (build, dependencies, etc.) |
Writing Good Commit Messages
- Use imperative, present tense: “Fix bug” not “Fixed bug”
- Capitalize the subject line
- No period at the end of the subject
Example commit messages:
feat(auth): add login with Google OAuthfix(api): handle token refresh errorsdocs(readme): update setup instructions
Helper Tools
Tool | What It Does | When It’s Used |
---|---|---|
commitizen | Interactive CLI that guides you through writing a commit message | Before writing commits |
commitlint | Lints commit messages to ensure they meet the standard and enforce consistency 1 | After writing commits |
conventional-changelog | Automatically generates changelogs from commit history | After merging/releasing |
Example workflow:
-
Write commits using the Conventional Commits format.
-
Run
npx conventional-changelog -i CHANGELOG.md -s
to update your changelog.This command scans your commit history for Conventional Commits, generates a changelog, writes it to
CHANGELOG.md
(-i CHANGELOG.md
), and updates the file in place (-s
). The default preset is Angular, but you can omit-p angular
for most projects.💡 To see all available command line parameters, run:
conventional-changelog --help
-
Optionally, use
standard-version
orrelease-it
to bump versions and update changelogs automatically.
Footnotes
-
You can add a Git hook (
commit-msg
) to validate your commit messages:npx commitlint --edit $1
↩