Repolode
guanguans

guanguans/ai-commit

A CLI tool that generates conventional git commit messages from your staged diff using AI models, then commits them.

Stars
393
Forks
22
Open issues
0
Last commit
3 days ago

What is it?

ai-commit is a PHP command-line tool that reads your git diff, sends it to an AI generator, and produces a conventional commit message with a type, subject, and body. You can review and edit the message before it is committed, or use a dry run to only print the result.

It supports several backends, including OpenAI, OpenAI Chat, Moonshot, ERNIE Bot, Bito CLI, GitHub Copilot CLI, and GitHub Models CLI. The default generator and API keys are set through a config command, and the tool includes commands for listing options, editing config, and self-updating the built binary.

Install it by downloading the single ai-commit file from the repository or via Composer, and it requires PHP 8.2 or newer.

Key features

  • 01Generates conventional commit messages from git diff content.
  • 02Lets you choose commit type and review the message before committing.
  • 03Supports multiple AI backends such as OpenAI, Moonshot, and ERNIE Bot.
  • 04Offers a dry-run mode that only prints the generated message.
  • 05Ships as a single downloadable file or installs via Composer.

Use cases

  • Writing consistent commit messages in projects that follow the Conventional Commits format.
  • Speeding up commits when the change is large and a summary is tedious to write by hand.
  • Using an existing GitHub Copilot or Bito CLI setup to generate commit messages.

Quick start

  1. 1

    Install via Composer globally (requires PHP 8.2 or newer)

    composer global require guanguans/ai-commit --dev -v
  2. 2

    Set your AI generator API key (example uses OpenAI Chat)

    ai-commit config set generators.openai_chat.api_key sk-... --global
  3. 3

    Stage your changes and generate and commit the message

    ai-commit commit

Things to know

  • Requires PHP 8.2 or newer.
  • Most generators need an API key or a separately installed CLI tool.

In collections

Topics

FAQ

What is ai-commit?
A CLI tool that generates conventional git commit messages from your staged diff using AI models, then commits them. ai-commit is a PHP command-line tool that reads your git diff, sends it to an AI generator, and produces a conventional commit message with a type, subject, and body. You can review and edit the message before it is committed, or use a dry run to only print the result.
Is ai-commit free to use? What license does it have?
ai-commit is open source under the MIT license. Check the license terms before using it in commercial products.
Is ai-commit still maintained?
Actively maintained. The last commit to ai-commit was on Nov 3, 2026.
What can I use ai-commit for?
Writing consistent commit messages in projects that follow the Conventional Commits format. Speeding up commits when the change is large and a summary is tedious to write by hand. Using an existing GitHub Copilot or Bito CLI setup to generate commit messages.
How do I install ai-commit?
Install via Composer globally (requires PHP 8.2 or newer): composer global require guanguans/ai-commit --dev -v Set your AI generator API key (example uses OpenAI Chat): ai-commit config set generators.openai_chat.api_key sk-... --global Stage your changes and generate and commit the message: ai-commit commit
Where can I get ai-commit?
The source code and installation instructions are on GitHub: https://github.com/guanguans/ai-commit

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects