A powerful CLI tool that helps you generate meaningful commit messages with AI by analyzing your Git changes.
Commit Sage analyzes the changes in your Git repository and uses AI to generate contextually relevant commit messages. It saves you time and helps maintain a consistent commit history with descriptive messages.
- Analyzes staged and unstaged changes in your Git repository
- Generates commit messages based on the actual code changes
- Supports different types of changes (staged, unstaged, untracked, deleted)
- Skips submodule changes automatically
- Works with any Git repository
- Git installed and accessible in your PATH
- Internet connection for AI service communication (unless using Ollama)
- Deno 2.x or higher (if compiling from source)
- Commit Sage detects if you're in a Git repository
- It analyzes the changes in your repository (staged, unstaged, etc.)
- The changes are processed and sent to an AI service
- The AI generates a contextually relevant commit message
- The suggested commit message is displayed for you to use
Commit Sage provides clear error messages for common issues:
- When no changes are detected
- When the API key is not set
- When Git is not installed or the directory is not a Git repository
You can download the prebuilt binary for your platform from the Releases page on GitHub. Follow these steps:
- Visit the Releases page.
- Download the appropriate binary for your operating system (e.g.,
commit-sage-linux
,commit-sage-macos
, orcommit-sage-windows.exe
). - Rename the binary to
commit-sage
and place it in a directory included in your$PATH
(e.g.,~/.local/bin
for Linux/macOS or any directory for Windows). - Ensure the binary is executable (on Linux/macOS, run
chmod u+x commit-sage
). - Run
commit-sage
from your terminal to use the tool.
Alternatively, you can build from source.
Clone the repository and compile the executable:
git clone https://github.com/AhmedOsman101/commit-sage-cli.git commit-sage
cd commit-sage
# Compiles the executable to your `~/.local/bin` directory. Ensure `~/.local/bin` is added to your $PATH.
deno task run compile
Note
If you plan to compile the project yourself, make sure you have Deno installed on your system.
Navigate to your Git repository and run commit-sage
to generate a commit message based on your changes:
For enhanced functionality, consider using the git-commit
wrapper script from AhmedOsman101/shellScripts.
This wrapper script extends commit-sage
with:
- Conventional commit message support
- AI-powered commit messages using
commit-sage
- Additional Git integration features
To use the wrapper script:
- Install it from AhmedOsman101/shellScripts
- Run
git-commit --ai
in your repository instead ofcommit-sage
The wrapper script provides a seamless integration between conventional commit formats and AI-generated messages.
The app requires an API key for the AI service it uses. You can set it up in two ways:
Add the following to your shell configuration file (e.g., ~/.bashrc
, ~/.zshrc
):
export SERVICE_API_KEY='your_api_key'
Replace SERVICE
with the appropriate service name and your_api_key
with your actual API key.
After adding these lines, restart your terminal or run source ~/.bashrc
to apply the changes.
Export before running
This method sets the API key for a single run.
SERVICE_API_KEY='your_api_key' commit-sage
Note
If you're using ollama
as your provider, you can skip all API key and environment variable setup.
Ollama runs locally and requires no authentication or network access.
You can customize any options in the configuration file located at ~/.config/commitSage/config.json
.
The configuration file allows customization of retry behavior, model providers, commit formatting, and default provider usage.
Key | Type | Default | Description |
---|---|---|---|
maxRetries |
number | 3 |
Number of retry attempts on failure. |
initialRetryDelayMs |
number | 1000 |
Delay (ms) before the first retry. |
Key | Type | Default | Options |
---|---|---|---|
model |
string | "gemini-2.0-flash-exp" |
"gemini-2.0-flash-exp" , "gemini-1.0-pro" , "gemini-1.5-pro" , "gemini-1.5-flash" |
Key | Type | Default | Description |
---|---|---|---|
model |
string | "llama3.2" |
Name of the Ollama model. |
baseUrl |
string | "http://localhost:11434" |
Base URL for the Ollama API. |
Key | Type | Default | Options |
---|---|---|---|
model |
string | "codestral-2405" |
"codestral-2405" , "codestral-latest" |
Key | Type | Default | Description |
---|---|---|---|
model |
string | "gpt-3.5-turbo" |
OpenAI model to use. |
baseUrl |
string | "https://api.openai.com/v1" |
OpenAI API base URL. |
Key | Type | Default | Options / Description |
---|---|---|---|
onlyStagedChanges |
boolean | true |
Limit commit messages to staged changes. |
commitLanguage |
string | "english" |
"english" , "russian" , "chinese" , "japanese" |
autoCommit |
boolean | false |
Automatically commit after generating message. |
autoPush |
boolean | false |
Push to remote after committing. |
commitFormat |
string | "conventional" |
"conventional" , "angular" , "karma" , "emoji" , "semantic" |
promptForRefs |
boolean | false |
Ask for refs (e.g., issue numbers) during commit. |
Key | Type | Default | Options |
---|---|---|---|
type |
string | "gemini" |
"gemini" , "codestral" , "openai" , "ollama" |
The following are known limitations in the current version of commit-sage, with plans to address them in future updates:
-
Handle files with spaces in their names
Previously, the program may have failed or behaved unexpectedly when processing files with spaces in their names. This has been resolved. -
Configuration options not yet implemented
The following options are defined in the schema for forward compatibility, but are currently non-functional and will be ignored at runtime:-
commit.autoCommit
-
commit.autoPush
-
commit.onlyStagedChanges
-
commit.promptForRefs
-
Note
These options can safely remain in your config. They won't cause any errors, but currently have no effect.
They are included as placeholders for upcoming features that are under active consideration or development.
Contributions are welcome! Please read the CONTRIBUTING.md file for guidelines before submitting a Pull Request.
By contributing to commit-sage-cli
, you agree to license your contributions under the GNU General Public License v3.0.
commit-sage-cli
was inspired by the CommitSage VS Code extension by Ivan K. (GitHub), licensed under the MIT License. His project motivated me to create a Deno CLI tool, adapting its approach to commit generation for CLI use. Thank you, Ivan, for your open-source contribution.
commit-sage-cli
is licensed under the GNU General Public License v3.0. The full text of the GPLv3 is available in the LICENSE file.
For questions or feedback about commit-sage-cli
, please contact me via GitHub or email at ahmad.ali.othman@outlook.com.