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
From PyPI (Recommended)
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
- Set your API key:
export D2C_API_KEY='your-openai-api-key'
- Stage your changes:
git add .
- 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 featurefix: A bug fixdocs: Documentation changesstyle: Formatting changesrefactor: Code refactoringperf: Performance improvementstest: Adding or modifying testsbuild: Build system changesci: CI configuration changeschore: 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.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with Typer for CLI
- Rich for beautiful terminal output
- GitPython for Git operations
- Inspired by the Conventional Commits specification
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)
| 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)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 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 logRelease 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 logSecurity 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.
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 logA 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.