🤖 git-ai-commit
Tl;DR
-
AI that writes your commit messages.
-
A CLI and git hook that summarizes your changes every time you run
git commit. -
Integrates with the
pre-commitframework, working alongside all your git hooks.
📺 Usage
git-ai-commit currently support the following LLM providers...
-
Open AI:
gpt-4o-mini(default),gpt-4,gpt-3.5, and more... -
Anthropic:
claude-3-haiku,claude-3-sonnet,claude-3-opus -
Local Ollama:
llama3,mistral,phi-3,gemma, and more..
🚀 Getting Started
- Install the
git-ai-committool via pip
pip install git-ai-commit
git-ai-commit --version # verify installation
- Start configuring your tool
git-ai-commit config --setup
- Your done, happy committing! Check out our fun range of command, the LLM can even help you, just run...
git-ai-commit help-ai [question?]
# or get help the ol fashion way
git-ai-commit --help
⚡️ Quick Start: Setup Git Hook
To quickly setup your prepare-commit-msg git hook, execute the command below.
Caution, this will override any existing prepare-commit-msg hooks you may have. To coordinate multiple git hook, check out the pre-commit framework.
git-ai-commit hook --setup
That is all, your good to go! Now every time you run git commit, let AI present you with a commit message.
🪝 Integrate with pre-commit framework
git-ai-commit integrates easily with your other git hook using the pre-commit framework. Follow the instructions below to get set up.
- Install the
pre-commitgit hooks framework
brew install pre-commit
pre-commit --version
- Create a
.pre-commit-config.yamlfiles and add the following config.
touch .pre-commit-config.yaml
# .pre-commit-config.yaml
default_install_hook_types:
# make sure you include `prepare-commit-msg` in `default_install_hook_types`
- prepare-commit-msg
repos:
- repo: https://github.com/the-cafe/git-ai-commit
rev: v1.0.13
hooks:
- id: git-ai-commit
- Based on the config above, install your
pre-commithook scripts.
pre-commit install
- Setup your OpenAI key, see their docs for help.
git-ai-commit config --openai-key=...
🎯 Cursor IDE Integration
git-ai-commit integrates seamlessly with Cursor IDE to enhance your AI-powered development workflow. The tool works alongside Cursor's AI capabilities to provide consistent, high-quality commit messages.
📁 Setup .cursorrules Integration
Add git-ai-commit to your project's .cursorrules file to ensure Cursor always suggests using AI-generated commit messages:
# Git AI Commit Integration
## Commit Workflow
When making commits, always use the `git-ai-commit` CLI tool instead of regular `git commit`. This tool automatically generates AI-powered commit messages based on your staged changes.
### Recommended Commands:
- Use `git-ai-commit` instead of `git commit` for AI-generated commit messages
- Use `git-ai-commit conventional` for conventional commit format
- Use `git-ai-commit summarize` to get a quick overview of changes before committing
### Workflow Integration:
- Before committing, stage your changes with `git add`
- Instead of `git commit -m "message"`, simply run `git-ai-commit`
- The tool will analyze your changes and suggest an appropriate commit message
💬 Example Cursor Prompts
Here are some effective prompts to use with Cursor when working with git-ai-commit:
For committing changes:
"I've made some changes to my code. Please stage the files and use git-ai-commit to generate an appropriate commit message."
For conventional commits:
"Stage my changes and use git-ai-commit conventional to create a conventional commit message for this feature/fix/refactor."
For code review before committing:
"Before committing, please run git-ai-commit summarize to show me what changes I've made, then proceed with the commit."
For complete workflow:
"Please help me commit my changes using this workflow: 1) Stage relevant files, 2) Use git-ai-commit to generate the message, 3) Review the commit message, 4) Push to the remote repository."
🔄 Recommended Workflow with Cursor
- Make your code changes using Cursor's AI assistance
- Stage changes: Ask Cursor to
git addthe relevant files - Generate commit message: Use
git-ai-commitinstead of manual commit messages - Review and commit: Let the AI analyze your changes and create descriptive commit messages
- Push changes: Complete the workflow with
git push
This integration ensures that both your code and commit messages maintain high quality and consistency throughout your development process.
🤖 For Claude AI Users
If you're using Claude or other AI assistants, check out our CLAUDE.md file for specific integration guidelines and workflow recommendations.
🛠️ CLI Commands & Options
✨ git-ai-commit config
Display your current config settings. Option flags can be used to configure various settings in your configuration. For example...
git-ai-commit config
git-ai-commit config --openai-key=... --model=gpt-4o-mini
-
-k--openai-keySet or update the OpenAI API key to access their GPT models.
-
-a--anthropic-keySet or update the Anthropic API key to access their Claude models.
-
-m--modeldefault: "gpt-4o-mini"
Select a model to power our tool from our supported provider. To use a Ollama model, prefix
ollama/<model>. -
-ou--ollama-urldefault: "http://localhost:11434/api/chat"
Set the URL for interacting with your local Ollama models.
-
-s--setupConfig your git hook, model, and API keys via the NUX flow.
-
-l--loggerdefault: false
A toggle for enabling logs that are saved to a local file -
.git/ai_commit_message.log. This was intended to be used as a local debug tool. -
-r--resetResets your entire config settings to the default state. This will reset all settings, including API keys and model.
-
-p--prefixSet a prefix for the generate commit messages.
-
-ml--max-lengthSet the character limit for the LLM response. In our testing, the greater the limit the more details are included in the commit messages.
🔎 git-ai-commit summarize
Get a quick summary of your local changes
git-ai-commit summarize
-
-u--unstagedSummarize your local unstaged changes.
-
-d--diffProvide a .diff file from the local file system to summarize
🏷️ git-ai-commit conventional
Generate commit messages in the Conventional Commits format (type(scope): description).
This command:
- Analyzes your staged changes using AI
- Suggests the most appropriate commit type based on your changes
- Suggests a relevant scope based on the affected components
- Allows you to accept the suggestions or choose your own
- Formats the message according to conventional commit standards
- Gives you the option to commit and push
Available commit types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Formatting changesrefactor: Code refactoringperf: Performance improvementstest: Adding or modifying testschore: Maintenance tasks
📌 git-ai-commit help, -h
Displays a list of available command and options to help you setup our tool.
git-ai-commit help # -h
🪝 git-ai-commit hook
Manage and setup git-ai-commit as a prepare-commit-msg git hook.
git-ai-commit hook --setup
-
-s--setupAdds a git hook by generating a
.git/hooks/prepare-commit-msgscript in your git repo. -
-sh--setup-huskyIntegrate our hook into your husky git hooks by generating a
.husky/prepare-commit-msgscript in your git repo. -
-r--removeRemoves the git hook.
-
-x--runExecutes the custom logic for our git hook. This option was intended to only run from the
prepare-commit-msggit hook.
🤝 Wanna Contribute?
Do you love our tool and wanna support us? Drop us a star 🌟
Have some feedback on what we could do better? Create a issue we'll respond in 24hrs we promise 😄
Wanna contribute code and improve our product, check out our Local Development Wiki to get started.
Right now we're focused on
-
Improving our prompting strategy to generate the best commit message possible
-
Super charge our CLI to support broad developer use cases and build the best interface we can
-
Build some tests
🎉 Fun Facts
- In this repository, every commit prefixed with
✨was generated by AI.
Metadata
Release files for git-ai-commit 1.0.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| git_ai_commit-1.0.13.tar.gz | 26.1 kB | Details |
Release files / git_ai_commit-1.0.13.tar.gz
| Download URL | git_ai_commit-1.0.13.tar.gz |
|---|---|
| Size | 26.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1f4be5b05cbbd60f733c19405e55920d4a650028449327969c6a59a5a1b52c6
|
|
BLAKE2b-256 checksum How to use checksums |
8ddfdcf83edccacf00703ca8ffb7b5fb13c6e2004229ef43fc06b66bd957f06f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.22
|