Skip to main content

AI-generated Git commits

Project description

pycommit-ai

AI-powered Git commit message generator — get meaningful, conventional commit messages from multiple AI providers simultaneously.

Inspired by aicommit2, rewritten in Python.

✨ Features

  • 🤖 Multi-provider support — Gemini, OpenAI, Groq, and OpenRouter
  • 📝 Conventional Commits & Gitmoji — choose your preferred commit style
  • 🌍 Multilingual — generate messages in any locale (e.g., en, pt, es)
  • Concurrent generation — queries all configured providers at once
  • 🚀 Pull Request Generation — generates PR descriptions from branch diffs
  • 🔧 Flexible configuration — INI file, environment variables, or CLI flags
  • ⌨️ Quick alias — use pyc as a fast shortcut

📦 Installation

Requirements: Python ≥ 3.13, uv

Global Install

uv tool install git+https://github.com/dnilsonc/pycommit-ai.git

(The pycommit-ai command and pyc short alias will be available globally)

Update/Uninstall:

uv tool upgrade pycommit-ai
uv tool uninstall pycommit-ai

Alternative methods

Method Command
pipx pipx install git+https://github.com/dnilsonc/pycommit-ai.git
pip pip install git+https://github.com/dnilsonc/pycommit-ai.git
Local dev git clone ... && cd pycommit-ai && uv sync

🚀 Quick Start

  1. Configure an AI provider (or multiple)
# Gemini (default model: gemini-2.5-flash)
pycommit-ai config set GEMINI.key=YOUR_GEMINI_API_KEY

# OpenAI (default model: gpt-4o-mini)
pycommit-ai config set OPENAI.key=YOUR_OPENAI_API_KEY

# Groq (default model: llama3-8b-8192)
pycommit-ai config set GROQ.key=YOUR_GROQ_API_KEY

# OpenRouter (default model: google/gemini-2.0-flash-001)
pycommit-ai config set OPENROUTER.key=YOUR_OPENROUTER_API_KEY
  1. Stage your changes and run
git add .
pycommit-ai
  1. Generate a Pull Request description
pyc --pr

(Optionally, set a custom PR template: pyc config set PR.templatePath=~/my-pr-template.md)

🏳️ CLI Flags

Flag Short Description
--locale -l Locale for the commit message (e.g., pt, en, es)
--generate -g Number of messages to generate per model
--all -a Stage all changed files before generating
--type -t Commit message style: conventional or gitmoji
--confirm -y Auto-commit with the first generated message (no prompt)
--dry-run -d Show generated messages without committing
--copy -c Copy the selected message to clipboard instead of committing
--exclude -x Files to exclude from the diff (can be used multiple times)
--print-prompt -p Don't use AI, just print and copy the generated prompt

Examples

pycommit-ai -g 3 -l pt             # 3 messages per model in Portuguese
pycommit-ai -a -t gitmoji -y       # Gitmoji, stage all, auto-commit
pycommit-ai -c                     # Copy message to clipboard instead of committing
pyc -x "*-lock.json"               # Exclude lock files from diff
pyc --pr                           # Generate a PR description
pyc --pr --print-prompt            # Print the prompt without calling the AI

Note: Common lock files (uv.lock, package-lock.json, etc.) are excluded by default.

⚙️ Configuration

Configuration is stored in ~/.config/pycommit-ai/config.ini (follows XDG).

Config Commands

pycommit-ai config set KEY=VALUE          # Set a value
pycommit-ai config get KEY                # Get a value
pycommit-ai config list                   # List all keys
pycommit-ai config del KEY                # Delete a key
pycommit-ai config path                   # Show config file path

Available Settings

Setting Default Description
locale en Language for generated messages
generate 1 Number of messages per model
type conventional Commit style (conventional / gitmoji)
maxLength 50 Max character length for the subject line
timeout 10000 Request timeout in milliseconds
maxTokens 2048 Max tokens for AI response
temperature 0.7 AI creativity (0.0 – 1.0)
topP 1.0 Nucleus sampling parameter
systemPrompt Custom system prompt (inline)
systemPromptPath Path to a custom system prompt file
PR.template Custom PR template (inline markdown)
PR.templatePath Recommended: Path to a .md custom PR template file

Provider Settings

Each provider supports key and model (comma-separated for multiple models):

# Use multiple models for a single provider
pycommit-ai config set OPENAI.model=gpt-4o,gpt-4o-mini

# Custom API URL (OpenAI-compatible endpoints)
pycommit-ai config set OPENAI.url=https://your-custom-api.com
pycommit-ai config set OPENAI.path=/v1/chat/completions

Environment Variables

API keys can also be set via environment variables:

export GEMINI_API_KEY=your-key
export OPENAI_API_KEY=your-key
export GROQ_API_KEY=your-key
export OPENROUTER_API_KEY=your-key

Use PYCOMMIT_AI_CONFIG_PATH to override the config file location:

export PYCOMMIT_AI_CONFIG_PATH=/path/to/custom/config.ini

Config Priority

Settings are resolved in this order (highest priority first):

  1. CLI flags (--locale, --generate, etc.)
  2. Environment variables (GEMINI_API_KEY, etc.)
  3. Config file (~/.config/pycommit-ai/config.ini)
  4. Defaults

🧪 Development

# Install dev dependencies
uv sync --group dev

# Run tests
uv run pytest -v

# Run the CLI locally
uv run pycommit-ai --help

📄 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycommit_ai-0.6.1.tar.gz (54.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycommit_ai-0.6.1-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file pycommit_ai-0.6.1.tar.gz.

File metadata

  • Download URL: pycommit_ai-0.6.1.tar.gz
  • Upload date:
  • Size: 54.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycommit_ai-0.6.1.tar.gz
Algorithm Hash digest
SHA256 57433958f57ba8f901a9e47c2073835113083977218c2efc57f2dd5474900d43
MD5 bc9b63ff5bebd8093daa2936e311a42a
BLAKE2b-256 4372ced558b4290b348210f5fec85a78c1ec227688d7023e1c31d53fc7582008

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycommit_ai-0.6.1.tar.gz:

Publisher: publish.yml on dnilsonc/pycommit-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycommit_ai-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: pycommit_ai-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pycommit_ai-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b9df278efcf7d0722d7f2d707990ab69f350df1e8e0e1c0c98f3885bf2857240
MD5 f7a37f2d602ba2037ce416ae63106637
BLAKE2b-256 9959d65ae5cf1a0422f55e6efb24e64225f119d358d9a03d7b03eb4c16151bc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycommit_ai-0.6.1-py3-none-any.whl:

Publisher: publish.yml on dnilsonc/pycommit-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page