Skip to main content

🚀 ai-git-commit-gen

AI-powered git commit message generator - Zero configuration, instant intelligent commits

PyPI version Python License: MIT Code style: black

Generate meaningful git commit messages instantly using AI. No API keys required - works right out of the box with free HuggingFace models.

✨ Features

  • 🔑 Zero Configuration - No API keys or setup required
  • 🤖 AI-Powered - Uses state-of-the-art language models
  • 🎨 Multiple Styles - Conventional commits, Gitmoji, or simple format
  • ⚡ Lightning Fast - Smart caching for instant repeated suggestions
  • 🎯 Context Aware - Analyzes your actual code changes
  • 📝 Interactive CLI - Beautiful terminal UI with rich formatting
  • 🔄 Regenerate - Don't like the suggestions? Generate new ones instantly
  • ✏️ Edit Mode - Fine-tune messages before committing

📦 Installation

pip install ai-git-commit-gen

That's it! No configuration needed.

🚀 Quick Start

  1. Stage your changes:
git add .
  1. Generate commit message:
gcai generate
  1. Select from AI-generated suggestions or regenerate for new options!

📖 Usage

Basic Commands

# Generate commit message suggestions
gcai generate
gcai g  # Short alias

# Auto-commit with first suggestion
gcai generate --auto

# Generate more suggestions
gcai generate --num 5

# Use different commit styles
gcai generate --style conventional  # Default
gcai generate --style gitmoji       # With emojis 🎨
gcai generate --style simple        # Simple format

# Dry run - see what would be committed
gcai generate --dry-run

# Check if ready to generate
gcai check

Interactive Mode

When you run gcai generate, you'll see:

🔍 Analyzing staged changes...

📁 Files changed:
   📝 src/auth/jwt.py (modified)
   ✨ src/auth/refresh.py (added)
   📝 tests/test_auth.py (modified)

✨ Suggested commit messages:

  [1] feat(auth): implement JWT refresh token rotation
  [2] fix(auth): add automatic token refresh mechanism
  [3] feat(auth): add refresh token support with rotation

Select [1-3], [r]egenerate, [e]dit, or [q]uit:

Choose an option:

  • 1-3: Select a suggestion
  • r: Generate new suggestions
  • e: Edit selected message before committing
  • q: Quit without committing

🎨 Commit Styles

Conventional Commits (Default)

feat(auth): add JWT refresh token rotation
fix(api): handle null response in user endpoint
docs(readme): update installation instructions

Gitmoji

✨ feat(auth): add JWT refresh token rotation
🐛 fix(api): handle null response in user endpoint
📝 docs(readme): update installation instructions

Simple

Add JWT refresh token rotation
Fix null response handling in user endpoint
Update readme installation instructions

🛠️ Advanced Features

Caching

git-commit-ai intelligently caches suggestions for identical changes, making repeated operations instant.

Smart Diff Handling

Large diffs are automatically truncated while preserving the most important context.

Fallback Mechanisms

  • Primary model unavailable? Automatically switches to backup model
  • No internet? Generates basic but functional commit messages
  • Rate limited? Implements smart exponential backoff

🧪 Development

Setup Development Environment

# Clone the repository
git clone https://github.com/yourusername/git-commit-ai.git
cd git-commit-ai

# Install in development mode
pip install -e .

# Install development dependencies
pip install pytest pytest-asyncio pytest-cov

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=git_commit_ai --cov-report=html

# Run specific test file
pytest tests/test_cli.py

Code Quality

# Format code
ruff format src tests

# Lint
ruff check src tests

# Type checking (optional, if using mypy)
mypy src

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (using git-commit-ai of course! 😄)
  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

  • Built with Typer for the amazing CLI experience
  • Powered by HuggingFace free inference API
  • Beautiful terminal output with Rich
  • Git operations via GitPython

🐛 Troubleshooting

"Not a git repository"

Make sure you're in a git repository. Initialize one with:

git init

"No staged changes found"

Stage your changes first:

git add .

"API is busy, retrying..."

The free HuggingFace API may be under load. The tool will automatically retry with exponential backoff.

Network Issues

Check your internet connection. The tool will fallback to basic commit messages if the API is unreachable.

📊 Stats

  • ⚡ Average response time: 2-3 seconds
  • 🎯 Suggestion accuracy: High
  • 💾 Cache hit rate: ~30% in typical usage
  • 🔄 API reliability: 99%+ with fallback

🚗 Roadmap

  • Support for commit body generation
  • Custom prompt templates
  • Git hooks integration
  • Multiple language support
  • Team-specific style guides
  • VSCode extension
  • Pre-commit integration

Made with ❤️ by developers, for developers

Report Bug • Request Feature

Metadata

Release files for ai-git-commit-gen 0.1.2

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

Source distribution (sdist)

Source distribution for ai-git-commit-gen 0.1.2
File Size Uploaded Provenance
ai_git_commit_gen-0.1.2.tar.gz 25.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ai-git-commit-gen 0.1.2
File Interpreter ABI Platform
ai_git_commit_gen-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 43.9 kB

Release files / ai_git_commit_gen-0.1.2.tar.gz

Download URL ai_git_commit_gen-0.1.2.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
685e299327ac8d0c59765f777cf854834a15a6fd4d519008c22531b012e48891
BLAKE2b-256 checksum
How to use checksums
b4e418fae721153f6358cfdd279893869ea8eaa6ee7e80d8834fd9ede41f2d97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / ai_git_commit_gen-0.1.2-py3-none-any.whl

Download URL ai_git_commit_gen-0.1.2-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad8fe4fee077ff93e3e1f517e6ea84e08edb4181e5dc0aec9d8b30506fcd2b53
BLAKE2b-256 checksum
How to use checksums
53e8339507ed14f9f62e612e463d0e76c1c1e28e3dab49fd578d7c5253bd5c29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for ai-git-commit-gen 0.1.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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