Conventional Commits

by patricio0312rev79ea6af48569No license62 starsListed Oct 8, 2026Updated Oct 8, 2026Repository updated 8 months ago

Generates semantic commit messages following the Conventional Commits specification with proper types, scopes, breaking changes, and footers. Use when users request "write commit message", "conventional commit", "semantic commit", or "format commit".

Instructions onlySoftware Development
AI-generated overview

Writes Conventional Commits messages with correct types, scopes, breaking-change markers and footers.

What it does
Provides a reference and workflow for producing standardized semantic commit messages following the Conventional Commits specification. It covers commit types and their SemVer effects, scope conventions, breaking-change notation, body and footer tokens, and examples of good and bad messages. It also shows optional integration with commitlint, Husky and semantic-release, and ends with an output checklist for the generated message.
When to use it
Use when a user asks to write, format or review a commit message, or wants a semantic/conventional commit. Also useful when setting up commit message conventions or tooling that depends on them.
Requirements
No scripts or packages are required; it is instructions only. The tooling examples (commitlint, Husky, semantic-release) are optional and would need Node.js and npm if actually installed.

Conventional Commits

Write standardized, semantic commit messages that enable automated versioning and changelog generation.

Core Workflow

  1. Analyze changes: Review staged files and modifications
  2. Determine type: Select appropriate commit type (feat, fix, etc.)
  3. Identify scope: Optional component/module affected
  4. Write description: Concise summary in imperative mood
  5. Add body: Optional detailed explanation
  6. Include footer: Breaking changes, issue references

Commit Message Format

<type>[optional scope]: <description>
[optional body]
[optional footer(s)]

Commit Types

TypeDescriptionSemverExample
featNew featureMINORfeat: add user authentication
fixBug fixPATCHfix: resolve login redirect loop
docsDocumentation only-docs: update API reference
styleFormatting, whitespace-style: fix indentation in utils
refactorCode change, no feature/fix-refactor: extract validation logic
perfPerformance improvementPATCHperf: optimize database queries
testAdding/fixing tests-test: add unit tests for auth
buildBuild system, dependencies-build: upgrade to Node 20
ciCI/CD configuration-ci: add GitHub Actions workflow
choreMaintenance tasks-chore: update .gitignore
revertRevert previous commit-revert: undo feature flag change

Scopes

Scopes indicate the area of the codebase affected:

bash
# Component/module scopesfeat(auth): add OAuth2 supportfix(api): handle timeout errorsdocs(readme): add installation steps
# File-based scopesstyle(eslint): update linting rulesbuild(docker): optimize image size
# Layer scopesrefactor(service): extract user servicetest(e2e): add checkout flow tests

Breaking Changes

Mark breaking changes with ! or BREAKING CHANGE footer:

bash
# Using ! notationfeat(api)!: change response format to JSON:API
# Using footerfeat(api): change response format
BREAKING CHANGE: Response now follows JSON:API specification.Clients must update their parsers.

Commit Message Examples

Simple Feature

feat: add dark mode toggle

Feature with Scope

feat(ui): add dark mode toggle to settings page

Bug Fix with Issue Reference

fix(auth): resolve session expiration race condition
The session refresh was racing with the expiration check,causing intermittent logouts.
Fixes #234

Breaking Change

feat(api)!: migrate to v2 response format
BREAKING CHANGE: All API responses now use camelCase keysinstead of snake_case. Update client parsers accordingly.
Migration guide: https://docs.example.com/v2-migration

Multiple Footers

fix(payments): correct tax calculation for EU customers
Updated tax calculation to use customer's billing countryinstead of shipping country for digital goods.
Fixes #456Reviewed-by: AliceCo-authored-by: Bob <[email protected]>

Revert Commit

revert: feat(auth): add OAuth2 support
This reverts commit abc123def456.
Reason: OAuth provider has rate limiting issues in production.Will re-implement with proper caching.

Description Guidelines

Do

  • Use imperative mood: "add" not "added" or "adds"
  • Keep under 72 characters
  • Start with lowercase
  • No period at the end
  • Be specific and concise

Don't

  • "Fixed bug" (too vague)
  • "Updated stuff" (not descriptive)
  • "WIP" (commit when ready)
  • "misc changes" (split into separate commits)

