AI Generate Commit is a tool that uses artificial intelligence to automatically generate meaningful commit messages based on your staged changes. This tool aims to streamline the git commit process and ensure consistent, descriptive commit messages across your project.
- Automatically generates commit messages based on staged changes
- Uses the GROQ API for AI-powered commit message generation
- Configurable commit message prompt
- Easy-to-use command-line interface
- Go 1.16 or higher
- Git
- Clone the repository:
git clone https://github.com/hambosto/ai-generate-commit.git
- Change to the project directory:
cd ai-generate-commit
- Build the project:
go build -o ai-generate-commit ./cmd/ai-generate-commit
- (Optional) Move the binary to a directory in your PATH:
sudo mv ai-generate-commit /usr/local/bin/
- Run following command to install the tool directly:
go install github.com/hambosto/ai-generate-commit/cmd/ai-generate-commit@latest
- Ensure that
$GOPATH/bin
is in yourPATH
so that you can run the tool from anywhere:
export PATH=$PATH:$(go env GOPATH)/bin
- Go to the Releases page of the project.
- Download the appropriate binary for your operating system.
- (Optional) Move the binary to a directory in your PATH:
sudo mv ai-generate-commit-* /usr/local/bin/ai-generate-commit
After installation, make sure the tool has the correct execution permissions:
-
If you installed the tool in a directory in your PATH (like
/usr/local/bin
):sudo chmod +x /usr/local/bin/ai-generate-commit
-
If you're using the tool from the build directory:
chmod +x ./ai-generate-commit
This ensures that you can run the tool without any permission issues.
Before using the tool, you need to set up your GROQ API key and customize the commit prompt if desired.
- Sign up for a GROQ account and obtain your API key from https://console.groq.com.
- Set your GROQ API key using the following command:
ai-generate-commit setConfig -key GROQ_APIKEY -value your_api_key_here
You can customize the prompt used for generating commit messages:
ai-generate-commit setConfig -key COMMIT_PROMPT -value "Your custom prompt here. Use {diff} as a placeholder for the git diff."
Default prompt if not set:
Based on the following git diff, please generate a concise and informative commit message:
{diff}
The commit message should follow these guidelines:
1. Start with a short summary (50 chars or less)
2. Followed by a blank line
3. Followed by a more detailed description, if necessary
Please write the commit message now:
- Stage your changes using
git add
. - Run the tool:
ai-generate-commit generate
- Review the generated commit message and confirm if you want to use it.
- Get the current value of a configuration key:
ai-generate-commit getConfig -key KEY_NAME
- Get the path of the configuration file:
ai-generate-commit getConfigPath
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.