Skip to main content

conventional-commit-hook

CI Coverage PyPI Conda Version Python License: MIT

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 and BREAKING CHANGE footer
  • 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: value or Token #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

Metadata

Release files for conventional-commit-hook 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for conventional-commit-hook 0.1.0
File Size Uploaded
conventional_commit_hook-0.1.0.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for conventional-commit-hook 0.1.0
File Interpreter ABI Platform
conventional_commit_hook-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.7 kB

Release files / conventional_commit_hook-0.1.0.tar.gz

Download URL conventional_commit_hook-0.1.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
814a30e2f3d99d34b13dbf5ff45f307732b1b862170fa974408ef76489bc0728
BLAKE2b-256 checksum
How to use checksums
cced51e4a306a27d2c749bb5621da238aebbde0f2624b1512188c9a267f19522
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / conventional_commit_hook-0.1.0-py3-none-any.whl

Download URL conventional_commit_hook-0.1.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4253e1f3523bec7d245c479457ef85b01a6a0cd7018c409eb3f6099e3a557731
BLAKE2b-256 checksum
How to use checksums
95549c493f78ba64a9bbbbedb9f34f348dac2e3ade434411841b31631d60d776
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page