Skip to main content

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:

  1. Read your staged diff
  2. Generate a commit message using Claude AI
  3. 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 to notepad on Windows, vi on 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, docs, style, refactor, test, chore

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:

  1. Tests are re-run as a gate
  2. The tag version is verified to match the version in pyproject.toml
  3. The package is built and published to PyPI
  4. 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

By default the tool produces no diagnostic output. To enable logging, set the GIT_COMMIT_AI_LOG_LEVEL environment variable before running the command. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_commit_msg_ai-2.0.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_commit_msg_ai-2.0.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file git_commit_msg_ai-2.0.1.tar.gz.

File metadata

  • Download URL: git_commit_msg_ai-2.0.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for git_commit_msg_ai-2.0.1.tar.gz
Algorithm Hash digest
SHA256 e7b598aeb93cf17f52fb5511d02c9548f52ffba408c43244ee801a6b8903a38b
MD5 e36b93b11ad40ddb95f18a0e0bc4f2fe
BLAKE2b-256 53f0cae737cdc786c1abac4650bbf63b454038f0c957b03138d0578d61e4c9ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_commit_msg_ai-2.0.1.tar.gz:

Publisher: cd.yml on ankit-d-joshi/git-commit-message-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file git_commit_msg_ai-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for git_commit_msg_ai-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 356c6be95c76e53ccd00ad1b4c0ac60c1670280d2e23dd04b412ae4eaede00f6
MD5 df9c92f9a714cb1b0d8392639eac5cb5
BLAKE2b-256 e6c52ab2d84d9d4f0516dfe9e85bb88c5631300f4ce4d78165874ea7c1ae11c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_commit_msg_ai-2.0.1-py3-none-any.whl:

Publisher: cd.yml on ankit-d-joshi/git-commit-message-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page