Skip to main content

Use LLM to create git commit messages

Project description

cai

cai is a Git extension written in Python that automates the creation of commit messages. With it, you can simply run git cai to automatically generate a commit message based on the changes and new files in your repository.

cai uses a large language model (LLM) to produce commit messages that are meaningful and context-aware. It currently supports both the OpenAI API and the Gemini API for message generation.

Table of Contents

About

cai is designed to simplify your Git workflow by automatically generating commit messages using an LLM. No more struggling to summarize changes, just run git cai, and it handles it for you.

Currently, the only supported backends are the OpenAI and Gemini APIs, but additional LLM integrations may be added in the future.

Prerequisites

  • Python 3.10 or higher
  • Pipx or Pip if installed in a virtual environment
  • API key, currently supported
    • OpenAI
    • Gemini

Features

  • Automatically detects added, modified, and deleted files
  • Generates meaningful, context-aware commit messages using an LLM
  • Seamless integration with Git as a plugin/extension
  • Supports different LLM models and languages for each repository, as well as global configuration

Installation

You can install cai using pipx:

pipx install git-cai-cli

After installation, make sure cai is added to your PATH:

pipx ensurepath

Then, restart your shell (e.g., bash, zsh, or whichever shell you use) for the changes to take effect.

Usage

Once installed, cai works like a standard Git command:

git cai

cai uses Git’s diff output to generate commit messages. The generated message is then opened in your editor, allowing you to review and edit it before confirming the commit.

In short: it behaves like git commit, but the commit message is pre-filled for you.

To exclude specific files or directories from being included in the generated commit message, create a .caiignore file in the root of your repository. This file works like a .gitignore.

  • Files listed in .gitignore are always excluded.
  • .caiignore is only needed for files that are tracked by Git but should not be included in the commit message.

Configuration

The first time you run git cai, it automatically creates two configuration files:

  • cai_config.yml – Stores general settings:
home/<USERNAME>/.config/cai/cai_config.yml
  • tokens.yml – Stores your API token(s):
home/<USERNAME>/.config/cai/tokens.yml

Add your OpenAI and/or Gemini API token to tokens.yml so that cai can use it each time you generate a commit message.

If a cai_config.yml file exists in the root of your repository, cai will use the settings defined there. Otherwise, it falls back to the default settings.

To use a repository-specific configuration, copy the config file to the root of your repository and adjust it as needed:

cp ~/.config/cai/cai_config.yml .

Currently, the following options can be customized:

  • default: set the default provider
  • model: specify which model of the provider to use
  • temperature: control how creative the model’s responses are
  • language: set the language in which the LLM should generate commit messages

CLI

Besides running git cai to generate commit messages, you can use the following options:

  • -h shows a brief help message with available commands
  • -d, --debug enables debug logging to help troubleshoot issues
  • -l, --languages list available languages
  • -u, --update checks for updates the cai tool
  • -v, --version displays the currently installed version

License

This project is licensed under the MIT License.

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

git_cai_cli-0.2.1.tar.gz (82.2 kB view details)

Uploaded Source

Built Distribution

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

git_cai_cli-0.2.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file git_cai_cli-0.2.1.tar.gz.

File metadata

  • Download URL: git_cai_cli-0.2.1.tar.gz
  • Upload date:
  • Size: 82.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for git_cai_cli-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3803b4eff03763cd41deddf59d3d039a540c6492aaaf38aa1cd3959254609d3e
MD5 0e59097f17aa01422cd17c357810f020
BLAKE2b-256 2df490663c50a4fe47d5b5b17c7d9bda3bdf6ac620d8bcae390b9eb449dc962c

See more details on using hashes here.

File details

Details for the file git_cai_cli-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: git_cai_cli-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for git_cai_cli-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9bb24d44133e70b50a7ef44f6e26b89828f7f725050a5af5368ea2c7d7c83945
MD5 f61f14ee3b07aff359aed4a8ff73719b
BLAKE2b-256 09515d679f7f01bf214ad3f531836d9b9c78d8a3d723645fb57912e909e4d293

See more details on using hashes here.

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