Skip to main content

Use LLM to create git commit messages

Project description

cai

cai is a Git extension to automate the creation of commit messages. Simply run git cai to generate automatically 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.

Table of Contents

About

cai is designed to simplify Git workflows by generating commit messages automatically using an LLM. No more struggling to summarize changes, just run git cai.

Currently, it supports the API of OpenAI, Gemini, Anthropic, Groq and Xai for message generation.

Prerequisites

  • Python 3.10 or higher
  • Pipx or Pip if installed in a virtual environment
  • API key, of at least one of the following providers
    • OpenAI
    • Gemini
    • Anthropic
    • Groq
    • Xai
    • Mistral
    • Deepseek

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
  • Allows to squash all commits in a branch and summarizes the commit messages

Installation

Installation:

pipx install git-cai-cli

Afterwards, add to PATH:

pipx ensurepath

Finally, restart the shell.

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 within the editor according to your git configuration, allowing reviewing and editing before confirming the commit.

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

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 two configuration files are automatically created:

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

Add provider API token to tokens.yml so that cai can use it each time to 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 (please note, perhaps not all models will work)
  • temperature: control how creative the model’s responses are
  • language: set the language in which the LLM should generate commit messages
  • style: choose a certain tone style of the commit message
  • emoji: boolean to enable/disable usage of emojis

CLI

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

  • -h shows a brief help message with available commands
  • -a, --all stages all modified and deleted files that are already tracked by Git
  • -d, --debug enables debug logging to help troubleshoot issues
  • -l, --list list information about languages and styles which can be used
  • -s, --squash squash commits on this branch and summarize them
  • -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.6.0.tar.gz (105.6 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.6.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: git_cai_cli-0.6.0.tar.gz
  • Upload date:
  • Size: 105.6 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.6.0.tar.gz
Algorithm Hash digest
SHA256 2ac3bc53c2ee3f78e600f806931f28373d0fc2a6f8e240aab7dd53ddfb9c9c6e
MD5 5524af37b89dd55b17ae7d164176ab3d
BLAKE2b-256 3f72da4d212e3cb2d9d152461bd3d1d410d3bb16d27ddb2c0102a2e0331ddf80

See more details on using hashes here.

File details

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

File metadata

  • Download URL: git_cai_cli-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4dfc594e701db836aa4504d4c4a2016ab6b54b7de4beab64d0c35599bbb344ca
MD5 0ab7047faa31726f937c67bf5db5fd37
BLAKE2b-256 21a0a6e8a8e870426a3abaaa24f5b36fe34581e43e482d1d78ac6e7f342d87f2

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