Fundamentals 15 min read

Master Conventional Commits: Streamline Git with Commitizen, cz‑customizable & Commitlint

This guide explains the Conventional Commits specification, its commit message structure, common types, and why it improves collaboration, then walks through using Commitizen, cz‑customizable, Commitlint, Husky, and lint‑staged to enforce and automate the workflow.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Conventional Commits: Streamline Git with Commitizen, cz‑customizable & Commitlint

Conventional Commits is a specification for Git commit messages that standardizes the format to improve readability, maintainability, and automation of versioning.

What is Conventional Commits

The format consists of a <type>, optional [scope], and a <description>, followed by optional body and footer sections. Example syntax:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Common types include feat (new feature), fix (bug fix), docs (documentation), and many others such as style, refactor, perf, test, build, ci, chore, and revert. Breaking changes are indicated by BREAKING CHANGE: in the footer or by appending ! to the type.

Why Use Conventional Commits

Standardized messages make it easier for team members to understand changes, generate changelogs, automate version bumps, and integrate with CI/CD tools.

How to Adopt Conventional Commits

Step 1: Commitizen

Commitizen provides an interactive CLI to generate compliant commit messages.
pnpm install -g commitizen
pnpm install -g cz-conventional-changelog

Create a .czrc file in your home directory with:

{"path": "cz-conventional-changelog"}

Then run:

git cz

Step 2: cz‑customizable

cz‑customizable lets you customize the prompts and available types.

npm install cz-customizable --save-dev

Add to package.json:

"config": {"commitizen": {"path": "node_modules/cz-customizable"}}

Create a .cz-config.js file to define types, messages, and limits (example shown in the original article).

Step 3: Commitlint

Commitlint validates commit messages against the Conventional Commits rules.

npm i @commitlint/config-conventional @commitlint/cli -D

Create commitlint.config.js:

module.exports = {extends: ['@commitlint/config-conventional']}

If using cz‑customizable, install the cz config:

npm install commitlint-config-cz --save-dev
module.exports = {extends: ['cz']}

Step 4: Husky

Husky runs scripts on Git hooks (e.g., pre‑commit).

pnpm install husky --save-dev

Add hooks in package.json:

"husky": {"hooks": {"pre-commit": "npm run lint && npm test"}}

Step 5: lint‑staged

lint‑staged runs linters on staged files before committing.

npm i lint-staged --save-dev

Configure in package.json:

"lint-staged": {"**/*.js": "eslint --fix", "**/*.{css,scss}": "stylelint"}

Additional Tips

You can also use ChatGPT as a commit message generator by providing a prompt that follows the Conventional Commits format.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

git-workflowcommitizencommitlinthuskylint-stagedconventional commits
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.