AI-powered git commit message generator following Conventional Commits
Project description
git-commit-msg-ai
AI-powered git commit message generator that follows the Conventional Commits specification.
Prerequisites
-
Python 3.14+
-
An Anthropic API key set as an environment variable:
export ANTHROPIC_API_KEY=sk-ant-... # macOS/Linux
[System.Environment]::SetEnvironmentVariable('ANTHROPIC_API_KEY', 'sk-ant-...', 'User') # Windows
Development Setup
Clone the repository, create a virtual environment, and install the project in editable mode with all dev dependencies:
python -m venv .venv
Activate the virtual environment:
# macOS/Linux
source .venv/bin/activate
# Windows PowerShell
.venv\Scripts\Activate.ps1
Install the project and dev dependencies:
pip install -e ".[dev]"
After activation the git-commit-msg-ai entry-point is on your PATH. You can also run the dev toolchain:
pytest # run tests with coverage
ruff check . # lint
mypy . # type-check
Installation
pip install git-commit-msg-ai
Usage
Stage your changes, then run the tool from inside any git repository:
git add <files>
git-commit-msg-ai
The tool will:
- Read your staged diff
- Generate a commit message using Claude AI
- Print the message and prompt you to choose:
[a]ccept / [e]dit / [r]eject:
- a - commits immediately with the generated message
- e - opens the message in your
$EDITOR(defaults tonotepadon Windows,vion Linux/macOS), lets you modify it, then commits - r - exits without committing
Commit message format
Generated messages follow the Conventional Commits specification:
<type>(<optional scope>): <short subject>
- Bullet explaining why this change was made
- Another reason if applicable
For breaking changes, the subject line gets a ! and a footer is added:
feat(api)!: remove deprecated endpoint
- Endpoint was unused and blocking the new auth rollout
BREAKING CHANGE: /v1/legacy is no longer available
Supported types: feat, fix, revert, build, ci, docs, perf, refactor, style, test (configurable — see Configuration)
revert commits always follow this format: the subject line begins with revert: followed by the header of the reverted commit, and the body must contain This reverts commit <hash>.
Configuration
The set of optional commit types the AI may use can be customised through a config file. feat, fix, and revert are always included regardless of any configuration.
Config file locations and precedence
The tool checks the following locations in order, using the first one that defines a types list:
- Project-level —
pyproject.tomlwalked up from the current working directory, under[tool.git-commit-msg-ai] - User-level —
~/.git-commit-msg-ai.tomlin your home directory - Built-in defaults — used when neither config file is present or neither defines
types
Config file formats
Project-level (pyproject.toml):
[tool.git-commit-msg-ai]
types = ["build", "ci", "docs", "perf", "refactor", "style", "test"]
User-level (~/.git-commit-msg-ai.toml):
types = ["build", "ci", "docs", "chore"]
Setting types = [] restricts the AI to only the three mandatory types (feat, fix, revert).
Default optional types
| Type | Purpose |
|---|---|
build |
Changes to the build system or external dependencies |
ci |
Changes to CI configuration files and scripts |
docs |
Documentation-only changes |
perf |
A code change that improves performance |
refactor |
A code change that neither fixes a bug nor adds a feature |
style |
Changes that do not affect the meaning of the code (whitespace, formatting) |
test |
Adding missing tests or correcting existing tests |
CI/CD
Every push to main and every pull request runs the full CI pipeline (lint, type-check, tests, build).
Pushing a version tag (e.g. v1.5.2) triggers the CD pipeline:
- Tests are re-run as a gate
- The tag version is verified to match the version in
pyproject.toml - The package is built and published to PyPI
- A GitHub Release is created with release notes generated by Claude Sonnet from the commit log
Releasing a new version:
# 1. Bump the version in pyproject.toml
# 2. Commit and push
git add pyproject.toml
git commit -m "chore: bump version to 1.5.2"
git push origin main
# 3. Tag and push - this triggers the CD pipeline
git tag v1.5.2
git push origin v1.5.2
Debugging
When a failure occurs (git error, API error, editor error), the tool always prints an error message to stderr. Diagnostic logs are disabled by default; to enable them, set the GIT_COMMIT_AI_LOG_LEVEL environment variable before running the command. Both error messages and logs are written to stderr and do not interfere with the generated commit message on stdout.
Valid values: DEBUG, INFO, WARNING, ERROR, CRITICAL
# macOS/Linux - show all internal diagnostic messages
GIT_COMMIT_AI_LOG_LEVEL=DEBUG git-commit-msg-ai
# Windows PowerShell
$env:GIT_COMMIT_AI_LOG_LEVEL = 'DEBUG'
git-commit-msg-ai
| Level | What you see |
|---|---|
DEBUG |
git commands run, API model/token params, temp file paths, char counts |
INFO |
commit message generated (with char count), commit created |
WARNING |
no staged changes found |
ERROR |
git not found, API failures, editor errors |
License
This project is released under the MIT License.
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 git_commit_msg_ai-2.1.1.tar.gz.
File metadata
- Download URL: git_commit_msg_ai-2.1.1.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a14ec4e81e7b0fd1b84fc7b59a6c15da9c18583a622415d8370fb09d55efb7d4
|
|
| MD5 |
d47fce23f075994df6918944b5cf47c2
|
|
| BLAKE2b-256 |
d03f8aeb41053fd215cf275661dc87bf151a2e39970a4ddf3ea737a1837e93e3
|
Provenance
The following attestation bundles were made for git_commit_msg_ai-2.1.1.tar.gz:
Publisher:
cd.yml on ankit-d-joshi/git-commit-message-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_commit_msg_ai-2.1.1.tar.gz -
Subject digest:
a14ec4e81e7b0fd1b84fc7b59a6c15da9c18583a622415d8370fb09d55efb7d4 - Sigstore transparency entry: 1692431921
- Sigstore integration time:
-
Permalink:
ankit-d-joshi/git-commit-message-ai@2fc2f0a98e5775a6f481107a5561ac1c98174b8a -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/ankit-d-joshi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@2fc2f0a98e5775a6f481107a5561ac1c98174b8a -
Trigger Event:
push
-
Statement type:
File details
Details for the file git_commit_msg_ai-2.1.1-py3-none-any.whl.
File metadata
- Download URL: git_commit_msg_ai-2.1.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a860bd78b875629b88a149e5be24f9ee293916b938021286a5cf704b4f2d218
|
|
| MD5 |
140784281ae1274dec8e99be24f05d6e
|
|
| BLAKE2b-256 |
735e27e3c10ca31508cb9e29d6144935a6f0a77986e1667a0235c8d6460dc361
|
Provenance
The following attestation bundles were made for git_commit_msg_ai-2.1.1-py3-none-any.whl:
Publisher:
cd.yml on ankit-d-joshi/git-commit-message-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_commit_msg_ai-2.1.1-py3-none-any.whl -
Subject digest:
5a860bd78b875629b88a149e5be24f9ee293916b938021286a5cf704b4f2d218 - Sigstore transparency entry: 1692432065
- Sigstore integration time:
-
Permalink:
ankit-d-joshi/git-commit-message-ai@2fc2f0a98e5775a6f481107a5561ac1c98174b8a -
Branch / Tag:
refs/tags/v2.1.1 - Owner: https://github.com/ankit-d-joshi
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@2fc2f0a98e5775a6f481107a5561ac1c98174b8a -
Trigger Event:
push
-
Statement type: