Skip to main content

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
  • 🌐 Multi-Language Support: Generate commit messages in any natural language (English, 简体中文, 日本語, etc.)
  • 🎯 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
uv tool upgrade 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

# Optional: Bypass system proxy for LAN endpoints (default: false)
# Useful when accessing internal model endpoints via VPN
export LAZY_COMMIT_BYPASS_PROXY=true

# Optional: Set the language for commit messages (default: English)
# Supports any natural language like "English", "简体中文", "日本語", "Español", etc.
export LAZY_COMMIT_LANGUAGE="简体中文"

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
LAZY_COMMIT_LANGUAGE=English

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"
LAZY_COMMIT_LANGUAGE=简体中文

Language Configuration

You can generate commit messages in any natural language by setting the LAZY_COMMIT_LANGUAGE environment variable.

Supported Languages

The tool supports any natural language. Simply specify the language name in your preferred format:

# English (default)
export LAZY_COMMIT_LANGUAGE="English"

# Simplified Chinese
export LAZY_COMMIT_LANGUAGE="简体中文"

# Japanese
export LAZY_COMMIT_LANGUAGE="日本語"

# Spanish
export LAZY_COMMIT_LANGUAGE="Español"

# French
export LAZY_COMMIT_LANGUAGE="Français"

# German
export LAZY_COMMIT_LANGUAGE="Deutsch"

The AI model will automatically generate commit messages in the specified language, including both the title and body.

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

  1. Repository Detection: Automatically detects git repository root
  2. File Analysis: Scans for modified, staged, and untracked files
  3. Smart Filtering: Excludes files like *.lock, *.ipynb from AI analysis but includes them in commits
  4. Diff Generation: Creates comprehensive diffs for all relevant changes
  5. Context Management: Compresses large diffs to fit within AI model context limits
  6. AI Generation: Uses AI to generate a structured commit message following Conventional Commits
  7. Display Message: Always displays the generated commit message
  8. Optional Staging & Commit: If --add is used, stages all changes and applies the generated commit message
  9. Optional Push: If --push is 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 features
  • fix: Bug fixes
  • docs: Documentation changes
  • style: Code style changes (formatting, etc.)
  • refactor: Code refactoring
  • perf: Performance improvements
  • test: Test additions or modifications
  • build: Build system changes
  • ci: CI/CD changes
  • chore: 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 interface
  • openai: OpenAI API client
  • pydantic-settings: Configuration management
  • rich: Beautiful terminal output
  • loguru: Logging
  • tiktoken: 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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Run code quality checks
  6. Submit a pull request

License

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

Metadata

Release files for lazy-commit 0.2.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 lazy-commit 0.2.1
File Size Uploaded Provenance
lazy_commit-0.2.1.tar.gz 20.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lazy-commit 0.2.1
File Interpreter ABI Platform
lazy_commit-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.4 kB

Release files / lazy_commit-0.2.1.tar.gz

Download URL lazy_commit-0.2.1.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c61a8138826969b9817bcec7ef4086ad721ecc7333029a09c073187bc257c0f3
BLAKE2b-256 checksum
How to use checksums
6a25013221fc144f39683177d66da7e89ccaeb3eb636af01d9dde18ebfbe9ec0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / lazy_commit-0.2.1-py3-none-any.whl

Download URL lazy_commit-0.2.1-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a79583bd0c0528bc3acf698491a81908b71f6bd92a11c972cebaefd3a3d2302
BLAKE2b-256 checksum
How to use checksums
0c1d99513ebc6a34f282a9429c6413515dffa4ae66cfd4e147961b67d90c30d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for lazy-commit 0.2.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.

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