Enforce Conventional Commits specification for consistent, meaningful commit messages. Provides commit message validation, type categorization, scope management, and automatic changelog generation support. Use when writing commit messages, validating commits, or setting up commit message standards.
Conventional Commits is a specification for creating consistent, meaningful commit messages. This skill helps you write, validate, and understand conventional commit messages.
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
| Type | Description | Examples |
|---|---|---|
feat | New feature | feat(auth): add OAuth2 login |
fix | Bug fix | fix(api): resolve timeout issue |
docs | Documentation changes |
docs(readme): update setup guide |
style | Code style changes (formatting, semicolons, etc.) | style(ui): format CSS |
refactor | Code refactoring | refactor(auth): simplify token logic |
perf | Performance improvements | perf(db): optimize query |
test | Adding or updating tests | test(api): add integration tests |
build | Build system or dependencies | build: upgrade to webpack 5 |
ci | CI/CD configuration | ci(github): add workflow |
chore | Other changes | chore: update .gitignore |
revert | Revert a previous commit | revert: feat(auth) |
The scope provides additional contextual information:
feat(auth): add OAuth2 login - Scope: authfix(api): resolve timeout - Scope: apidocs(readme): update setup - Scope: readmeScopes are project-specific. Common scopes:
ui, components, styles, assetsapi, db, auth, servicesbuild, ci, deploy, infrastructureRules:
Good:
feat(auth): add OAuth2 login flowfix(api): resolve request timeoutdocs(readme): update installation stepsBad:
feat(auth): Added OAuth2 login flow. (Wrong mood, has period)fix(api): fix the thing that broke (Too vague)feat: implement a very long description that exceeds reasonable limits (Too long)Purpose: Provide detailed explanation of WHAT and WHY
Rules:
Example:
feat(auth): add OAuth2 login flow
Implement OAuth2 authentication using Google provider.
This allows users to sign in with their Google account
instead of creating a separate password.
Closes #123
Purpose: Metadata about breaking changes and issue references
Breaking Changes:
feat(api): remove deprecated endpoint
BREAKING CHANGE: Endpoint /api/v1/users has been removed.
Use /api/v2/users instead.
Issue References:
fix(auth): resolve token expiration
Closes #456
Related #789
Fixes #123
Step 1: Identify Type
# Did you add a new feature?
Type: feat
# Did you fix a bug?
Type: fix
# Did you change documentation?
Type: docs
# Other changes?
Type: chore, refactor, style, test, etc.
Step 2: Identify Scope
# What part of the codebase changed?
feat(auth): # Authentication module
fix(api): # API layer
docs(readme): # README file
Step 3: Write Description
# What did you do in 50 characters or less?
feat(auth): add OAuth2 login
fix(api): resolve timeout error
docs(readme): update setup guide
Step 4: Add Body (Optional)
feat(auth): add OAuth2 login
Implement OAuth2 authentication using Google provider.
This simplifies the login process and improves security.
Closes #123
New Feature:
feat(feature-name): short description
Detailed explanation of what feature was added
and why it was necessary.
Closes #issue-number
Bug Fix:
fix(component-name): short description
Explanation of what was broken, why it broke,
and how it was fixed.
Fixes #issue-number
Breaking Change:
feat(component-name): short description
BREAKING CHANGE: Explanation of what broke and
how to migrate to the new version.
Documentation:
docs(file-name): short description
Updated documentation to reflect recent changes
in the codebase or clarify existing functionality.
Refactoring:
refactor(component-name): short description
Explanation of what was refactored and why.
No functional changes.
Before Committing:
# 1. Check commit message format
git log -1 --format=%s
# 2. Verify type is valid
# Should match: ^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)
# 3. Check description length
# Should be <= 50 characters
# 4. Verify imperative mood
# Should use "add", "fix", "update" not "added", "fixed", "updated"
After Committing:
# 1. View commit message
git log -1 --format=fuller
# 2. Verify all parts are correct
# Type, scope, description, body, footer
feat(auth): add login is better than feat: add login to auth modulefeat and fix in the same commitfeat(auth): add OAuth2 login
fix(api): resolve request timeout issue
The API was timing out when processing large payloads.
Added streaming response handling to prevent buffer overflow.
Fixes #456
feat(api): remove deprecated endpoints
BREAKING CHANGE: The following endpoints have been removed:
- /api/v1/users
- /api/v1/auth
Migrate to /api/v2/users and /api/v2/auth.
Migration guide: https://docs.example.com/migration-v2
docs(readme): update installation instructions
Added Docker installation method and updated
Python version requirements.
Related #789
refactor(auth): simplify token validation
Consolidated token validation logic into a single function.
No functional changes - this improves code maintainability.
Refactored code is now 40% shorter and easier to understand.
perf(db): optimize user query performance
Added database indexes for commonly queried fields.
Query performance improved from 500ms to 50ms.
Closes #123
test(auth): add integration tests for OAuth2
Added comprehensive integration tests covering:
- Token generation
- Token refresh
- Token revocation
- Error handling
Solution: Break into multiple commits or shorten description
# Too long
feat(auth): implement a very comprehensive OAuth2 login system with multiple providers
# Better
feat(auth): add OAuth2 multi-provider support
Solution: Use git commit --amend to fix before pushing
# Fix the commit message
git commit --amend -m "fix(auth): resolve token expiration"
# Push if you already pushed (requires force push)
git push --force-with-lease
Solution: Add footer to commit message
git commit --amend -m "feat(api): remove deprecated endpoint
BREAKING CHANGE: Endpoint /api/v1/users removed. Use /api/v2/users."
Add commitlint to enforce Conventional Commits:
Installation:
npm install -g @commitlint/cli @commitlint/config-conventional
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
Git Hook:
# .husky/pre-commit
#!/bin/sh
commitlint --edit $1
Set up a commit message template:
# Create template
cat > .gitmessage << 'EOF'
<type>(<scope>): <subject>
<body>
<footer>
EOF
# Configure git to use template
git config --global commit.template .gitmessage
Conventional Commits enable automatic changelog generation:
Using conventional-changelog:
npm install -g conventional-changelog-cli
# Generate changelog
conventional-changelog -p angular -i CHANGELOG.md -s
Output:
## [1.0.0] - 2024-01-15
### Added
- **auth:** add OAuth2 login flow
- **api:** add user profile endpoint
### Fixed
- **api:** resolve request timeout issue
- **ui:** fix mobile responsive layout
### Breaking Changes
- **api:** removed deprecated /api/v1/users endpoint
feat(auth): add login is better than feat: add stuffSources: