Commitizen is a tool that helps standardize commit messages following the Conventional Commits specification, making your Git history more readable and useful.
Commitizen provides a command-line interface that guides you through creating properly formatted commit messages. It helps:
- Enforce a consistent commit message format
- Generate changelogs automatically
- Simplify semantic versioning
- Improve collaboration through clear commit intentions
- Make Git history more readable and useful
Commitizen is included as a development dependency:
# Install with other development dependencies
uv sync --devTo install it directly:
uv pip install commitizenIn this project, Commitizen is used to:
- Standardize commit messages following the Conventional Commits specification
- Enforce commit message format through pre-commit hooks
- Facilitate automatic changelog generation
- Support semantic versioning
Commitizen is configured in the pyproject.toml file:
[tool.commitizen]
name = "cz_conventional_commits"
version = "0.1.0"
tag_format = "v$version"Instead of using git commit directly, use:
# Interactive commit creation
uv run cz commit
# Or the shorter alias
uv run cz cThis will guide you through a series of prompts:
- Select the type of change (feat, fix, docs, etc.)
- Enter the scope (optional)
- Write a short description
- Provide a longer description (optional)
- Indicate breaking changes (optional)
- Reference issues (optional)
# Commit with a message directly
uv run cz commit -m "feat: add new feature"
# Commit all changes
uv run cz commit -a
# Check if the last commit message follows the convention
uv run cz check --rev-range HEAD~1..HEAD<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
feat(auth): add OAuth2 authentication
Implement OAuth2 authentication flow with Google and GitHub providers.
BREAKING CHANGE: The previous authentication system is no longer supported.
Refs: #123
fix(api): correct response status code for invalid requests
The API was returning 500 instead of 400 for invalid requests.
docs: update installation instructions
Update installation instructions to include the new uv package manager.
- Be specific in your commit messages: Clearly describe what changes were made and why.
- Use appropriate types: Choose the correct type (feat, fix, docs, etc.) for your changes.
- Include scope when relevant: Specify which part of the codebase was affected.
- Reference issues: Link commits to related issues or pull requests.
- Keep descriptions concise: Aim for 50-72 characters in the summary line.
- Use imperative mood: Write "add feature" instead of "added feature" or "adds feature".
| Type | Description |
|---|---|
feat |
A new feature |
fix |
A bug fix |
docs |
Documentation changes |
style |
Code style changes (formatting, missing semi-colons) |
refactor |
Code changes that neither fix bugs nor add features |
perf |
Performance improvements |
test |
Adding or correcting tests |
build |
Changes to build system or dependencies |
ci |
Changes to CI configuration |
chore |
Other changes that don't modify src or test files |