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.
Commitizen requires Node.js 22.23.5+, 24.22.3+ or 26.13.1+ (the November 2026 security releases) and is tested against Node.js 22, 24 & 26. Use the latest release of your line.
Installation is as simple as running the following command (if you see EACCES error, reading fixing npm permissions may help):
npm install -g commitizenIf 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 --no -- cz--no stops npx from downloading anything when commitizen isn't installed in the project. Without it, npx would fetch an unrelated npm package that is also named cz. With pnpm, use pnpm exec 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 you're not working in a Commitizen-friendly repository, then git cz will work just the same as git commit. To fix this, you need to first make 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 -gNext, 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-exactNote 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'sdependenciesordevDependencies - Adds the
config.commitizenkey to the root of yourpackage.jsonfile 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.jsfile - file base names relative to
process.cwd()with.jsextension - 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.
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
precommithooks 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.
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.
Update .git/hooks/prepare-commit-msg with the following code:
#!/bin/bash
exec < /dev/tty && node_modules/.bin/cz --hook || trueFor husky users, add the following configuration to the project's package.json file:
"husky": {
"hooks": {
"prepare-commit-msg": "exec < /dev/tty && npx --no -- 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.
Add the "Commitizen friendly" badge to your README using the following markdown:
[](https://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.
Install commitizen globally, if you have not already.
npm install -g commitizenInstall your preferred commitizen adapter globally (for example cz-conventional-changelog).
npm install -g cz-conventional-changelogCreate a .czrc file in your home directory, with path referring to the preferred, globally-installed, commitizen adapter
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrcYou 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.
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.
// 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"
}
});// package.json
{
"name": "company-commit",
"bin": "./my-cli.js",
"dependencies": {
"commitizen": "^2.7.6",
"cz-conventional-changelog": "^1.1.5"
}
}npm install --save-dev company-commit
./node_modules/.bin/company-commitWe 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
- commit-jazzer
An adapter can work in one of two ways.
As a program (adapter protocol). Commitizen runs your adapter as its own
Node.js program, so you can use any prompt library, ES modules and top-level
await, and you don't need to depend on commitizen. Declare it in the
adapter's package.json:
{
"main": "./bin.js",
"commitizenAdapter": {
"protocol": [1],
"bin": "./bin.js"
}
}Commitizen runs bin with the same Node.js and your terminal, and sets:
| Variable | Meaning |
|---|---|
CZ_PROTOCOL |
The protocol version, currently 1. |
CZ_MESSAGE_FILE |
An empty file. Write the commit message to it. |
CZ_CONFIG_FILE |
A JSON file with the project's commitizen config (config.commitizen, .czrc or .cz.json). |
CZ_GIT_ROOT |
The repository root. |
Exit with 0 after writing the message and commitizen commits it, including
--hook and --retry support. Exit with 0 without writing anything to cancel,
or exit non-zero to abort; commitizen exits with the same status. main must
point at a file that exists, because commitizen resolves the adapter path the
same way for every adapter. See examples/protocol-adapter
for a complete adapter with no dependencies.
As a module (original API). Export a prompter(cz, commit) function.
Commitizen loads the module with require() and passes an instance of
Inquirer.js 8, though you can
capture input using whatever means necessary. Call the commit callback with a
string and we'll be happy. Existing adapters keep working this way.
Publish your adapter to npm, and you'll be all set!
Commitizen runs code from your project's dependencies, and sometimes from the repository itself. Plain git commit doesn't. This section explains the risks and what you can do about each.
- An adapter runs with your full permissions. Commitizen runs the adapter named in
config.commitizen.path, either inside its own process (aprompteradapter) or as a separate program (a protocol adapter). Either way it runs as you. It can read your files, SSH keys and environment variables (including tokens), change your working tree and staged files, and run git. Commitizen can't limit what an adapter does. - A repository can bring its own adapter.
config.commitizen.pathcan name a file inside the repository, such as./tools/adapter.js. Runninggit czin a repository you've just cloned can then run that repository's code, just asnpm testwould. - An adapter can change what gets committed. Commitizen commits whatever is staged when the adapter finishes.
- Some adapters send data elsewhere. Adapters that integrate with issue trackers or AI services may send your branch name, staged changes or message to that service.
- Commit messages are kept for
--retry. Commitizen saves the last message for each repository incommitizen.jsonin your user cache directory (for example~/Library/Caches/commitizenon macOS or~/.cache/commitizenon Linux). - Installing runs code. Depending on your package manager, installing an adapter can run install scripts from the adapter and any of its dependencies. A compromised release of any of them runs on your machine before you ever use commitizen.
npx czcan download an unrelated package. If commitizen isn't installed in the project,npx czlooks for an npm package namedcz, which isn't commitizen.
- Choose adapters as carefully as any dev dependency you run, such as a test runner or linter. Prefer widely used, maintained adapters, and read what an adapter sends to other services before giving it tokens.
- Check a repository before running
git czin it. Look atconfig.commitizenin itspackage.json,.czrcor.cz.json. A path starting with./runs code from the repository. - Check your commit with
git show --stat HEADwhen trying out an adapter you haven't reviewed. - Keep secrets out of commit messages. They end up in git history anyway.
- Run the commitizen installed in your project, not one npx downloads:
npx --no -- cz,pnpm exec czornode_modules/.bin/cz.--nomakes npx fail instead of downloading. - Commit your lockfile and install exact versions (
--save-exact, as in the examples above), so everyone runs the versions you reviewed. - Delay new releases. Most attacks through npm are found and removed within days. A minimum release age makes your package manager ignore versions newer than that, and avoid install scripts where you can:
| Package manager | commitizen init |
Install scripts from dependencies | Minimum release age |
|---|---|---|---|
| npm | default | Run by default. Use --ignore-scripts or ignore-scripts=true in .npmrc. |
min-release-age (days), npm 11.10+ |
| Yarn 1 | --yarn |
Run by default. Use --ignore-scripts. |
Not available |
| Yarn 2+ | --yarn |
Run by default. Set enableScripts: false in .yarnrc.yml. |
npmMinimalAgeGate, Yarn 4.10+ |
| pnpm | --pnpm |
Not run: commitizen passes --ignore-scripts, and pnpm 10+ runs dependency scripts only for packages you allow. |
minimumReleaseAge (minutes); on by default (1 day) in pnpm 11 |
| Bun | Not supported; install the adapter yourself and set config.commitizen.path |
Run only for packages in trustedDependencies (and Bun's built-in list). |
minimumReleaseAge in bunfig.toml (seconds) |
Commitizen itself passes the commit message to git as a single argument, never through a shell, so a message can't run commands.
To report a security problem in commitizen itself, use GitHub's private vulnerability reporting rather than a public issue.
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
-- --retryas an argument for your script. i.e:npm run commit -- --retry - Use npx to find and call the
czexecutable directly. i.e:npx --no -- cz --retry
Note that the last two options do not require you to pass -- before the args but the first does.
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.
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.
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.
Both! Commitizen is not meant to be a replacement for git commit hooks. Rather, it is meant to work side-by-side with them to ensure a consistent and positive experience for your contributors. Commitizen treats the commit command as a declarative action. The contributor is declaring that they wish to contribute to your project. It is up to you as the maintainer to define what rules they should be following.
We accomplish this by letting you define which adapter you'd like to use in your project. Adapters just allow multiple projects to share the same commit message conventions. A good example of an adapter is the cz-conventional-changelog adapter.
- conventional-changelog – Generate a changelog from conventional commit history
- commitlint - Lint commit messages
@JimTheDev (Jim Cummins, author) @kentcdodds @accraze @kytwb @Den-dp
Special thanks to @stevelacy, whose gulp-git project makes commitizen possible.
This project exists thanks to all the people who contribute. [Contribute].
Thank you to all our backers! 🙏 [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
