- Introduction
- Purpose
- Prompt Features
- Choosing the best AI API to use with AI Commit
- Setup
- Usage
- Current Status
This repository tracks the development of a custom AI prompt for use with the AI Commit VS Code extension. The prompt's purpose is to generate better git commit messages based on the Conventional Commits 1.0.0 Specification.
This project's current iteration is loosely based on the extension's original prompt message Git Commit Message Guide and further refined to my needs and taste.
The purpose of this prompt is to generate thorough, consistent and precise git commit messages based on the Conventional Commits 1.0.0 Specification. This prompt achieves this by giving AI precise instructions on composing a commit message based on the current commit's git diff.
The detailed prompt instructions are in the prompt document of this repository.
AI-assisted git Conventional Commits prompt features:
- Follows Conventional Commits 1.0.0 Specification.
- Supports Gitmoji.
- Messages are written in English.
- Outputs ONLY the commit message.
- Messages need to use one of the defined types.
- The output must be formatted according to the Output Format section.
I chose Gemini as the AI API provider for git commit messages for a few reasons:
- It has one of the largest context windows out of all of the currently available APIs out there (more on this below) and the biggest context window out of all the APIs supported by AI Commit.
- The cost related to using Gemini API for this purpose is negligible. I currently spend less than 0.10 USD per month using it nearly every day, multiple times a day indiscriminately.
- Gemini's latest AI models are quite competent in understanding and providing good commit messages based on git diffs.
A large context window is essential for generating git commit messages since the git diffs used by this extension combined with the provided instructions can easily exceed most other AI API's maximum context window, even with very common and relatively simple commits such as a dependency update.
You may choose to use any other supported APIs such as ChatGPT, Azure or DeepSeek APIs but you are likely to have issues with context window size.
-
Generate a Gemini API key and add it to the
Ai-commit: GEMINI_API_KEY
setting. If you need help with this, there are quite a few online tutorials such as How to Obtain a Gemini API Key. -
Install the AI Commit VS Code extension.
-
Open your VS Code settings (
cmd + ,
on a mac) and type@ext:sitoi.ai-commit
on the search box. -
Edit AI Commit's extension settings:
- On the
Ai-commit: AI_COMMIT_SYSTEM_PROMPT
, paste all the contents of theai-git-commit-message-prompt.md
file. - For the
Ai-commit: AI_PROVIDER
field selectgemini
. - For the
Ai-commit: GEMINI_MODEL
typegemini-2.0-flash
or whatever other Gemini model you may want to use. - Tweak
Ai-commit: GEMINI_TEMPERATURE
to taste. I'm currently using0.1
.
- On the
Use the extension to create your AI generate git commit messages:
- Make changes to a file in your git repository and stage the changes.
- Navigate to VS Code's Source Control Tab.
- From there, you can press the little AI commit button on top of the
Changes
sub-tab or search forAI Commit
in VS Code's Command Palette (command + p
on a Mac). Once you click the button or execute the command, the AI Commit extension will populate the tab's commit message input field with the AI-generated commit message you can then review it, tweak it and eventually hit commit.
Optionally, and this is a very powerful feature, before calling the AI Commit extension in step 3, you can provide it with extra context, specific to your current commit.
To do this, simply type the extra information into the commit message input field (in VS Code's Source Control Tab) before pressing the commit button (or executing the AI Commit
command).
This can tremendously improve the quality of the commit messages you get from Gemini. I especially recommend this feature if the first commit message you got was not to your satisfaction.
Even a tiny bit of context is normally enough to steer Gemini in the right direction. AI Commit will then pass what you typed together with the instructions provided by you in the Setup step 4.1 to the Gemini API returning a better commit message.
As of the 21st of April 2025, I have been using the AI Commit VS Code extension for a few months. I'm currently using it with the Gemini API's gemini-2.0-flash
model as a good balance between context window size, speed, cost and ability to create good commit messages based on git diffs.
It has proven to be a very useful addition to my tool kit. It helps me speed up my rate of commits while maintaining precision, thoroughness and consistency. It is by no means perfect and it's a work in progress. I will continue to refine it as I go. I recommend always checking the output before committing as hallucinations are not uncommon.