About this project
Commitizen helps teams enforce and communicate commit-message conventions while the commit is being created. Instead of waiting for a hook to reject an invalid message, contributors answer prompts for the required fields, and the selected adapter generates the formatted commit message.
The tool is distributed through npm and can be installed globally with npm install -g commitizen, run directly with npx cz, or installed as a project devDependency so every contributor uses the same version. In a configured repository, users can run git cz, cz, or git-cz in place of git commit. It can also be exposed through an npm script.
A repository is made Commitizen-friendly by choosing an adapter. The documented setup uses commitizen init cz-conventional-changelog with npm, Yarn, or pnpm, which installs the adapter, saves it to package.json, and adds the config.commitizen.path setting. Configuration can instead be placed in a .czrc file. The adapter path can resolve npm packages, local JavaScript files, directories containing index.js, relative paths, or absolute paths.
Commitizen is adapter-based, so projects can use published options such as cz-conventional-changelog, cz-customizable, cz-emoji, cz-commitlint, cz-git, Jira-oriented adapters, or build their own. Custom adapters receive an Inquirer.js instance and return the final commit string through a commit callback.
For maintainers who want the prompts to appear during a normal git commit, Commitizen can be invoked from a prepare-commit-msg Git hook using the --hook option. The README provides examples for both traditional Git hooks and Husky, including redirecting input from /dev/tty so the hook can be interactive. Commitizen is intended to work alongside commit hooks and related tools rather than replace them.
Other capabilities include global configuration through ~/.czrc for use across repositories, support for standard git commit options such as git cz -a, and a multi-repository pattern where a team can publish a small custom Node.js CLI that bootstraps Commitizen with a fixed adapter. The git cz --retry command can reuse the previous attempted commit after a failed hook or test run, with retry data tied to the repository path and potentially cleared by upgrades or cache-file deletion.
The README lists tested Node.js versions 12, 14, and 16 and requires npm 6 or greater, while noting that it may work on older Node.js versions. Related projects mentioned include conventional-changelog for generating changelogs and commitlint for linting commit messages.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.