Skip to content

Repository files navigation

snapmit

AI-powered conventional commit messages with OpenAI-compatible API providers

Preview

snapmit helps you write clear, conventional, and meaningful Git commit messages automatically using AI. Save time, improve your commit history, and focus on what matters—your code.


Features

  • AI-Generated Commit Messages: Let AI analyze your staged changes and suggest concise, descriptive commit messages.
  • AI-Generated Pull Requests: Use snapmit pr to push your branch and open a GitHub pull request with an AI-generated conventional title (and body).
  • Multi-Provider Support: Use Google Gemini (default) or any OpenAI-compatible API (OpenAI, Ollama, LM Studio, vLLM, etc.)
  • Customizable Output: Tailor the message style and structure to fit your workflow.
  • Conventional Commits: Ensures messages follow best practices for readability and automation.
  • Cross-Platform: Works on Linux, Windows, and macOS.
  • Open Source: Free to use and contribute.
  • Automatic Push: Push committed changes to remote repository with --push flag.
  • Advanced Customization: Fine-tune commit messages with various flags and options.
  • Smart Issue Detection: Automatically detects and references issue numbers from branch names.
  • Custom API Endpoints: Configure custom base URLs for API endpoints.

Quickstart

# 1. Install (Go required)
go install github.com/fiandev/snapmit@latest

# 2. Get your API key
#    Gemini: https://aistudio.google.com/app/apikey
#    OpenAI: https://platform.openai.com/api-keys

# 3. Configure your API key
snapmit config set api.key <your-api-key>

# 4. (Optional) Configure provider, model, and base URL
snapmit config set api.provider gemini       # or: openai (default: gemini)
snapmit config set api.model gemini-2.5-pro  # or: gpt-4o
snapmit config set api.baseurl https://your-proxy  # optional: custom endpoint

# 5. Stage your changes
git add <file>

# 6. Generate and commit
snapmit

Requirements

  • Go 1.24+ (for go install)
  • Git
  • Gemini API key from Google AI Studio
  • GitHub CLI (gh) for snapmit pr

Installation

  • From Source:

    Add To Path:

    • Zshrc:

      echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.zshrc
      source ~/.zshrc
    • Bashrc:

      echo 'export PATH="$PATH:$HOME/go/bin"' >> ~/.bashrc
      source ~/.bashrc
    go install github.com/fiandev/snapmit@latest
  • Standalone Binary: Download from the releases page and move to a directory in your PATH:

    • Linux: $HOME/.local/bin/ or /usr/local/bin/
    • Windows: %LocalAppData%\Programs\
    • macOS: /usr/local/bin/
  • Arch Linux (AUR):

    yay -S snapmit-bin
  • Fedora (Copr):

    sudo dnf copr enable fiandev/snapmit
    sudo dnf install snapmit
  • NixOS:

    environment.systemPackages = [
      pkgs.snapmit
    ];

Configuration

Basic Setup

  1. Get your API key from Google AI Studio.

  2. Set your key:

    snapmit config set api.key <your-api-key>
    snapmit config get api.key

Advanced Configuration

Configure additional settings using the snapmit config command:

# Set or change the AI provider (default: gemini)
snapmit config set api.provider gemini    # Google Gemini
snapmit config set api.provider openai    # OpenAI or OpenAI-compatible

# Set or change the model (default: gemini-2.5-flash)
snapmit config set api.model gemini-2.5-pro
snapmit config set api.model gpt-4o

# Set custom API base URL (for proxy servers or custom endpoints)
snapmit config set api.baseurl https://your-proxy.example.com
snapmit config get api.baseurl

# Clear custom base URL (revert to default)
snapmit config set api.baseurl ""

# View current API key
snapmit config get api.key

# List all current configuration values
snapmit config list

All configuration is stored in ~/.config/snapmit/config.toml.

Available Configuration Keys

[api]
api.key             - Gemini API key
api.model           - Model name (default: gemini-2.5-flash)
api.baseurl         - Custom base URL for API
api.provider        - AI provider: gemini, openai (default: gemini)

[commit]
commit.language     - Language for commit messages (default: english)
commit.max_length   - Maximum length of commit message (default: 72)

