Skip to main content

diff2commit

🤖 An AI-powered Git commit message generator that creates clear, descriptive commit messages following the Conventional Commits specification.

Features

  • AI-Powered Generation: Leverages GPT-4, Claude, or Gemini to analyze your changes and generate meaningful commit messages.
  • Conventional Commits: Automatically formats messages according to the Conventional Commits specification.
  • Interactive Review: Review, edit, and approve messages before committing.
  • Multiple AI Providers: Support for OpenAI, Anthropic Claude, and Google Gemini.
  • Cost Tracking: Monitor token usage and API costs.
  • Customizable: Configure models, prompts, and message formats.
  • Beautiful CLI: Rich terminal UI with syntax highlighting.

Installation

pip install diff2commit

From Source

git clone https://github.com/maadhav-codes/diff2commit.git
cd diff2commit
pip install -e .

Using pipx (Isolated Installation)

pipx install diff2commit

Quick Start

  1. Set your API key:
export D2C_API_KEY='your-openai-api-key'
  1. Stage your changes:
git add .
  1. Generate and commit:
diff2commit generate

Usage

Generate Commit Message

# Generate with interactive review
diff2commit generate

# Generate multiple suggestions
diff2commit generate --count 3

# Use a different AI provider
diff2commit generate --provider anthropic

# Use specific model
diff2commit generate --model gpt-4-turbo

# Skip interactive review
diff2commit generate --no-review

# Generate without committing
diff2commit generate --no-commit

View Usage Statistics

# Total usage
diff2commit usage

# Current month usage
diff2commit usage --monthly

# Usage by provider
diff2commit usage --by-provider

View Configuration

diff2commit config

Version Information

diff2commit version

Configuration

Environment Variables

Create a .env file in your project or set environment variables:

# Required
D2C_API_KEY=your-api-key-here

# Optional
D2C_AI_PROVIDER=openai          # openai, anthropic, or gemini
D2C_AI_MODEL=gpt-4              # Model name
D2C_MAX_TOKENS=200           # Max tokens for generation
D2C_TEMPERATURE=0.7          # Sampling temperature (0.0-2.0)
D2C_COMMIT_FORMAT=conventional
D2C_INCLUDE_EMOJI=false
D2C_MAX_SUBJECT_LENGTH=72
D2C_TRACK_USAGE=true

Configuration File

Create ~/.config/diff2commit/config.toml:

ai_provider = "openai"
ai_model = "gpt-4"
max_tokens = 200
temperature = 0.7
commit_format = "conventional"
include_emoji = false
max_subject_length = 72
track_usage = true

Conventional Commits Format

The tool generates messages following the Conventional Commits specification:

<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Types

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation changes
  • style: Formatting changes
  • refactor: Code refactoring
  • perf: Performance improvements
  • test: Adding or modifying tests
  • build: Build system changes
  • ci: CI configuration changes
  • chore: Other changes

AI Providers

OpenAI (GPT-4)

export D2C_API_KEY='sk-...'
export D2C_AI_PROVIDER='openai'
export D2C_AI_MODEL='gpt-4'

Anthropic Claude

export D2C_API_KEY='sk-ant-...'
export D2C_AI_PROVIDER='anthropic'
export D2C_AI_MODEL='claude-3-sonnet-20240229'

Google Gemini

export D2C_API_KEY='AI...'
export D2C_AI_PROVIDER='gemini'
export D2C_AI_MODEL='gemini-pro'

Cost Management

Track and manage API costs:

# View total costs
diff2commit usage

# View monthly costs
diff2commit usage --monthly

# Set monthly limit (in config)
D2C_COST_LIMIT_MONTHLY=10.0

Development

Setup Development Environment

git clone https://github.com/maadhav-codes/diff2commit.git
cd diff2commit
pip install -e ".[dev]"

Run Tests

pytest tests/

Linting

ruff check .
black --check .
mypy src/

Format Code

black .
ruff check --fix .

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support


Made with ❤️ by maadhav-codes

Metadata

Release files for diff2commit 1.0.1

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

Source distribution (sdist)

Source distribution for diff2commit 1.0.1
File Size Uploaded Provenance Actions
diff2commit-1.0.1.tar.gz 24.8 kB With provenance Details for diff2commit-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for diff2commit 1.0.1
File Interpreter ABI Platform Actions
diff2commit-1.0.1-py3-none-any.whl Python 3 none any Details for diff2commit-1.0.1-py3-none-any.whl

Total release size: 52.9 kB

Release files / diff2commit-1.0.1.tar.gz

Download URL diff2commit-1.0.1.tar.gz
Size 24.8 kB
Tags Source
SHA-256 checksum
How to use checksums
07e64e9eeeb36c34b46c453ef8d0897410e423a2923be93a550ee4d747e577e3
BLAKE2b-256 checksum
How to use checksums
158c0a2a01dcbd23f3c69362e46c422b095b8707792507083a291e65d346e6c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2025.

Transparency log

Release files / diff2commit-1.0.1-py3-none-any.whl

Download URL diff2commit-1.0.1-py3-none-any.whl
Size 28.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffb6580503ccc2037476aedb0535a5beb188db4c07b5a58f5a2e7ac3452770bf
BLAKE2b-256 checksum
How to use checksums
704d1769d7581389743d652217a1cdacf649ff30965e53058ef245ec1115cf33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2025.

Transparency log

Security for diff2commit 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for diff2commit-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

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