Skip to content

warunacds/autogit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

autogit

A CLI tool that generates git commit messages using AI.

Analyzes your staged git diff, calls an AI model to suggest a Conventional Commits message, then lets you accept, edit, regenerate, or abort — all from the terminal. Supports Claude (API key or Claude Code Pro/Max subscription), ChatGPT, Ollama, LM Studio, Gemini, and any OpenAI-compatible endpoint.

Demo

$ autogit init

Select a provider:
  1) Claude (Anthropic API key)
  2) Claude Code (Pro/Max subscription — no API key needed)
  3) OpenAI-compatible (ChatGPT, Ollama, LM Studio, Gemini, etc.)
> 1

Model name [claude-opus-4-6]:
>

Config saved to ~/.autogit.yaml
$ git add .
$ autogit

[autogit] Analyzing changes...
[autogit] Generating commit message...

Generated message:
─────────────────────────────────────────
feat: add user authentication with JWT tokens

- Implement login/logout endpoints
- Add JWT middleware for protected routes
- Store refresh tokens in Redis
─────────────────────────────────────────

[a] Accept  [A] Accept and Push  [e] Edit in $EDITOR  [r] Regenerate  [q] Quit
>

With --all to interactively select which files to stage:

$ autogit --all

Select files to stage (3/4 selected):
  [x]  M  internal/ui/prompt.go
  [x]  A  internal/git/status.go
> [ ]  ?  temp.log
  [x]  M  main.go

  ↑/↓ navigate  space toggle  a all  n none  enter confirm  q quit

[autogit] Staged 3 file(s):
  • internal/ui/prompt.go
  • internal/git/status.go
  • main.go

[autogit] Analyzing changes...
[autogit] Generating commit message...

Files to commit (3):
  internal/ui/prompt.go
  internal/git/status.go
  main.go

Generated message:
─────────────────────────────────────────
feat: add file selector and status parsing
─────────────────────────────────────────

[a] Accept  [A] Accept and Push  [e] Edit in $EDITOR  [r] Regenerate  [q] Quit
>

If you run autogit without --all and nothing is staged, the file selector is shown automatically.

With --push to automatically push after committing:

$ git add .
$ autogit --push

[autogit] Analyzing changes...
[autogit] Generating commit message...
...
[autogit] Committed successfully!
[autogit] Pushing...
[autogit] Pushed successfully!

Requirements

  • Go 1.22+
  • An API key for your chosen provider (not needed for local models or Claude Code)

Setup

1. Install autogit

go install github.com/warunacds/autogit@latest

Or build from source:

git clone https://github.com/warunacds/autogit
cd autogit
go build -o autogit .
sudo mv autogit /usr/local/bin/autogit

2. Run the setup wizard

autogit init

This creates ~/.autogit.yaml with your provider, model, and endpoint settings.

3. Set your API key

Add the appropriate key to your ~/.zshrc or ~/.bashrc:

# For Claude (API key)
export ANTHROPIC_API_KEY=sk-ant-...

# For ChatGPT / OpenAI
export OPENAI_API_KEY=sk-...

Then reload: source ~/.zshrc

For Claude Code (Pro/Max subscription) and local models (Ollama, LM Studio), no API key is needed.

4. Verify it works

autogit --help

Updating

If you installed with go install:

go install github.com/warunacds/autogit@latest

If you built from source:

cd autogit
git pull
go build -o autogit .
sudo mv autogit /usr/local/bin/autogit

Usage

# Stage your changes
git add .

# Generate and commit
autogit

# Select files to stage interactively
autogit --all

# Commit and push in one step
autogit --push
autogit -p          # shorthand

# Override provider or model for one run
autogit --provider openai --model gpt-4o-mini
autogit --provider claudecode

Interactive options

Key Action
a Accept the message and commit
A Accept the message, commit, and push
e Open $EDITOR to edit the message
r Regenerate — call the AI again for a new suggestion
q Quit without committing
(type anything) Replace the message inline and loop back

Providers

Claude (Anthropic)

autogit init  # select 1) Claude
export ANTHROPIC_API_KEY=sk-ant-...

Config (~/.autogit.yaml):

provider: claude
claude:
  model: claude-opus-4-6

Claude Code (Pro/Max subscription)

Uses the claude CLI — no API key needed. Requires a Claude Code Pro or Max subscription.

autogit init  # select 2) Claude Code
# Make sure `claude` is installed and you're logged in

Config (~/.autogit.yaml):

provider: claudecode
claudecode:
  model: ""  # leave empty for CLI default, or set a specific model

ChatGPT (OpenAI)

autogit init  # select 3) OpenAI-compatible
# Use default base URL: https://api.openai.com/v1
export OPENAI_API_KEY=sk-...

Config:

provider: openai
openai:
  base_url: https://api.openai.com/v1
  model: gpt-4o

Ollama (local)

autogit init  # select 3) OpenAI-compatible
# Set base URL to: http://localhost:11434/v1
# No API key needed

Config:

provider: openai
openai:
  base_url: http://localhost:11434/v1
  model: llama3

LM Studio (local)

autogit init  # select 3) OpenAI-compatible
# Set base URL to: http://localhost:1234/v1
# No API key needed

Config:

provider: openai
openai:
  base_url: http://localhost:1234/v1
  model: local-model

Gemini (Google)

autogit init  # select 3) OpenAI-compatible
# Set base URL to: https://generativelanguage.googleapis.com/v1beta/openai
export OPENAI_API_KEY=your-gemini-api-key

Config:

provider: openai
openai:
  base_url: https://generativelanguage.googleapis.com/v1beta/openai
  model: gemini-2.0-flash

How it works

  1. Loads provider config from ~/.autogit.yaml (with CLI flag overrides)
  2. With --all (or when nothing is staged), shows an interactive file selector to choose which files to stage
  3. Reads your staged git diff (git diff --cached)
  4. Sends the diff to the configured AI provider with a Conventional Commits prompt
  5. Shows the generated message with an interactive menu
  6. Commits via git commit -m using your existing git config (name/email)
  7. Optionally pushes to the remote with --push / -p or interactively with A

Diffs larger than 100 KB are automatically truncated before sending to the API.

Configuration

Setting How to set
Provider autogit init or --provider flag
Model autogit init or --model flag
Claude API key ANTHROPIC_API_KEY environment variable
Claude Code claude CLI installed and logged in (Pro/Max subscription)
OpenAI API key OPENAI_API_KEY environment variable (not needed for local models)
Editor EDITOR environment variable (falls back to nano)
Diff scope --all flag (default: staged only)
Push after commit --push / -p flag (default: off)

License

MIT

About

CLI tool that generates git commit messages using AI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages