Skip to content

lourenc/comsg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

comsg

CI Release

Generate commit messages from staged git diffs using OpenAI or Anthropic.

Install

Download the latest binary from Releases, or build from source:

cargo install --git https://github.com/lourenc/comsg

Setup

Set an API key in your environment:

# OpenAI (default provider)
export OPENAI_API_KEY="sk-..."

# or Anthropic
export ANTHROPIC_API_KEY="sk-ant-..."

Usage

Stage some changes and run:

comsg

That's it. It reads your staged diff and prints a commit message.

Options

-p, --provider <openai|anthropic>   AI provider (default: openai)
-m, --model <MODEL>                 Model override
-n, --number <N>                    Number of suggestions (default: 1)

Examples

# Generate a single commit message
comsg

# Get 5 suggestions to pick from
comsg -n 5

# Use Anthropic instead of OpenAI
comsg -p anthropic

# Pipe a diff directly
git diff --staged | comsg

# One-liner commit
git commit -m "$(comsg)"

Integrations

Git alias

# ~/.gitconfig
[alias]
    cm = "!comsg"

Then just git cm.

lazygit

# ~/.config/lazygit/config.yml
customCommands:
  - key: "C"
    context: "files"
    command: "git commit -m \"$(comsg)\""
    subprocess: true

prepare-commit-msg hook

#!/bin/bash
if [ "$2" = "" ]; then
    MSG=$(comsg 2>/dev/null)
    [ $? -eq 0 ] && [ -n "$MSG" ] && echo "$MSG" > "$1"
fi

Default models

Provider Model
OpenAI gpt-4o
Anthropic claude-sonnet-4-20250514

Override with -m:

comsg -m gpt-4o-mini
comsg -p anthropic -m claude-haiku-4-20250514

License

MIT

About

🤖 CLI tool that generates commit messages from staged git diffs using OpenAI or Anthropic APIs ⚡

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages