Skip to main content

lgit

LLM-powered git commit message generator

CI PyPI License Python

Generates conventional commits from git diffs using Claude AI or any OpenAI-compatible API.
Automatic changelog maintenance, multi-commit composition, and full history rewriting.


Features

  • Conventional commits — Generates properly formatted commit messages with type, scope, and past-tense summary (≤72 chars)
  • Automatic changelogs — Maintains CHANGELOG.md following Keep a Changelog format with monorepo support
  • Compose mode — Splits large staged changes into multiple logical atomic commits
  • Rewrite mode — Converts entire git history to conventional commits (with automatic backup)
  • Map-reduce analysis — Parallel per-file analysis for large commits without truncation
  • Any LLM provider — Works with Anthropic, OpenAI, OpenRouter, or any OpenAI-compatible API

Quick Start

# Install
uv tool install lgit-cli

# Configure (pick one)
export LLM_GIT_API_KEY=your_anthropic_key                    # Direct Anthropic
export LLM_GIT_API_URL=https://openrouter.ai/api/v1          # OpenRouter
litellm --port 4000                                           # Local proxy (default)

# Use
git add .
lgit                    # Analyze, update changelog, commit
lgit --dry-run          # Preview without committing
lgit --compose          # Split into multiple commits

Usage

Basic Commands

lgit                                # Analyze staged changes and commit
lgit --dry-run                      # Preview message without committing
lgit --copy                         # Copy message to clipboard
lgit -p                             # Commit and push
lgit -S                             # GPG sign the commit
lgit -s                             # Add Signed-off-by trailer
lgit --amend                        # Amend the previous commit
lgit > msg.txt                      # Save raw message to file (auto-detected pipe mode)
lgit --dry-run | git commit -F -    # Generate message and commit with custom git flags

# Modes
lgit --mode=unstaged                # Preview unstaged changes (no commit)
lgit --mode=commit --target=HEAD~1  # Analyze a specific commit

# Models
lgit -m opus                        # Use Opus for analysis (more capable)
lgit -m sonnet                      # Use Sonnet (default)

# Context
lgit Fixed regression from PR #123  # Add context via trailing text
lgit --fixes 123 456                # Add "Fixes #123, #456" to body
lgit --breaking                     # Mark as breaking change

Compose Mode

Split staged changes into multiple logical commits:

lgit --compose                      # Propose and create atomic commits
lgit --compose --compose-preview    # Preview splits without committing
lgit --compose --compose-max-commits 5
lgit --compose --compose-test-after-each

Rewrite Mode

Convert repository history to conventional commits:

lgit --rewrite                      # Rewrite full history (creates backup)
lgit --rewrite --rewrite-preview 10 # Preview first 10 commits
lgit --rewrite --rewrite-dry-run    # Show all changes without applying
lgit --rewrite --rewrite-start main~50  # Rewrite last 50 commits only
lgit --rewrite --rewrite-parallel 20    # 20 concurrent API calls

Profiling Trace

Write detailed tracing spans and HTTP timing events to a JSONL file:

lgit --trace-output /tmp/lgit-profile.jsonl --dry-run
LLM_GIT_TRACE_FILE=/tmp/lgit-profile.jsonl lgit --compose

Each span close event includes busy/idle timing from tracing-subscriber; API events also record TTFT, total response time, status, and response size.

Automatic Changelog

lgit automatically maintains CHANGELOG.md files when committing:

  • Auto-detection — Finds all CHANGELOG.md files in your repository
  • Monorepo support — Routes changes to the correct changelog based on file paths
  • Deduplication — Skips entries semantically similar to existing ones
  • Category mapping — Maps commit types to sections (Added, Fixed, Changed, etc.)
