gitmyhub

aicommits

TypeScript ★ 9.0k updated 1mo ago

A CLI that writes your git commit messages for you with AI

A command-line tool that reads your staged git changes and uses an AI service to automatically write a commit message for you, saving time and improving consistency.

TypeScriptNode.jsnpmsetup: easycomplexity 2/5

AI Commits is a command-line tool that automatically writes git commit messages for you by analyzing the code changes you have staged. Instead of thinking up a message yourself, you run the tool after staging your files and it calls an AI service to describe what changed. The project has around 8,900 GitHub stars and is written in TypeScript.

Getting started requires Node.js v22 or higher. You install the package globally through npm and then run a setup command that walks you through picking an AI provider and entering your API key. The tool supports a range of providers including TogetherAI (listed as the recommended choice), OpenAI, Groq, xAI, OpenRouter, and two options for running models locally on your own machine via Ollama or LM Studio. You can also point it at any service that speaks the OpenAI API format.

Once set up, you stage your files the normal way and then call the tool instead of typing a commit message by hand. It reads the diff, sends it to whichever AI you configured, and returns a suggested message. You can ask it to generate several options at once and pick the one you like best, though generating more uses more tokens. The tool also supports three commit message formats: plain text, the Conventional Commits style that many teams use for changelogs, and a gitmoji format that adds emoji prefixes.

For teams or individuals who prefer to stay in a standard git workflow, the tool can install itself as a git hook. With the hook in place, you just run git commit as usual and the tool intercepts it, generates a message, and opens your editor so you can review or adjust before finalizing. You can override it at any time by passing your own message directly.

Configuration can be managed through a config file in your home directory, environment variables, or command-line flags, with flags taking the highest priority. A custom prompt flag lets you steer the style of the output, for example asking for messages in a specific language or with a particular level of technical detail.

Where it fits