Create commits following Sentry conventions - meaningful messages, atomic changes, and proper formatting. Use when making git commits.
<type>(<scope>): <subject>
<body>
<footer>
| Type | Description | Example |
|---|---|---|
feat |
New feature | feat(auth): add SSO login |
fix |
Bug fix | fix(api): handle null response |
docs |
Documentation | docs(readme): update setup guide |
style |
Formatting | style(lint): fix indentation |
refactor |
Code restructure | refactor(db): extract query builder |
perf |
Performance | perf(cache): add redis caching |
test |
Tests | test(auth): add login tests |
build |
Build system | build(deps): upgrade webpack |
ci |
CI/CD | ci(github): add lint workflow |
chore |
Maintenance | chore: update gitignore |
revert |
Revert commit | revert: feat(auth): add SSO |
The scope should be the module, component, or area affected:
feat(auth): ... # Authentication module
fix(api/users): ... # Users API endpoint
docs(contributing): ... # Contributing docs
refactor(ui/button): ... # Button component
## Good Subject Lines
- Start with lowercase (unless proper noun)
- No period at the end
- Use imperative mood ("add" not "added")
- Keep under 50 characters
- Be specific and descriptive
## Examples
ā
feat(auth): add password reset flow
ā
fix(api): handle rate limit errors gracefully
ā
refactor(db): extract connection pooling logic
ā feat(auth): Added password reset flow.
ā fix: fix stuff
ā refactor(db): this refactors the database connection pooling logic to be more efficient
fix(api): handle rate limit errors gracefully
The API was crashing when receiving 429 responses from
the upstream service. This adds proper error handling
and implements exponential backoff.
- Add RateLimitError exception class
- Implement retry logic with exponential backoff
- Add circuit breaker for repeated failures
- Log rate limit events for monitoring
# Reference issues
Fixes #123
Closes #456
Refs #789
# Breaking changes
BREAKING CHANGE: API response format changed
The `user` field is now `users` (array) in the response.
Migration guide: https://docs.example.com/migration
## Each Commit Should:
1. Represent one logical change
2. Leave the codebase in a working state
3. Be independently reviewable
4. Be revertable without side effects
# Instead of one large commit:
# "feat: add user management"
# Break into atomic commits:
git commit -m "feat(db): add users table migration"
git commit -m "feat(models): add User model with validation"
git commit -m "feat(api): add user CRUD endpoints"
git commit -m "feat(ui): add user management page"
git commit -m "test(users): add integration tests"
git commit -m "docs(api): document user endpoints"
# Stage specific files
git add src/auth/login.ts src/auth/logout.ts
# Interactive staging (pick hunks)
git add -p
# Stage all changes (be careful!)
git add .
# Quick commit with message
git commit -m "type(scope): subject"
# Open editor for detailed message
git commit
# Amend last commit (before push)
git commit --amend
# Amend without changing message
git commit --amend --no-edit
# Review what's staged
git diff --staged
# Check status
git status
# Run tests
npm test
# Run linter
npm run lint
feat(scope): add feature description
Implement [feature] to enable [capability].
- Add [component/function]
- Update [related component]
- Include [tests/docs]
Closes #123
fix(scope): resolve issue description
The issue occurred because [root cause].
This fix [explanation of solution].
Before: [problematic behavior]
After: [correct behavior]
Fixes #456
refactor(scope): improve code description
Restructure [component] to improve [quality attribute].
Changes:
- Extract [function/class]
- Rename [old name] to [new name]
- Remove unused [code]
No functional changes.
feat(api)!: change authentication method
BREAKING CHANGE: JWT tokens now required for all API calls.
Migration:
1. Generate API key in dashboard
2. Include in Authorization header
3. Update client SDK to v2.0+
See migration guide: https://docs.example.com/auth-migration
#!/bin/bash
# .git/hooks/pre-commit
# Run linter
npm run lint || exit 1
# Run type check
npm run typecheck || exit 1
# Run tests
npm test -- --passWithNoTests || exit 1
#!/bin/bash
# .git/hooks/commit-msg
MSG=$(cat "$1")
PATTERN="^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?(!)?: .{1,50}"
if ! echo "$MSG" | grep -qE "$PATTERN"; then
echo "ā Invalid commit message format"
echo "Expected: type(scope): subject"
exit 1
fi