Skip to main content

git-llm-commit

codecov

Generate Conventional Commit messages from your staged changes using an LLM.

Description

git-llm-commit is a command-line tool that analyzes your staged git changes and generates a commit message following the Conventional Commits specification using various LLM models, including OpenAI's GPT-4 and OpenRouter.

Installation

  1. Ensure you have Python 3.x installed
  2. Install the package:
    pip install git-llm-commit
    

Setup

  1. Get an API key from your preferred LLM provider (e.g., OpenAI, OpenRouter)

  2. Set your API key in your environment:

    export OPENAI_API_KEY='your-api-key'
    

    Or create a .env file in your project root with:

    OPENAI_API_KEY=your-api-key
    
  3. (Optional) Customize the LLM's creativity:

    export LLM_COMMIT_TEMPERATURE='0.5'  # More deterministic (0.0-1.0, default: 0.7)
    

    Or in your .env file:

    LLM_COMMIT_TEMPERATURE=0.5
    
  4. (Optional) Use OpenRouter:

    • Get an OpenRouter API key from OpenRouter's platform

    • Set your OpenRouter API key in your environment:

      export OPENROUTER_API_KEY='your-openrouter-api-key'
      

      Or in your .env file:

      OPENROUTER_API_KEY=your-openrouter-api-key
      
  5. (Optional) Choose a custom model:

    • Set the model name in your environment:

      export LLM_COMMIT_MODEL='custom-model'
      

      Or in your .env file:

      LLM_COMMIT_MODEL=custom-model
      

Usage

  1. Stage your changes as usual:

    git add .
    
  2. Instead of git commit, run:

    git llm-commit
    
  3. Review the generated commit message and:

    • Press y to accept and commit
    • Press n to abort
    • Press e to edit the message before committing
  4. For detailed commit messages with body and footer sections:

    git llm-commit --dynamic
    

    or set the environment variable:

    export LLM_COMMIT_DYNAMIC_LENGTH=true
    

Features

  • Generates commit messages following Conventional Commits format
  • By default, generates one-sentence commit messages (title only) for simplicity
  • Optional dynamic mode (--dynamic flag) that adapts commit message detail based on change size:
    • Small changes (≤50 lines): Concise, single-line messages
    • Medium changes (51-200 lines): Moderate detail with brief body
    • Large changes (>200 lines): Detailed messages with full body and footers
  • Supports interactive editing of generated messages
  • Integrates with your default git editor
  • Respects conventional commit types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
  • Detects potentially risky files (like .env, credentials, secrets) and prompts for confirmation before committing
  • Prioritizes OpenRouter API key if available, otherwise falls back to OpenAI API key
  • Allows users to choose the model they would like to use

Security Features

Risky File Detection

The tool automatically scans staged files for potentially sensitive content like:

  • .env files
  • Files containing "secret" or "credentials" in the name
  • Key files
  • Secret/credential configuration files (yml, yaml, json, toml)

If such files are detected, you'll be prompted for confirmation before proceeding with the commit. This helps prevent accidental commits of sensitive information to your repository.

Requirements

  • Python 3.x
  • Git
  • API key from your preferred LLM provider (e.g., OpenAI, OpenRouter)

License

MIT License

Metadata

Release files for git-llm-commit 2.1.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 git-llm-commit 2.1.0
File Size Uploaded
git_llm_commit-2.1.0.tar.gz 43.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-llm-commit 2.1.0
File Interpreter ABI Platform
git_llm_commit-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 52.4 kB

Release files / git_llm_commit-2.1.0.tar.gz

Download URL git_llm_commit-2.1.0.tar.gz
Size 43.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8919cd5d45cc49c513d29b14ebfe205864adb840d73ed5dc1efb14954a6d0268
BLAKE2b-256 checksum
How to use checksums
8c96823e2f5c43a1dbd0539bb5a5abc6dbd33a3cd9059e40f7864576e4a8d3cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Release files / git_llm_commit-2.1.0-py3-none-any.whl

Download URL git_llm_commit-2.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
714167dafe946e378b9e5926cd9c3137f5bbdfc61f432067993e83940d68f028
BLAKE2b-256 checksum
How to use checksums
9454e7076a543aa23226365e995dddbd7737a5117923c3cde9b6c8d2f9d6b362
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.3

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.2

2 release files

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