Commitizen for contributors
When you commit with Commitizen, you'll be prompted to fill out any required commit fields at commit time. No more waiting until later for a git commit hook to run and reject your commit (though that can still be helpful). No more digging through CONTRIBUTING.md to find what the preferred format is. Get instant feedback on your commit message formatting and be prompted for required fields.
Installing the command line tool
Commitizen is currently tested against Node.js 12, 14, & 16, although it may work in older versions of Node.js. You should also have npm 6 or greater.
Installation is as simple as running the following command (if you see EACCES
error, reading fixing npm permissions may help):
npm install -g commitizen
Using the command line tool
If your repo is Commitizen friendly:
Simply use git cz
or just cz
instead of git commit
when committing. You can also use git-cz
, which is an alias for cz
.
Alternatively, if you are using npm 5.2+ you can use npx
instead of installing globally:
npx cz
or as an npm script:
... "scripts": { "commit": "cz" }
When you're working in a Commitizen-friendly repository, you'll be prompted to fill in any required fields, and your commit messages will be formatted according to the standards defined by project maintainers.
If your repo is NOT Commitizen friendly:
If you're not working in a Commitizen-friendly repository, then git cz
will work just the same as git commit
, but npx cz
will use the streamich/git-cz adapter. To fix this, you need to first make your repo Commitizen friendly
Making your repo Commitizen friendly
For this example, we'll be setting up our repo to use AngularJS's commit message convention, also known as conventional-changelog.
First, install the Commitizen CLI tools:
npm install commitizen -g
Next, initialize your project to use the cz-conventional-changelog adapter by typing:
# npm commitizen init cz-conventional-changelog --save-dev --save-exact # yarn commitizen init cz-conventional-changelog --yarn --dev --exact # pnpm commitizen init cz-conventional-changelog --pnpm --save-dev --save-exact
Note that if you want to force install over the top of an old adapter, you can apply the --force
argument. For more information on this, just run commitizen help
.
The above command does three things for you:
- Installs the cz-conventional-changelog adapter npm module
- Saves it to
package.json
'sdependencies
ordevDependencies
- Adds the
config.commitizen
key to the root of yourpackage.json
file as shown here:
... "config": { "commitizen": { "path": "cz-conventional-changelog" } }
Alternatively, Commitizen configs may be added to a .czrc
file:
{ "path": "cz-conventional-changelog" }
This just tells Commitizen which adapter we actually want our contributors to use when they try to commit to this repo.
commitizen.path
is resolved via require.resolve and supports:
- npm modules
- directories relative to
process.cwd()
containing anindex.js
file - file base names relative to
process.cwd()
with.js
extension - full relative file names
- absolute paths
Please note that in the previous version of Commitizen we used czConfig. czConfig has been deprecated, and you should migrate to the new format before Commitizen 3.0.0.
Optional: Install and run Commitizen locally
Installing and running Commitizen locally allows you to make sure that developers are running the exact same version of Commitizen on every machine.
Install Commitizen with npm install --save-dev commitizen
.
On npm 5.2+ you can use npx
to initialize the conventional changelog adapter:
npx commitizen init cz-conventional-changelog --save-dev --save-exact
For previous versions of npm (< 5.2) you can execute ./node_modules/.bin/commitizen
or ./node_modules/.bin/cz
in order to actually use the commands.
You can then initialize the conventional changelog adapter using: ./node_modules/.bin/commitizen init cz-conventional-changelog --save-dev --save-exact
And you can then add some nice npm scripts in your package.json
file pointing to the local version of Commitizen:
... "scripts": { "commit": "cz" }
This will be more convenient for your users because then if they want to do a commit, all they need to do is run npm run commit
and they will get the prompts needed to start a commit!
NOTE: If you are using
precommit
hooks thanks to something likehusky
, you will need to name your script something other than"commit"
(e.g."cm": "cz"
). The reason is because npm scripts has a "feature" where it automatically runs scripts with the name prexxx where xxx is the name of another script. In essence, npm and husky will run"precommit"
scripts twice if you name the script"commit"
, and the workaround is to prevent the npm-triggered precommit script.
Optional: Running Commitizen on git commit
This example shows how to incorporate Commitizen into the existing git commit
workflow by using git hooks and the --hook
command-line option. This is useful for project maintainers
who wish to ensure the proper commit format is enforced on contributions from those unfamiliar with Commitizen.
Once either of these methods is implemented, users running git commit
will be presented with an interactive Commitizen session that helps them write useful commit messages.
NOTE: This example assumes that the project has been set up to use Commitizen locally.
Traditional git hooks
Update .git/hooks/prepare-commit-msg
with the following code:
#!/bin/bash exec < /dev/tty && node_modules/.bin/cz --hook || true
Husky
For husky
users, add the following configuration to the project's package.json
file:
"husky": { "hooks": { "prepare-commit-msg": "exec < /dev/tty && npx cz --hook || true" } }
Why
exec < /dev/tty
? By default, git hooks are not interactive. This command allows the user to use their terminal to interact with Commitizen during the hook.
Congratulations! Your repo is Commitizen friendly. Time to flaunt it!
Add the "Commitizen friendly" badge to your README using the following markdown:
[](http://commitizen.github.io/cz-cli/)
Your badge will look like this:
It may also make sense to change your README.md
or CONTRIBUTING.md
files to include or link to the Commitizen project so that your new contributors may learn more about installing and using Commitizen.
Conventional commit messages as a global utility
Install commitizen
globally, if you have not already.
npm install -g commitizen
Install your preferred commitizen
adapter globally (for example cz-conventional-changelog
).
npm install -g cz-conventional-changelog
Create a .czrc
file in your home
directory, with path
referring to the preferred, globally-installed, commitizen
adapter
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc
You are all set! Now cd
into any git
repository and use git cz
instead of git commit
, and you will find the commitizen
prompt.
Pro tip: You can use all the git commit
options
with git cz
. For example: git cz -a
.
If your repository is a Node.js project, making it Commitizen friendly is super easy.
If your repository is already Commitizen friendly, the local commitizen
adapter will be used, instead of globally installed one.
Commitizen for multi-repo projects
As a project maintainer of many projects, you may want to standardize on a single commit message format for all of them. You can create your own node module which acts as a front-end for Commitizen.
1. Create your own entry point script
// my-cli.js #!/usr/bin/env node "use strict"; const path = require('path'); const bootstrap = require('commitizen/dist/cli/git-cz').bootstrap; bootstrap({ cliPath: path.join(__dirname, '../../node_modules/commitizen'), // this is new config: { "path": "cz-conventional-changelog" } });
2. Add the script to your package.json
file
// package.json { "name": "company-commit", "bin": "./my-cli.js", "dependencies": { "commitizen": "^2.7.6", "cz-conventional-changelog": "^1.1.5" } }
3. Publish it to npm and use it!
npm install --save-dev company-commit ./node_modules/.bin/company-commit
Adapters
We know that every project and build process has different requirements, so we've tried to keep Commitizen open for extension. You can do this by choosing from any of the pre-built adapters or even by building your own. Here are some of the great adapters available to you:
- cz-conventional-changelog
- cz-conventional-changelog-for-jira
- cz-conventional-changelog-with-jiraid-detection
- cz-jira-smart-commit
- @endemolshinegroup/cz-jira-smart-commit
- @endemolshinegroup/cz-github
- rb-conventional-changelog
- @mapbox/cz-mapbox-changelog
- cz-customizable
- cz-commitlint
- commitlint
- vscode-commitizen
- cz-emoji
- cz-adapter-eslint
- commitiquette
- cz-format-extension
- cz-emoji-conventional
- cz-git
- cz-vinyl
To create an adapter, just fork one of these great adapters and modify it to suit your needs. We pass you an instance of Inquirer.js, but you can capture input using whatever means necessary. Just call the commit
callback with a string and we'll be happy. Publish it to npm, and you'll be all set!
Retrying failed commits
As of version 2.7.1, you may attempt to retry the last commit using the git cz --retry
command. This can be helpful when you have tests set up to run via a git precommit hook. In this scenario, you may have attempted a Commitizen commit, painstakingly filled out all of the commitizen fields, but your tests fail. In previous Commitizen versions, after fixing your tests, you would be forced to fill out all of the fields again. Enter the retry command. Commitizen will retry the last commit that you attempted in this repo without you needing to fill out the fields again.
Please note that the retry cache may be cleared when upgrading Commitizen versions, upgrading adapters, or if you delete the commitizen.json
file in your home or temp directory. Additionally, the commit cache uses the filesystem path of the repo, so if you move a repo or change its path, you will not be able to retry a commit. This is an edge case but might be confusing if you have scenarios where you are moving folders that contain repos.
It is important to note that if you are running cz
from an npm script (let's say it is called commit
) you will need to do one of the following:
- Pass
-- --retry
as an argument for your script. i.e:npm run commit -- --retry
- Use npx to find and call the
cz
executable directly. i.e:npx cz --retry
Note that the last two options do not require you to pass --
before the args but the first does.
Commitizen for project maintainers
As a project maintainer, making your repo Commitizen friendly allows you to select pre-existing commit message conventions or to create your own custom commit message convention. When a contributor to your repo uses Commitizen, they will be prompted for the correct fields at commit time.
Go further
Commitizen is great on its own, but it shines when you use it with some other amazing open source tools. Kent C. Dodds shows you how to accomplish this in his Egghead.io series, How to Write an Open Source JavaScript Library. Many of the concepts can be applied to non-JavaScript projects as well.
Philosophy
About Commitizen
Commitizen is an open source project that helps contributors be good open source citizens. It accomplishes this by prompting them to follow commit message conventions at commit time. It also empowers project maintainers to create or use predefined commit message conventions in their repos to better communicate their expectations to potential contributors.
Commitizen or Commit Hooks
Both! Commitizen is not meant to be a replacement for git commit hooks. Rather,
编辑推荐精选

酷表ChatExcel
大模型驱动的Excel数据处理工具
基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。


DeepEP
DeepSeek开源的专家并行通信优化框架
DeepEP是一个专为大规模分布式计算设计的通信库,重点解决专家并行模式中的通信瓶颈问题。其核心架构采用分层拓扑感知技术,能够自动识别节点间物理连接关系,优化数据传输路径。通过实现动态路由选择与负载均衡机制,系统在千卡级计算集群中维持稳定的低延迟特性,同时兼容主流深度学习框架的通信接口。


DeepSeek
全球领先开源大模型,高效智能助手
DeepSeek是一家幻方量化创办的专注于通用人工智能的中国科技公司,主攻大模型研发与应用。DeepSeek-R1是开源的推理模型,擅长处理复杂任务且可免费商用。


问小白
DeepSeek R1 满血模型上线
问小白是一个基于 DeepSeek R1 模型的智能对话平台,专为用户提供高效、贴心的对话体验。实时在线,支持深度思考和联网搜索。免费不限次数,帮用户写作、创作、分析和规划,各种任务随时完成!


KnowS
AI医学搜索引擎 整合4000万+实时更新的全球医学文献
医学领域专用搜索引擎整合4000万+实时更新的全球医学文献,通过自主研发AI模型实现精准知识检索。系统每日更新指南、中英文文献及会议资料,搜索准确率较传统工具提升80%,同时将大模型幻觉率控制在8%以下。支持临床建议生成、文献深度解析、学术报告制作等全流程科研辅助,典型用户反馈显示每周可节省医疗工作者70%时间。


Windsurf Wave 3
Windsurf Editor推出第三次重大更新Wave 3
新增模型上下文协议支持与智能编辑功能。本次更新包含五项核心改进:支持接入MCP协议扩展工具生态,Tab键智能跳转提升编码效率,Turbo模式实现自动化终端操作,图片拖拽功能优化多模态交互,以及面向付费用户的个性化图标定制。系统同步集成DeepSeek、Gemini等新模型,并通过信用点数机制实现差异化的资源调配。


腾讯元宝
腾讯自研的混元大模型AI助手
腾讯元宝是腾讯基于自研的混元大模型推出的一款多功能AI应用,旨在通过人工智能技术提升用户在写作、绘画、翻译、编程、搜索、阅读总结等多个领域的工作与生活效率。


Grok3
埃隆·马斯克旗下的人工智能公司 xAI 推出的第三代大规模语言模型
Grok3 是由埃隆·马斯克旗下的人工智能公司 xAI 推出的第三代大规模语言模型,常被马斯克称为“地球上最聪明的 AI”。它不仅是在前代产品 Grok 1 和 Grok 2 基础上的一次飞跃,还在多个关键技术上实现了创新突破。


OmniParser
帮助AI理解电脑屏幕 纯视觉GUI元素的自动化解析方案
开源工具通过计算机视觉技术实现图形界面元素的智能识别与结构化处理,支持自动化测试脚本生成和辅助功能开发。项目采用模块化设计,提供API接口与多种输出格式,适用于跨平台应用场景。核心算法优化了元素定位精度,在动态界面和复杂布局场景下保持稳定解析能力。


流畅阅读
AI网页翻译插件 双语阅读工具,还原母语级体验
流畅阅读是一款浏览器翻译插件,通过上下文智能分析提升翻译准确性,支持中英双语对照显示。集成多翻译引擎接口,允许用户自定义翻译规则和快捷键配置,操作数据全部存储在本地设备保障隐私安全。兼容Chrome、Edge、Firefox等主流浏览器,基于GPL-3.0开源协议开发,提供持续的功能迭代和社区支持。
推荐工具精选
AI云服务特惠
懂AI专属折扣关注微信公众号
最新AI工具、AI资讯
独家AI资源、AI项目落地

微信扫一扫关注公众号