Conventional Commit Message Guidelines
The commit message should be structured as follows:
# A - inline command
git commit -m "<type>(optional scope): <commit message>"
# B - in a commit editor
<type>(optional scope): <description>
[optional body]
[optional footer(s)]The commit contains the following structural elements, to communicate intent to the consumers of your library:
Commit Types
fix: A commit of the type
fixpatches a bug in your codebase (this correlates withPATCHin Semantic Versioning).Example:
fix(authentication): prevent timing attack vulnerabilityfeat: A commit of the type
featintroduces a new feature to the codebase (this correlates withMINORin Semantic Versioning).Example:
feat: add ability to create webhooksbuild: A commit of the type
buildaffects the build system or external dependencies (example scopes: gulp, broccoli, npm).Example:
build: bump lodash from 4.17.15 to 4.17.21chore: A commit of the type
choreincludes routine tasks, maintenance, or housekeeping changes that don't change production code.Example:
chore: update .gitignore fileci: A commit of the type
ciaffects the continuous integration or continuous delivery system (example scopes: Travis, Circle, BrowserStack, SauceLabs).Example:
ci: add Node 14 to testing matrixdocs: A commit of the type
docsaffects documentation only.Example:
docs(readme): update installation instructionsperf: A commit of the type
perfimproves performance.Example:
perf: improve list rendering performance by virtualizingrefactor: A commit of the type
refactorneither fixes a bug nor adds a feature, but restructures code.Example:
refactor(user): extract address validation to separate functionrevert: A commit of the type
revertreverts a previous commit.Example:
revert: feat(shopping cart): add product recommendationsstyle: A commit of the type
styleaffects code formatting, white-space, etc., without changing logic.Example:
style: fix indentation and whitespacetest: A commit of the type
testadds missing tests or corrects existing tests.Example:
test(api): add integration tests for user endpointshotfix: A commit of the type
hotfixhot fix bugs in production. Example:hotfix: update config
Breaking Changes
BREAKING CHANGE: A commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
Example:
feat(api)!: require authentication for all endpoints
BREAKING CHANGE: All API endpoints now require authenticationFooters
Footers other than BREAKING CHANGE: <description> may be provided and follow a convention similar to git trailer format.
Example footers:
Reviewed-by: John Doe
Refs: AST-142
Co-authored-by: Jane Smith <jane@example.com>Every commit that lands on main carries the Jira key of its subtask in a Refs: footer, so Jira lists the commit on the ticket (jira.md).
Best Practices
- Keep the subject line concise (ideally under 72 characters)
- Use the imperative mood in the subject line (e.g., "add" not "added" or "adds")
- Do not end the subject line with a period
- Separate subject from body with a blank line
- Use the body to explain what and why vs. how
- Reference the Jira key in the footer:
Refs: AST-142