Commit Oracle is a smart Git commit message generator that leverages AI to suggest contextually relevant commit messages based on your staged changes. It integrates seamlessly with your Git workflow and popular tools like LazyGit.
- Generates 5+ AI-powered commit messages based on your staged Git changes
- Uses the Conventional Commits format for structured, consistent messages
- Allows browsing and selection of suggested messages using FZF
- Supports editing of the selected message before committing
- Integrates with LazyGit for a smooth workflow
-
Clone this repository:
git clone https://github.com/tfriedel/commit-oracle.git
-
Add the script to your PATH. Add this line to your
~/.bashrc
or~/.zshrc
:export PATH=$PATH:/path/to/commit-oracle
-
Source your updated RC file or restart your terminal.
-
Install aichat and FZF by following the instructions in the repositories.
Run the script in your Git repository after staging your changes:
commit-oracle.sh
To use Commit Oracle with LazyGit, add the following to your LazyGit config file (usually located at ~/.config/lazygit/config.yml
and for macos at ~/Library/Application\ Support/lazygit/config.yml
):
# yaml-language-server: $schema=https://raw.githubusercontent.com/jesseduffield/lazygit/master/schema/config.json
customCommands:
- key: <c-g>
description: Pick LLM commit
loadingText: "waiting for LLM to generate commit messages..."
command: clear && export EDITOR=nvim && commit-oracle.sh
context: files
subprocess: true
Now you can use the <Ctrl-G>
shortcut in LazyGit to invoke Commit Oracle.
- The script extracts the diff of staged changes.
- It sends this diff to an LLM, requesting commit message suggestions.
- The LLM generates multiple commit messages following the Conventional Commits format.
- FZF presents these messages for you to browse and select.
- You can edit the selected message in your preferred text editor.
- The script commits the changes with your chosen (and possibly edited) message. In case you don't save the message, the script will abort the commit.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
The code is heavily based on the script that "deepanchal" posted here.
This script was based on chhoumann's template.