An AI-powered CLI tool that analyzes your staged changes and generates structured, conventional commit messages using LangChain and Ollama.
Note
While the following guide specifically targets Arch Linux and the Fish shell, main.py is entirely platform-independent. You can easily adapt the shortcut command for Bash, Zsh, or Windows (PowerShell).
-
Clone the Repository (to
~/tools/) -
Congigure Environment Variables (Optional) If you are using a custom Ollama setup, you can set these in your shell configuration (e.g.
~/.config/fish/config.fish):set -gx OLLAMA_BASE_URL "http://localhost:11434" # Your Ollama URL set -gx OLLAMA_MODEL "gemma4:31b-cloud" # Your preferred model
-
Create Fish Shell Function
# ~/.config/fish/functions/gcm.fish function gcm --description "Generate git commit message using AI (via uv venv)" if not git rev-parse --is-inside-work-tree >/dev/null 2>&1 echo "Error: Not a git repository (or any of the parent directories)" return 1 end ~/tools/gcm/.venv/bin/python ~/tools/gcm/main.py end
-
Rule Ingestion: Reads
[simple_]commit_message_rule.mdto strictly follow the Conventional Commits specification. -
Log Analysis: Fetches commit history from the current branch using
git log --onelineto understand your writing style. -
Diff Analysis: Automatically fetches staged changes using
git diff --cached. -
AI Generation: Streams 3 distinct commit message options tailored to your codebase changes, letting you choose the best fit.
Stage your changes first, then run gcm from anywhere inside your repository:
# under repo dir
git add <some files>
gcm