Skip to content

Commitizen

A tool for creating standardized commit messages and automated versioning in your project.


What is it used for here?

!

  • standardizing commit messages using the Conventional Commits specification
  • automatically bumping project version and generating/updating CHANGELOG.md and pyproject.toml (only updating)
  • integrating with pre-commit hooks to ensure commit messages follow the defined style

Features

  • Interactive CLI for creating conventional commit messages via a wizard.
  • Automatic version bump based on commit history (major, minor, patch).
  • Generates and updates CHANGELOG.md and pyproject.toml (only updating) automatically.

How to use it?

  • In this case, the Makefile does the same as running the commands directly via uv. The Makefile is only needed to shorten commands.

!

make commit   # Interactive commit message creation (wizard)
make bump     # Bump version and update CHANGELOG.md
cz commit # or cz c
cz bump
uv run cz commit # or uv run cz c
uv run cz bump

How to use it with pre-commit?

To use Commitizen with pre-commit, you need to add a configuration for it in your .pre-commit-config.yaml file.

!

.pre-commit-config.yaml
- repo: https://github.com/commitizen-tools/commitizen
  rev: v4.8.3
  hooks:
    - id: commitizen
      stages: [commit-msg]

Configuration

All configuration for Commitizen in this template is located in pyproject.toml under the [tool.commitizen] section.


Example workflow

Without pre-commit

  • In the sense that the hook will run, but your message will be ignored because it matches the structure

!

  1. Create a commit using make commit (or cz commit). The interactive CLI will help you compose a valid commit message.
  2. Bump version and generate changelog using make bump (or cz bump). This updates the version in pyproject.toml and regenerates CHANGELOG.md based on your commit history.
  3. Push changes: Push your code and the updated changelog/version to your repository.

With pre-commit

  • The pre-commit hook will check the message format.

!

  1. Create a commit using git commit -m "feat: add new feature".
  2. Bump version and generate changelog using make bump (or cz bump). This updates the version in pyproject.toml and regenerates CHANGELOG.md based on your commit history.
  3. Push changes: Push your code and the updated changelog/version to your repository.

For more details on configuration, see the Commitizen Documentation