@mitesh_1803/commit-gen
v1.0.12
Published
<div align="center"> <h1>✨ Commit-Gen</h1> <p><b>AI-powered git commit message generator using Gemini API</b></p>
Readme
Tired of writing boring commit messages? Commit-Gen analyzes your staged git changes using a local Ollama LLM (with Gemini as fallback) and generates clean, conventional commit messages. Pick your favorite with arrow keys!
🚀 Features
- 🤖 Local LLM First: Uses your own Ollama instance on EC2 for privacy and speed
- ☁️ Gemini Fallback: Automatically falls back to Gemini if Ollama is unavailable
- 🧠 Smart Analysis: Understands context of your staged git diffs
- 🎯 Multiple Options: Generates 3 high-quality commit messages to choose from
- 🕹️ Interactive CLI: Spinners and arrow key prompts via
nanospinnerandinquirer - ⚡ Quick & Easy: Commit without ever leaving your terminal
- 🔑 Secure Config: Saves your Gemini API key locally for future use.
📦 Installation
You don't even need to install it! You can run it directly using npx:
npx @mitesh_1803/commit-genAlternatively, you can install it globally to use the commit-gen command anywhere:
npm install -g @mitesh_1803/commit-gen🛠️ Setup & Usage
Option A — Using Ollama (Primary, Recommended)
Run your own local LLM on any server using Ollama(I have used AWS EC2 Instance).
- Install Ollama on your server:
curl -fsSL https://ollama.ai/install.sh | sh- Pull the model:
ollama pull qwen2.5-coder:1.5b- Start Ollama on all interfaces:
OLLAMA_HOST=0.0.0.0 ollama serve- Set your Ollama URL in
.env:
Option B — Using Gemini (Fallback)
If Ollama is unavailable, the tool automatically falls back to Gemini.
- Get your free API key from Google AI Studio
- On first run the tool will ask for your key and save it to
~/.commit-gen-config
Running the tool
Stage your changes:
git add .Run:
commit-gen
# or
npx @mitesh_1803/commit-genWhat happens:
- Spinner shows while connecting to Ollama
- If Ollama fails → automatically switches to Gemini
- Pick from 3 commit messages with arrow keys
- Press Enter → committed automatically 🎉
4. Follow the Prompts
- It will read your staged changes and generate a list of commit options.
- Use your arrow keys to select the perfect commit message.
- Press Enter, and the tool will automatically commit your changes! 🎉
- If ollama fail,the CLI will ask for your Gemini API key and securely save it in
~/.commit-gen-config.
📖 CLI Options
Usage: commit-gen [options]
Options:
--version Show version number
--help Show the help message⚙️ How it works
- Reads your staged changes with
git diff --staged - Tries your Ollama instance first (fast, private, local LLM)
- If Ollama unavailable → falls back to Gemini API automatically
- Returns 3 conventional commit message suggestions
- You pick one with arrow keys
- Tool runs
git commitautomatically
🛠️ Built with
- Ollama — local LLM runner (primary)
- Google Gemini AI — cloud fallback
- Inquirer.js — interactive prompts
- Nanospinner — terminal spinners
- TypeScript — type safety
🤝 Contributing
Contributions, issues, and feature requests are welcome! Feel free to check out the issues page
📄 License
This project is licensed under the ISC License.