project/
├── CHANGELOG.md              ← covers: src/, docs/
├── packages/
│   ├── core/
│   │   └── CHANGELOG.md      ← covers: packages/core/**
│   └── cli/
│       └── CHANGELOG.md      ← covers: packages/cli/**

Disable with --no-changelog or changelog_enabled = false in config.

When staged changes have a changelog boundary, one synthesis call generates the commit analysis and all applicable changelog updates together. Compose uses the same synthesis for each already-planned group; grouping and staging are unchanged. Large inputs reuse per-file map observations, and valid summaries avoid a separate summary call.

Summary repair/rewrite, authored-entry protection, existing-entry revisions, and staged/worktree isolation still apply. Malformed shared output falls back to separate generation. --dry-run, commit/unstaged analysis, and --no-changelog retain their existing generation paths.

Prompt overrides remain explicit: a relevant analysis.md, fast.md, map.md, reduce.md, or changelog.md override keeps separate calls unless the override directory also supplies synthesis.md.

Configuration

Create ~/.config/llm-git/config.toml:

# API
api_base_url = "http://localhost:4000"    # Default: LiteLLM proxy
api_key = "sk-..."                        # Or use LLM_GIT_API_KEY env var

# Model — any role accepts a `;`-separated fallback chain, tried left to right
analysis_model = "claude-sonnet-4.5"      # Diff analysis / classification
summary_model = "claude-haiku-4-5"        # Summary line generation
map_model = ""                            # Per-file map phase; empty = summary_model
fast_model = "flash-lite;haiku"           # Fast mode; falls back when the primary stalls

# Commit message limits
summary_guideline = 72                    # Target length
summary_soft_limit = 96                   # Triggers retry
summary_hard_limit = 128                  # Absolute max

# Features
changelog_enabled = true
auto_fast_threshold_lines = 200           # Auto-use fast mode for small diffs; 0 disables
map_reduce_enabled = true                 # Parallel analysis for large commits
disable_git_background_features = true    # Disables fsmonitor/untrackedCache for lgit subprocesses

# Typed judgments (TypeSafe jev, ~$0.04 per million input tokens, ~1s per round trip).
# With a key: mechanical follow-through hunks (imports, call sites, formatting, lockfiles)
# are pruned from analysis prompts and the rest get a per-hunk type hint; compose binds
# hunks to groups by judgment instead of the analysis model; changelog generation is
# skipped for changes judged not user-visible and paraphrased duplicate entries are
# dropped. Shared commit/changelog synthesis does not require a judge key.
judgment_api_key = ""                     # Or TYPESAFE_API_KEY env var; `!cmd` runs a command
judgment_model = "jev-latest"
mechanical_hunk_threshold = 0.7           # Prune hunks judged mechanical with >= this probability
mechanical_prune_min_tokens = 5000        # Skip pruning below this diff size (round trip not worth it)
mechanical_prune_min_model_rate = 1.0     # ...and unless the analysis model bills >= this $/M (judging costs ~$0.08/M of diff)
changelog_gate_threshold = 0.3            # Skip the changelog model below this user-visibility; 0 disables

# Commit signing
gpg_sign = false                          # GPG sign commits by default (-S)
signoff = false                           # Add Signed-off-by trailer by default (-s)

Provider Examples

Anthropic Direct:

api_base_url = "https://api.anthropic.com/v1"
api_key = "sk-ant-..."

OpenRouter:

api_base_url = "https://openrouter.ai/api/v1"
api_key = "sk-or-..."
analysis_model = "anthropic/claude-sonnet-4.5"
summary_model = "anthropic/claude-haiku-4-5"

OpenAI:

api_base_url = "https://api.openai.com/v1"
api_key = "sk-..."
analysis_model = "gpt-4o"
summary_model = "gpt-4o-mini"

Judgments (optional, any provider above):

judgment_api_key = "!cat ~/.secrets/typesafe"   # key from https://console.typesafe.ai/

Set LLM_GIT_JUDGMENT_DISABLED=1 to switch judgments off without removing the key.

The client uses the same response formats across OpenRouter, LiteLLM, Anthropic, and OpenAI endpoints: markdown/plain text for individual operations and a validated JSON object for shared commit/changelog synthesis.

Commit Types

Customize commit type classification:

[types.feat]
description = "New public API or user-observable behavior change"
diff_indicators = ["pub fn", "pub struct", "export function"]

[types.fix]
description = "Fixes incorrect behavior"
diff_indicators = ["unwrap() → ?", "bounds check", "error handling"]

[types.refactor]
description = "Internal restructuring with unchanged behavior"
hint = "If behavior changes, use feat instead."

Changelog Categories

[[categories]]
name = "Breaking"
header = "Breaking Changes"
match.body_contains = ["breaking", "incompatible"]

[[categories]]
name = "Added"
match.types = ["feat"]

[[categories]]
name = "Fixed"
match.types = ["fix"]

[[categories]]
name = "Changed"
default = true

Environment Variables

Variable Description Default
LLM_GIT_API_URL API endpoint http://localhost:4000
LLM_GIT_API_KEY API key none
LLM_GIT_CONFIG Config file path ~/.config/llm-git/config.toml
LLM_GIT_VERBOSE Debug output false
LLM_GIT_TRACE_FILE JSONL profiling trace output path none

Installation

From PyPI

uv tool install lgit-cli    # recommended
pipx install lgit-cli       # or
pip install lgit-cli

From source

git clone https://github.com/can1357/llm-git.git
cd llm-git
uv tool install .

Prerequisites

  • Python 3.14+
  • Git
  • API access (Anthropic, OpenAI, OpenRouter, or local LiteLLM proxy)

License

MIT

Metadata

Release files for lgit-cli 5.5.0

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

Source distribution (sdist)

Source distribution for lgit-cli 5.5.0
File Size Uploaded Provenance Actions
lgit_cli-5.5.0.tar.gz 806.4 kB With provenance Details for lgit_cli-5.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lgit-cli 5.5.0
File Interpreter ABI Platform Actions
lgit_cli-5.5.0-py3-none-any.whl Python 3 none any Details for lgit_cli-5.5.0-py3-none-any.whl

Total release size: 1.0 MB

Release files / lgit_cli-5.5.0.tar.gz

Download URL lgit_cli-5.5.0.tar.gz
Size 806.4 kB
Tags Source
SHA-256 checksum
How to use checksums
be8a9a35f57ba700b1b51c7425ba057fb176e6d5c9a5813345344657ebf60ca0
BLAKE2b-256 checksum
How to use checksums
557f407bc3b2473254e87b26707977317b473c36f93963619eafae432f1c62ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Release files / lgit_cli-5.5.0-py3-none-any.whl

Download URL lgit_cli-5.5.0-py3-none-any.whl
Size 202.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ac8a50d4de768d61a2a9758910c8f98dc77fd908f28023284fde7f0618c559c
BLAKE2b-256 checksum
How to use checksums
021d408677991dc898a0b9ba2a4ad796cf590ebd0a7952ef1076baab7e345add
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 3, 2026.

Transparency log

Security for lgit-cli 5.5.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lgit_cli-5.5.0.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 Nov 3, 2026.

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.

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