Good Examples

bash
feat: add email verification flowfix: prevent duplicate form submissionsrefactor: extract payment processing to serviceperf: cache user preferences in memorydocs: add API authentication examples

Bad Examples

bash
# Too vaguefix: fixed itupdate: updates
# Wrong tensefeat: added new featurefix: fixes the bug
# Too longfeat: add a new feature that allows users to export their data in multiple formats including CSV, JSON, and XML

Body Guidelines

When to include a body:

  • Changes need context or explanation
  • Complex logic that isn't self-evident
  • Breaking changes require migration info
  • Multiple related changes in one commit
fix(cache): invalidate user cache on profile update
Previously, profile updates were not reflected until cache expiry.This caused confusion when users updated their avatar and didn'tsee the change immediately.
The fix adds cache invalidation after successful profile updatesand ensures CDN purge for static assets.

Footer Tokens

TokenPurposeExample
FixesCloses issueFixes #123
ClosesCloses issueCloses #456
RefsReferences issueRefs #789
BREAKING CHANGEBreaking changeBREAKING CHANGE: description
Reviewed-byReviewer creditReviewed-by: Name
Co-authored-byCo-author creditCo-authored-by: Name <email>

Integration with Tooling

Commitlint Configuration

javascript
// commitlint.config.jsmodule.exports = {  extends: ['@commitlint/config-conventional'],  rules: {    'type-enum': [      2,      'always',      [        'feat', 'fix', 'docs', 'style', 'refactor',        'perf', 'test', 'build', 'ci', 'chore', 'revert'      ]    ],    'scope-case': [2, 'always', 'kebab-case'],    'subject-case': [2, 'always', 'lower-case'],    'subject-max-length': [2, 'always', 72],    'body-max-line-length': [2, 'always', 100]  }};

Husky Pre-commit Hook

bash
# .husky/commit-msg#!/bin/sh. "$(dirname "$0")/_/husky.sh"npx --no-install commitlint --edit "$1"

Package.json Setup

json
{  "devDependencies": {    "@commitlint/cli": "^18.0.0",    "@commitlint/config-conventional": "^18.0.0",    "husky": "^8.0.0"  },  "scripts": {    "prepare": "husky install"  }}

Semantic Release Integration

Conventional commits enable automated versioning:

yaml
# .releaserc.ymlbranches:  - mainplugins:  - "@semantic-release/commit-analyzer"  - "@semantic-release/release-notes-generator"  - "@semantic-release/changelog"  - "@semantic-release/npm"  - "@semantic-release/git"

Version Bumping Rules

Commit TypeVersion BumpExample
featMinor (0.X.0)1.2.0 → 1.3.0
fixPatch (0.0.X)1.2.0 → 1.2.1
perfPatch (0.0.X)1.2.0 → 1.2.1
BREAKING CHANGEMajor (X.0.0)1.2.0 → 2.0.0
OthersNo bump1.2.0 → 1.2.0

Commit Message Generator

When analyzing changes, generate a commit message:

bash
# 1. Check staged changesgit diff --cached --name-only
# 2. Analyze change type# - New files = likely feat# - Modified test files = test# - Modified docs = docs# - Bug-related keywords = fix
# 3. Identify scope from path# src/components/Button.tsx → components or ui# src/services/auth.ts → auth or services
# 4. Generate messagefeat(ui): add loading state to Button component

Best Practices

  1. One logical change per commit: Don't mix features with fixes
  2. Commit early, commit often: Small, focused commits
  3. Write for reviewers: Messages should explain why, not just what
  4. Reference issues: Link to tickets/issues when applicable
  5. Use scopes consistently: Establish team conventions
  6. Review before committing: git diff --cached to verify changes

Output Checklist

Every commit message should:

  • Start with valid type (feat, fix, docs, etc.)
  • Use imperative mood in description
  • Keep description under 72 characters
  • Include scope when applicable
  • Mark breaking changes with ! or footer
  • Reference related issues in footer
  • Provide body for complex changes
  • Follow team's scope conventions

Source and attribution

Source:patricio0312rev/skillsinfoundation/conventional-commitsat commit79ea6af

License: No license

Content belongs to its original authors. SourceWeft indexes it from a public repository.

Report or request removal