A pre-commit hook that enforces Conventional Commits standards on commit messages
Project description
conventional-commit-hook
A pre-commit hook that validates commit messages against the Conventional Commits specification.
Features
- Validates commit message structure: type, optional scope, optional breaking marker, description
- Enforces all 11 standard Conventional Commit types out of the box
- Custom type overrides via
--types - Detects breaking changes from both the
!header marker andBREAKING CHANGEfooter - Strips git-generated comment lines and scissors line before validation
- Silent on success — writes only to stderr on failure, never to stdout
- Single runtime dependency: structlog
Installation
Add to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/millsks/conventional-commit-hook
rev: v0.1.0
hooks:
- id: conventional-commit-hook
Install the hook:
pre-commit install --hook-type commit-msg
Usage
The hook runs automatically on git commit. It exits 0 (silent) on a valid message, or 1 (error to stderr) on an invalid one.
Supported commit types
| Type | Purpose |
|---|---|
feat |
New feature |
fix |
Bug fix |
docs |
Documentation only |
style |
Formatting, no logic change |
refactor |
Code restructure, no feature or fix |
perf |
Performance improvement |
test |
Adding or fixing tests |
build |
Build system or dependency changes |
ci |
CI configuration changes |
chore |
Maintenance tasks |
revert |
Revert a previous commit |
Message format
<type>[(<scope>)][!]: <description>
[body]
[footer(s)]
- type — one of the 11 types above (lowercase)
- scope — optional, enclosed in parentheses:
fix(auth): … - ! — optional breaking change marker:
feat!: … - description — required, non-empty, starts immediately after
: - body — optional, separated from the header by a blank line
- footers — optional, each on its own line as
Token: valueorToken #value;BREAKING CHANGE: …marks a breaking release
Valid examples
feat: add user authentication
fix(auth): resolve null pointer on login
feat!: drop Python 2 support
feat(api)!: remove v1 endpoints
docs: update installation instructions
With body and footers:
feat: add OAuth2 support
Implements the PKCE flow with refresh token rotation.
BREAKING CHANGE: the /auth/token endpoint now requires a code_verifier
Reviewed-by: Alice <alice@example.com>
Invalid examples
# Missing type
Add user authentication
# Uppercase type
Feat: add something
# Missing space after colon
feat:add something
# No blank line before body
feat: add login
Body text without a blank line separator
Custom types
Override the allowed type set with --types:
hooks:
- id: conventional-commit-hook
args: [--types, feat, fix, hotfix, chore]
When --types is supplied, only those types are accepted. Standard types not listed are rejected.
Development
See CONTRIBUTING.md for the full workflow.
Prerequisites
Pixi — all other dependencies are managed by Pixi.
Setup
git clone https://github.com/millsks/conventional-commit-hook
cd conventional-commit-hook
pixi run bootstrap
Common tasks
| Command | Purpose |
|---|---|
pixi run test |
Unit tests only (fast inner loop) |
pixi run test-integration |
Integration tests |
pixi run cov |
Full suite + coverage gate (≥90%) |
pixi run fmt |
Auto-format with ruff |
pixi run lint |
Lint with ruff |
pixi run check |
Type-check with mypy (strict) |
pixi run build |
Build wheel + sdist |
pixi run ci |
Full CI gate — must pass before committing |
License
MIT — Copyright (c) 2026 Kevin Mills
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file conventional_commit_hook-0.1.0.tar.gz.
File metadata
- Download URL: conventional_commit_hook-0.1.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
814a30e2f3d99d34b13dbf5ff45f307732b1b862170fa974408ef76489bc0728
|
|
| MD5 |
abcdbeda236ff48e9e2c4b198f7ebb2c
|
|
| BLAKE2b-256 |
cced51e4a306a27d2c749bb5621da238aebbde0f2624b1512188c9a267f19522
|
File details
Details for the file conventional_commit_hook-0.1.0-py3-none-any.whl.
File metadata
- Download URL: conventional_commit_hook-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4253e1f3523bec7d245c479457ef85b01a6a0cd7018c409eb3f6099e3a557731
|
|
| MD5 |
f5b55e1f4d24669b8ec032e9194a17ed
|
|
| BLAKE2b-256 |
95549c493f78ba64a9bbbbedb9f34f348dac2e3ade434411841b31631d60d776
|