[behavior]
behavior.stage_all   - Stage all changes in tracked files (default: false)
behavior.auto_select - Let AI select files and generate commit message (default: false)
behavior.no_confirm  - Skip confirmation prompt (default: false)
behavior.quiet       - Suppress output (default: false)
behavior.push        - Push committed changes to remote (default: false)
behavior.dry_run     - Run without making changes (default: false)
behavior.show_diff   - Show diff before committing (default: false)
behavior.no_verify   - Skip git commit-msg hook verification (default: false)

Configuration File Format

The configuration file uses TOML format:

[api]
key = "your-api-key"
model = "gemini-2.5-flash"
baseurl = "https://your-proxy.example.com"  # optional
provider = "gemini"  # or: openai

Usage

  1. Stage your changes:

    git add <file>
  2. Run the CLI to generate a commit:

    snapmit
  3. Review and edit the AI-generated message if needed.

  4. snapmit will commit your changes with the generated message.

Create Pull Requests

Use Gemini to draft a PR title & body and open a GitHub pull request:

snapmit pr              # opens a ready-for-review PR
snapmit pr --draft      # create as draft
snapmit pr --dry-run    # preview without pushing

You can combine --yes -q, --show-diff, --language, --baseurl, and other flags just like the commit command.

Advanced Usage & Customization

Commit Message Customization Flags

# Preview commit without making changes
snapmit --dry-run

# Display the diff before committing
snapmit --show-diff

# Set maximum commit message length (default: 72 characters)
snapmit --max-length 50

# Generate commit messages in different languages
snapmit --language spanish
snapmit --language french

# Reference specific issue numbers
snapmit --issue "#123"
snapmit --issue "JIRA-456"

# Skip git commit-msg hook verification
snapmit --no-verify

# Push committed changes to remote repository
snapmit --push

# Use custom API endpoint
snapmit --baseurl https://your-proxy.example.com

# Use specific Gemini model
snapmit --model gemini-1.5-pro

Auto Issue Detection

snapmit automatically detects issue numbers from branch names using common patterns:

  • feature-123-description → references issue #123
  • fix-456-bug → references issue #456
  • #789-feature → references issue #789
  • issue-101 → references issue #101

Combining Options

# Comprehensive example: dry run with diff, custom length, and language
snapmit --dry-run --show-diff --max-length 60 --language spanish

# Production workflow: commit and push with issue reference
snapmit --issue "#123" --push --no-verify

# Using custom endpoint with specific model
snapmit --baseurl https://your-proxy.example.com --model gemini-2.5-pro

Multi-Provider Usage

Google Gemini (Default)

# Default behavior - uses Gemini
snapmit

# Explicit Gemini with specific model
snapmit --provider gemini --model gemini-2.5-pro

OpenAI

# Use OpenAI GPT-4o
snapmit --provider openai --model gpt-4o

# Via config
snapmit config set api.provider openai
snapmit config set api.model gpt-4o
snapmit

Ollama (Local)

# Use Ollama with a local model
snapmit --provider openai --model llama3 --baseurl http://localhost:11434/v1

# Via config
snapmit config set api.provider openai
snapmit config set api.model llama3
snapmit config set api.baseurl http://localhost:11434/v1
snapmit

LM Studio (Local)

# Use LM Studio with a local model
snapmit --provider openai --model local-model --baseurl http://localhost:1234/v1

# Via config
snapmit config set api.provider openai
snapmit config set api.model local-model
snapmit config set api.baseurl http://localhost:1234/v1
snapmit

Other OpenAI-Compatible APIs

# Azure OpenAI, vLLM, LiteLLM, etc.
snapmit --provider openai --model gpt-4o --baseurl https://your-endpoint.openai.azure.com

# Via config
snapmit config set api.provider openai
snapmit config set api.model gpt-4o
snapmit config set api.baseurl https://your-endpoint.openai.azure.com
snapmit

For more options:

snapmit --help

Contributing

Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.


License

This project is licensed under the GPLv3 License. See the LICENSE file for details.

Support Palestine

About

AI-powered conventional commit messages with OpenAI-compatible API providers

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages