Skip to content

sidedwards/auto-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auto-commit

Automatically generate git commit messages using Claude 3 Haiku. This tool analyzes your staged changes and creates clear, concise commit messages. It uses the Conventional Commit format by default but can adapt to repository-specific or author-specific styles.

auto-commit-demo

Features

  • Generates clear, concise commit messages from staged changes
  • Supports multiple LLM providers:
    • Anthropic Claude (default)
    • OpenAI GPT models
    • Ollama (local LLMs)
  • Supports various commit formats:
    • Conventional Commits (default)
    • Angular
    • Semantic Git Commits (with emojis)
    • Linux Kernel style
    • GitHub issue-reference style (e.g., [#123]: description)
    • Custom styles from repository or author history
  • Simple CLI interface

Quick Start

Get up and running in minutes:

  1. Install the tool:

    curl -fsSL https://raw.githubusercontent.com/sidedwards/auto-commit/main/scripts/install.sh | bash
  2. Set up your API key (if using Anthropic or OpenAI):

  3. Generate a commit message:

    git add <files>
    auto-commit
  4. Review and confirm:

    • Accept, edit, reject, or regenerate the proposed commit message.

Installation

Quick Install (Recommended for macOS/Linux)

curl -fsSL https://raw.githubusercontent.com/sidedwards/auto-commit/main/scripts/install.sh | bash

This script:

  • Downloads the correct binary for your system.
  • Adds it to your PATH.
  • Makes it executable.

Manual Installation

  1. Download the latest release from GitHub Releases.

  2. Move the binary to a PATH directory and make it executable:

    • macOS (M1/M2):
      sudo mv auto-commit-darwin-arm64 /usr/local/bin/auto-commit
      sudo chmod +x /usr/local/bin/auto-commit
    • macOS (Intel):
      sudo mv auto-commit-darwin-x64 /usr/local/bin/auto-commit
      sudo chmod +x /usr/local/bin/auto-commit
    • Linux:
      sudo mv auto-commit-linux-x64 /usr/local/bin/auto-commit
      sudo chmod +x /usr/local/bin/auto-commit
    • Windows (PowerShell as Admin):
      move auto-commit-windows-x64.exe C:\Windows\System32\auto-commit.exe

Install from Source

  1. Install Deno:
    curl -fsSL https://deno.land/x/install/install.sh | sh
  2. Clone and install:
    git clone https://github.com/sidedwards/auto-commit.git
    cd auto-commit
    deno task install

Updating

  • Quick Install or Manual:
    curl -fsSL https://raw.githubusercontent.com/sidedwards/auto-commit/main/scripts/install.sh | bash
  • From Source:
    cd auto-commit
    deno task update

Usage

Basic Usage

  1. Stage your changes:
    git add <files>
  2. Run the tool:
    auto-commit
  3. Review the commit message and select:
    • (a)ccept
    • (e)dit
    • (r)eject
    • (n)ew message

Advanced Options

  • Add a Git alias:

    git config --global alias.ac '!auto-commit'

    Then use: git ac

  • Choose a commit format:

    auto-commit --format=conventional  # Default
    auto-commit --format=angular      # Angular style
    auto-commit --format=semantic     # With emojis
    auto-commit --format=kernel       # Linux Kernel style
    auto-commit --format=issue        # GitHub issue-reference
  • Learn custom styles:

    • From repository history:
      auto-commit --learn
    • From a specific author:
      auto-commit --learn --author="[email protected]"
  • List repository authors:

    auto-commit --list-authors

LLM Provider Options

Choose the LLM provider and model that best suits your needs.

Providers and Models

  • Anthropic Claude (default):

    • claude-3-5-haiku-20241022 (default): Fast and compact.
    • claude-3-5-sonnet-20241022: Balanced performance.
    • claude-3-7-sonnet-20250219: Most powerful with reasoning.
  • OpenAI:

    • gpt-4o-mini (default): Fast and cost-effective.
    • gpt-4o: Fast, intelligent, and flexible.
    • o3-mini: Fast and flexible with reasoning.
    • o1: High intelligence with reasoning.
  • Ollama (local LLMs):

    • Depends on your Ollama setup. Examples:
      • llama3 (default): Meta's latest model.
      • mistral: Mistral 7B.
      • mixtral: Mixtral 8x7B.
      • codellama: Code-optimized.

Commands

  • List all models:
    auto-commit --list-models
  • List models for a provider:
    auto-commit --list-models --provider=anthropic
  • Use a specific provider/model:
    auto-commit --provider=anthropic --model=claude-3-opus-20240229
    auto-commit --provider=openai --model=gpt-4o
    auto-commit --provider=ollama --model=llama3
  • Custom Ollama URL:
    auto-commit --provider=ollama --base-url=http://localhost:11434

Configuration

  • API Keys:

    • Required for Anthropic/OpenAI; set on first run.
    • Not needed for Ollama (just run the Ollama server locally).
    • Links: Anthropic | OpenAI
  • Commit Formats:

    • Default: Conventional Commits.
    • Change with --format (see Usage).
  • Custom Styles:

    • Train with --learn or --learn --author="email".

Requirements

  • Git
  • GitHub CLI (gh) - for issue integration
  • Vim - for editing commit messages
  • API keys (Anthropic/OpenAI) or Ollama running locally

License

MIT