A git commit message generator for personal use.
Project description
lazy-commit
A smart git commit message generator that uses AI to create high-quality commit messages following the Conventional Commits specification. It analyzes your git changes and automatically generates descriptive commit messages.
Features
- 🤖 AI-Powered: Uses OpenAI-compatible APIs to generate intelligent commit messages
- 📝 Conventional Commits: Follows the Conventional Commits specification format
- 🎯 Smart File Analysis: Automatically analyzes changed files and generates appropriate diffs
- 🚫 Intelligent Filtering: Excludes lock files and binary files from analysis while still including them in commits
- ⚡ Context Compression: Automatically compresses large diffs to fit within token limits
- 🔄 Auto-Push Support: Optional automatic push to remote repository after commit
- 🎨 Rich UI: Beautiful command-line interface with progress bars and status indicators
- 📊 File Status Display: Shows modified, added, and deleted files with clear indicators
Installation
Using uv (recommended)
uv tool install lazy-commit
From source
git clone https://github.com/QIN2DIM/lazy-commit.git
cd lazy-commit
uv sync
Configuration
Set the required environment variables:
# For OpenAI API
export LAZY_COMMIT_OPENAI_BASE_URL="https://api.openai.com/v1"
export LAZY_COMMIT_OPENAI_API_KEY="your-openai-api-key"
export LAZY_COMMIT_OPENAI_MODEL_NAME="gpt-4o-mini"
# For free models via OpenRouter
export LAZY_COMMIT_OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export LAZY_COMMIT_OPENAI_API_KEY="sk-or-v1-xxx"
export LAZY_COMMIT_OPENAI_MODEL_NAME="moonshotai/kimi-k2:free"
# For Chinese users - free models via ModelScope
export LAZY_COMMIT_OPENAI_BASE_URL="https://api-inference.modelscope.cn/v1"
export LAZY_COMMIT_OPENAI_API_KEY="ms-xxx"
export LAZY_COMMIT_OPENAI_MODEL_NAME="Qwen/Qwen3-30B-A3B-Instruct-2507"
# Optional: Set maximum context size (default: 32000)
export LAZY_COMMIT_MAX_CONTEXT_SIZE=32000
Environment File
You can also create a .env file in your project root:
For OpenRouter (free models):
LAZY_COMMIT_OPENAI_BASE_URL=https://openrouter.ai/api/v1
LAZY_COMMIT_OPENAI_API_KEY=sk-or-v1-xxx
LAZY_COMMIT_OPENAI_MODEL_NAME=moonshotai/kimi-k2:free
For Chinese users - ModelScope (free models):
LAZY_COMMIT_OPENAI_BASE_URL="https://api-inference.modelscope.cn/v1"
LAZY_COMMIT_OPENAI_API_KEY="ms-xxx"
LAZY_COMMIT_OPENAI_MODEL_NAME="Qwen/Qwen3-30B-A3B-Instruct-2507"
Usage
Basic Usage
Generate a commit message only (display message without applying):
commit
or if installed from source:
uv run commit
Stage and Commit
Generate commit message, stage files, and apply commit (without push):
commit --add
Auto-push After Commit
Generate commit message, stage files, apply commit, and push to remote:
commit --push
Note: When --push is enabled, --add is automatically enabled.
How It Works
- Repository Detection: Automatically detects git repository root
- File Analysis: Scans for modified, staged, and untracked files
- Smart Filtering: Excludes files like
*.lock,*.ipynbfrom AI analysis but includes them in commits - Diff Generation: Creates comprehensive diffs for all relevant changes
- Context Management: Compresses large diffs to fit within AI model context limits
- AI Generation: Uses AI to generate a structured commit message following Conventional Commits
- Display Message: Always displays the generated commit message
- Optional Staging & Commit: If
--addis used, stages all changes and applies the generated commit message - Optional Push: If
--pushis used, pushes changes to remote repository after commit
Commit Message Format
The tool generates commit messages following the Conventional Commits specification:
<type>(<scope>): <description>
[optional body]
[optional footer]
Commit Types
feat: New featuresfix: Bug fixesdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringperf: Performance improvementstest: Test additions or modificationsbuild: Build system changesci: CI/CD changeschore: Maintenance tasks
Examples
Feature Addition
feat(api): add user authentication endpoint
Implements JWT-based authentication with login and logout functionality.
Includes input validation and error handling for invalid credentials.
Bug Fix
fix(payment): correct tax calculation error
Fixed off-by-one error in tax calculation loop that was causing
incorrect tax amounts for orders with multiple items.
Documentation
docs(README): update installation and configuration instructions
Added detailed setup guide for environment variables and
included examples for different AI providers.
Requirements
- Python 3.12+
- Git repository
- OpenAI-compatible API access (OpenAI, local models, etc.)
Dependencies
typer: Command-line interfaceopenai: OpenAI API clientpydantic-settings: Configuration managementrich: Beautiful terminal outputloguru: Loggingtiktoken: Token counting
Development
Setup Development Environment
git clone https://github.com/QIN2DIM/lazy-commit.git
cd lazy-commit
uv sync --group dev
Code Quality
# Format code
uv run black src/
# Lint code
uv run ruff check src/
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run code quality checks
- Submit a pull request
License
This project is licensed under the MIT License. See the LICENSE file for details.
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 lazy_commit-0.1.6.tar.gz.
File metadata
- Download URL: lazy_commit-0.1.6.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e44c495f12ea73e47204fce04c35db752912aaf95fe7beb3ac28f678a84aa40
|
|
| MD5 |
b65b19f20ea70843f83a8f9ace86e014
|
|
| BLAKE2b-256 |
73b105f688a2b5ab29254316a0a86aaec89f69da98cdadc4ed8e4f5e67f9503c
|
File details
Details for the file lazy_commit-0.1.6-py3-none-any.whl.
File metadata
- Download URL: lazy_commit-0.1.6-py3-none-any.whl
- Upload date:
- Size: 18.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2c6fc047168915848a632d269b9c8fa31b8771aeee7e6fdda195472db2032a6
|
|
| MD5 |
3f2086b92a66de50b1fdd626446d300d
|
|
| BLAKE2b-256 |
2b7c137f0767dc6e340f11ef1464ba39d5f5e8b5ebbe53ce9f95b9baf00f2a62
|