A command-line tool that uses the power of Google's Gemini AI to automatically generate concise, descriptive commit messages for your staged changes.
- AI-Powered: Generates a 7-word commit message based on your staged diff.
- Interactive: Prompts you to accept, reject, or regenerate the message.
- Automatic Push: Commits and pushes your changes to GitHub in one go.
- Simple Workflow: Just stage your files and run one command.
You can install the AI Committer CLI globally via npm, which allows you to run it from any directory on your system.
-
Prerequisites: You must have Node.js (version 16 or higher) installed.
-
Install from GitHub: Run the following command in your terminal to install the tool directly from this repository.
npm install -g git+https://github.com/Rishav07-05/ai_commit.git
This will install the package and make the ai-commit command available globally.
The tool requires a Google Gemini API key to function.
-
Get an API Key: Obtain your free API key from Google AI Studio.
-
Set the Environment Variable: Before running the tool, you must set your API key as an environment variable named
GEMINI_API_KEY.On macOS and Linux:
export GEMINI_API_KEY="YOUR_API_KEY_HERE"
On Windows (Command Prompt):
set GEMINI_API_KEY=YOUR_API_KEY_HERENote: You need to set this variable once per terminal session.
The workflow is designed to be simple and fast.
-
Make Your Code Changes: Modify your project files as you normally would.
-
Stage Your Files: Use
git addto stage the files you want to include in the commit.git add . -
Run the AI Committer: Execute the
ai-commitcommand.ai-commit
The tool will then:
- Analyze your staged changes.
- Display an AI-generated commit message.
- Prompt you to take action:
- Type
yto commit and push the changes. - Type
nto abort the commit. - Type
rto regenerate a new message.
- Type
Interested in contributing? Here’s how to set up the project for local development.
-
Clone the Repository:
git clone https://github.com/Rishav07-05/ai_commit.git cd ai_commit -
Install Dependencies:
npm install
-
Run in Development Mode: The
npm run gocommand compiles the code and runs the script, simulating the final workflow.# Make sure to set your API key first export GEMINI_API_KEY="YOUR_API_KEY_HERE" # Stage some files git add . # Run the development script npm run go
