Skip to main content

LLM-powered git workflow tools — generate commit messages and MR descriptions using Gemini

Project description

git-ai

LLM-powered git workflow tools. Generate commit messages and PR titles using Claude, Gemini, or Codex from the CLI, Lazygit, and other git environments that expose normal Git state.

Install

npm install -g @waxmard/git-ai

Or clone and symlink for local development:

make install   # symlinks to ~/.local/bin and ~/.local/lib; edits are live
make uninstall

Prerequisites

At least one provider must be available:

Provider CLI Auth
claude Claude Code CLI — run claude login Claude Code CLI session, or ANTHROPIC_API_KEY
gemini Gemini CLI GEMINI_API_KEY, system keychain, or Google ADC
codex Codex CLI — run codex login Codex CLI session, or OPENAI_API_KEY

ANTHROPIC_API_KEY and OPENAI_API_KEY modes require curl and python3, both standard on macOS and most Linux systems.

Gemini auth

git-ai tries these in order until one succeeds:

  1. GEMINI_API_KEY environment variable
  2. System keychain — store the key as gemini-api-key:
    • macOS: security add-generic-password -s gemini-api-key -a "$USER" -w YOUR_KEY
    • GNOME / libsecret: secret-tool store --label="Gemini API Key" service gemini-api-key
    • pass: pass insert gemini-api-key
    • KDE Wallet: kwallet-query kdewallet -w gemini-api-key
  3. Google Application Default Credentials (ADC):
    • gcloud auth application-default login
    • or set GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json

Commands

Both git-ai and aigit work identically — use whichever you prefer.

commit

Generate a commit message from staged changes.

git-ai commit [claude|gemini|codex] [tier]
  • Reads git diff --staged and produces a Conventional Commits message
  • Includes a description body for non-trivial changes
  • Default provider: gemini
  • Default tiers: haiku, flash-lite, mini (lightweight models for speed)
  • Pass last as the provider to reuse the previously generated message

pr

Generate a PR title and body from the current branch.

git-ai pr [claude|gemini|codex] [tier] [--base <branch>] [--fresh]
git-ai mr [...]   # alias for pr
  • Reads the commit log and diff against the base branch
  • Produces a Conventional Commits title + markdown body with a ### Test Plan section
  • Auto-detects the base branch from the remote default (falls back to main)
  • Use --base to override (e.g. --base dev)
  • Saves the generated output per current-branch/base-branch pair under .git/pr-cache/; subsequent runs with the same pair refine the previous result automatically
  • Use --fresh to ignore the saved output and regenerate from scratch
  • Default provider: gemini (defaults to pro/opus tier — stronger models for PR-level summaries)

providers / tiers

List available providers and tiers, ordered by last-used. Primarily for Lazygit integration.

last is only a commit provider option; PR refinement reuses cached prior output automatically.

git-ai providers [commit|pr]
git-ai tiers <provider> [commit|pr]

Providers

Provider Tier Model Auth
claude haiku claude-haiku-4-5-20251001 Claude Code CLI login, or ANTHROPIC_API_KEY
claude sonnet claude-sonnet-4-6 Claude Code CLI login, or ANTHROPIC_API_KEY
claude opus claude-opus-4-6 Claude Code CLI login, or ANTHROPIC_API_KEY
gemini flash-lite gemini-3.1-flash-lite-preview GEMINI_API_KEY, system keychain, or Google ADC
gemini pro gemini-3.1-pro-preview GEMINI_API_KEY, system keychain, or Google ADC
codex mini gpt-5.4-mini Codex CLI login, or OPENAI_API_KEY
codex standard gpt-5.4 Codex CLI login, or OPENAI_API_KEY

Last-used provider and tier are saved per repo in .git/, so repeated runs remember your selection.

Lazygit integration

Add to ~/.config/lazygit/config.yml:

customCommands:
  - key: "<c-g>"
    description: "AI commit message"
    command: 'git commit -m "$(git-ai commit {{.Form.Provider}} {{.Form.Tier}})" --edit'
    context: "files"
    prompts:
      - type: "menuFromCommand"
        title: "Select AI Provider"
        key: "Provider"
        command: "git-ai providers commit"
        filter: '(?P<value>[^|]+)\|(?P<label>.+)'
        valueFormat: '{{ .value }}'
        labelFormat: '{{ .label }}'
      - type: "menuFromCommand"
        title: "Select Model Tier"
        key: "Tier"
        command: "git-ai tiers {{.Form.Provider}} commit"
        filter: '(?P<value>[^|]+)\|(?P<label>.+)'
        valueFormat: '{{ .value }}'
        labelFormat: '{{ .label }}'
    output: terminal

Python library

git-ai is also distributed as a Python package (waxmard-git-ai) so other tools can reuse the same commit-message and MR-description generation without shelling out. Gemini only.

pip install waxmard-git-ai
# or: uv add waxmard-git-ai

Repo-mode (reads staged diff / base..HEAD from a local checkout):

from git_ai import generate_commit_message, generate_mr_description

msg = generate_commit_message(".")
pr = generate_mr_description(".", base_branch="main")

Data-mode (no local checkout required — pass raw diff strings, e.g. fetched from the GitHub/GitLab API):

from git_ai import (
    create_gemini_client,
    format_commit_log,
    generate_commit_message_from_diff,
    generate_mr_description_from_data,
)

client = create_gemini_client()

commit_msg = generate_commit_message_from_diff(diff_text, client=client)

log = format_commit_log((c.title, c.message) for c in mr_commits)
pr_text = generate_mr_description_from_data(
    diff=diff_text,
    commit_log=log,
    existing_pr=current_pr_body or None,
    client=client,
)

diff_stat and release_context are optional — when omitted, the diff-stat is derived from the diff and a generic "no release tags found" context is used. Pass model= to override the default Gemini model (COMMIT_MODEL / MR_MODEL).

Compatibility

git-ai does not depend on a specific terminal UI. It works in the CLI, in Lazygit, and in similar git environments as long as Git exposes the required repository state:

  • git-ai commit needs staged changes (git diff --staged)
  • git-ai pr needs commits and diff data relative to a base branch

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

waxmard_git_ai-3.1.1.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

waxmard_git_ai-3.1.1-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file waxmard_git_ai-3.1.1.tar.gz.

File metadata

  • Download URL: waxmard_git_ai-3.1.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for waxmard_git_ai-3.1.1.tar.gz
Algorithm Hash digest
SHA256 2560c74ac8afdd28d22d14faa85bba45f12b584aaec0f23bf8c9cacc099bc291
MD5 e8e1e9a27dc189e84e80d376b96f945d
BLAKE2b-256 758c98ae64b48c993487ae429ddf82d530e29da3f9f4bc8160227fee59378d56

See more details on using hashes here.

Provenance

The following attestation bundles were made for waxmard_git_ai-3.1.1.tar.gz:

Publisher: pypi-publish.yml on Waxmard/git-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file waxmard_git_ai-3.1.1-py3-none-any.whl.

File metadata

  • Download URL: waxmard_git_ai-3.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for waxmard_git_ai-3.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8d47ae8a2ee9e6d66cdf57714f78afcbff51e994fb07500f12f3f55037ef11a
MD5 2d6107cffec7f2cbca1852fdc46584e8
BLAKE2b-256 4da9714a88a33ff5c3f1c692b35bda9e0616f7c72d665eb4f85f37d6f42f4e30

See more details on using hashes here.

Provenance

The following attestation bundles were made for waxmard_git_ai-3.1.1-py3-none-any.whl:

Publisher: pypi-publish.yml on Waxmard/git-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page