Skip to content

Yangge521/aicommit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

aicommit

πŸš€ AI writes your git commit messages. You ship code.

PyPI Python License Tests

Stop staring at your terminal wondering what commit message to write. aicommit reads your staged changes, understands your code, and generates the perfect commit message β€” in any style you want.

✨ Features

  • 🧠 AI-Powered β€” Uses DeepSeek, OpenAI, Anthropic, Ollama, or any compatible API
  • 🎨 4 Commit Styles β€” Conventional Commits, Gitmoji, Simple, Detailed
  • 🎯 Smart Context β€” Auto-detects scope, branch type, breaking changes, monorepo packages
  • πŸ” Branch-Aware β€” Infers commit type from branch name (feat/xxx, fix/xxx)
  • πŸ’₯ Breaking Change Detection β€” Flags breaking changes with !
  • πŸ“¦ Monorepo Support β€” Detects package from directory structure
  • 🌐 Multi-Provider β€” DeepSeek, OpenAI, Anthropic, Ollama, custom endpoints
  • πŸ”Ž Code Review β€” AI code review of staged changes
  • πŸ“‹ PR Description β€” Generate pull request descriptions from branch diffs
  • πŸ“¦ Squash Messages β€” Generate consolidated messages from commits
  • πŸ“ Changelog Generation β€” Auto-generate changelog entries
  • βš™οΈ Config Management β€” Set/get config via CLI (--set, --get)
  • 🚫 .aicommitignore β€” Per-project file/diff ignore patterns
  • βœ… Conventional Validation β€” Validate and auto-fix conventional commits
  • πŸ”„ AI Retry β€” Exponential backoff on API failures
  • πŸ”Œ Provider Override β€” Switch AI provider at runtime (--provider)
  • πŸ’Ύ Save Output β€” Save generated messages to file (--output/-o)
  • πŸ“Š Enhanced Stats β€” Per-repo, per-model breakdown with date range
  • πŸ” Log Filtering β€” Filter history by repo or style (--log-repo, --log-style)
  • πŸ“‹ Message Templates β€” Save/apply named message format templates (--msg-template)
  • ✏️ Editor Command β€” Specify custom editor via --editor-cmd (e.g. --editor-cmd "code --wait")
  • πŸ”€ Shell Completions β€” bash, zsh, fish, PowerShell
  • πŸͺ Git Hook β€” Install as prepare-commit-msg hook
  • πŸ“‹ Clipboard β€” Auto-copy with --copy
  • 🌍 CI/CD Ready β€” GitHub Action included, AICOMMIT_* env vars
  • ✏️ Edit Mode β€” Edit message in $EDITOR before commit
  • ⚑ Auto-Stage β€” --stage to auto-add files
  • πŸ–₯️ Beautiful CLI β€” Rich output with token stats and progress

πŸ“¦ Installation

pip install aicommit

Or with pipx (recommended for CLI tools):

pipx install aicommit

πŸš€ Quick Start

# 1. Setup (one-time, 2 steps)
aicommit --init

# 2. Stage + generate + commit in one go
aicommit --stage -y

# Or step-by-step
git add .
aicommit

That's it! The AI analyzes your diff and generates a commit message. Review and confirm, or use -y to skip confirmation.

🎨 Commit Styles

Style Example Best For
conventional (default) feat(auth): add OAuth2 login flow Teams, CI/CD, changelogs
emoji ✨ Add OAuth2 login flow Personal projects, fun repos
simple Add OAuth2 login flow Quick commits
detailed Multi-line with bullet points Complex changes
aicommit -s emoji      # Use emoji style
aicommit -s detailed   # Detailed with bullet points
aicommit -s simple     # Short and sweet

🧠 Smart Context Analysis

aicommit doesn't just read your diff β€” it understands the context:

  • Scope Detection: src/auth/login.ts + src/auth/logout.ts β†’ scope: auth
  • Branch Inference: Branch feat/oauth-login β†’ type: feat
  • Breaking Changes: Detects deprecated APIs, signature changes β†’ adds ! flag
  • Style Matching: Learns from your last 5 commit messages
  • File Context: Understands which files changed and why it matters
$ aicommit
Staged: 3 file(s) β†’ scope: auth β†’ branch suggests: feat ⚠ BREAKING CHANGE DETECTED
Repo: aicommit | Branch: feat/oauth-login

β”Œβ”€ Generated Message (πŸ“ Conventional) ──┐
β”‚ feat(auth)!: add OAuth2 login flow     β”‚
β”‚                                        β”‚
β”‚ BREAKING CHANGE: removed legacy token  β”‚
β”‚ endpoint in favor of OAuth2            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Model: deepseek-chat | Tokens: 420β†’68 | Time: 820ms

Commit with this message? [y/N]:

πŸ“– Usage

# Quick setup (configure git + AI provider)
aicommit --init

# Stage, generate, and commit in one command
aicommit --stage -y

# Basic usage
aicommit                    # Generate and confirm

# Skip confirmation
aicommit -y

# Preview without committing
aicommit --dry-run

# Provide additional context
aicommit -m "fixing race condition in websocket handler"

# Use a specific style
aicommit -s conventional

# Edit generated message before committing
aicommit -e

# Copy generated message to clipboard
aicommit --copy

# Override token limit
aicommit --max-tokens 1000

# Install as git hook (auto-suggests on every commit)
aicommit --install-hook

# Remove the git hook
aicommit --uninstall-hook

# Reconfigure
aicommit --config

βš™οΈ Configuration Management

# Show full configuration
aicommit --config

# Get a specific value
aicommit --get api.model

# Set a value
aicommit --set api.model=gpt-4

# Reset to defaults
aicommit --reset-config

🚫 .aicommitignore

Create .aicommitignore in your repo root to exclude files from AI analysis:

# .aicommitignore
*.lock
*.log
dist/*
secrets.env
generated/*

Patterns use the same glob syntax as .gitignore and are merged with built-in noise filtering.

πŸ“‹ Message Templates

Save named templates to format commit messages your way:

# Save a template
   aicommit --msg-template-save feat_only="{type}: {description}"
   aicommit --msg-template-save emoji_header="{emoji} {type}({scope}): {description}"

# List saved templates
   aicommit --msg-template-list

# Apply a template
   aicommit --msg-template feat_only

# Delete a template
   aicommit --msg-template-delete feat_only

Template variables available: {type}, {scope}, {description}, {body}, {emoji}, {breaking}, {branch}.

πŸ”Ž Code Review

# Review staged changes before committing
aicommit --review

# Review with severity filter
aicommit --review --severity high

# Focus on specific area
aicommit --review -m "SQL injection risks"

πŸ“‹ PR Description

# Generate PR description from branch diff
aicommit --pr

# Specify base branch
aicommit --pr --pr-base develop

# Add context
aicommit --pr -m "async refactor, focus on error handling"

πŸ“¦ Squash & Changelog

# Generate squash message from last 5 commits
aicommit --squash 5

# Generate changelog entry
aicommit --changelog

# With version tag
aicommit --changelog --version-tag v1.3.0

βœ… Conventional Validation

# Validate conventional format
aicommit --validate

# Auto-fix format if needed
aicommit --auto-fix

πŸ”€ Shell Completions

# Generate for your shell
aicommit --completion bash > ~/.aicommit-completion.bash
aicommit --completion zsh > ~/.aicommit-completion.zsh
aicommit --completion fish > ~/.config/fish/completions/aicommit.fish
aicommit --completion powershell

🌍 CI/CD & GitHub Actions

πŸ”Œ Runtime Provider Override

Temporarily switch AI providers without changing your config:

# Use OpenAI instead of your default DeepSeek
aicommit --provider openai

# Use a local model
aicommit --provider ollama

# Anthropic Claude
aicommit --provider anthropic

🌍 CI/CD & GitHub Actions

All config can be overridden via environment variables:

export AICOMMIT_API_KEY="sk-xxx"
export AICOMMIT_MODEL="gpt-4o"
export AICOMMIT_STYLE="conventional"
export AICOMMIT_PROVIDER="openai"
export AICOMMIT_TEMPERATURE="0.3"

GitHub Action available β€” see action.yml:

- uses: Yangge521/aicommit@master
  with:
    api_key: ${{ secrets.AICOMMIT_API_KEY }}
    style: conventional
    stage: true

πŸͺ Git Hook Integration

Install aicommit as a prepare-commit-msg hook and get AI suggestions automatically on every git commit:

aicommit --install-hook

Now when you run git commit, the editor will be pre-filled with an AI-generated message. You can edit it or accept it as-is.

git add .
git commit
# β†’ Editor opens with AI suggestion pre-filled!

Remove anytime:

aicommit --uninstall-hook

πŸ”§ Configuration

aicommit stores config at ~/.aicommit/config.toml:

# API settings
endpoint = "https://api.deepseek.com/v1"
key = "sk-your-api-key"
model = "deepseek-chat"

# Commit preferences
style = "conventional"
language = "auto"
max_diff_lines = 200
auto_confirm = false

Supported AI Providers

Provider Free Tier Setup
DeepSeek βœ… 500M tokens Get Key
OpenAI ❌ Pay-as-you-go Get Key
Ollama (local) βœ… Free endpoint="http://localhost:11434/v1"
Groq βœ… Free tier Get Key
Any OpenAI-compatible β€” Set endpoint to your API

Using Local Models (Ollama)

# Start Ollama
ollama pull llama3.2

# Configure aicommit
aicommit --config
# β†’ Choose "Custom"
# β†’ Endpoint: http://localhost:11434/v1
# β†’ Model: llama3.2

πŸ€” Why aicommit?

The Problem: Writing good commit messages is tedious. Most developers either write vague messages ("update", "fix") or spend too long crafting the perfect one.

The Solution: Let AI do it. aicommit understands your code changes and generates messages that are:

  • Accurate β€” Based on actual diff analysis, not guessing
  • Consistent β€” Follows your team's conventions automatically
  • Context-Aware β€” Scope detection, branch inference, breaking change awareness
  • Fast β€” Generated in under a second
  • Customizable β€” Your style, your rules, your model

πŸ§ͺ Development

git clone https://github.com/Ghy/aicommit.git
cd aicommit
pip install -e ".[dev]"
pytest

πŸ“ Changelog

v1.7.0

  • πŸ“‹ Message template system: save/apply named message format templates
    • --msg-template NAME apply saved template
    • --msg-template-save NAME=FORMAT save a template
    • --msg-template-list list all saved templates
    • --msg-template-delete NAME delete a template
    • Template variables: {type}, {scope}, {description}, {body}, {emoji}, {breaking}, {branch}
  • ✏️ --editor-cmd flag to override $EDITOR (e.g. --editor-cmd "code --wait")
  • 70 tests (15 new)

v1.6.0

  • πŸ”Œ --provider runtime override (switch AI provider without changing config)
  • πŸ’Ύ --output/-o save generated messages to file
  • πŸ“Š --stats now shows per-repo and per-model breakdown
  • πŸ” --log-repo/--log-style filter history entries

v1.5.0

  • βš™οΈ --set/--get config management from CLI
  • 🚫 .aicommitignore per-project file/diff ignore patterns
  • πŸ› Fixed deepcopy config pollution, HIDDEN name error, --config dedup, --diff routing

v1.4.0

  • πŸ”„ AI retry with exponential backoff
  • πŸͺ Git hook auto-install (prepare-commit-msg)
  • πŸ“¦ Monorepo package detection
  • πŸ’₯ Breaking change-aware (auto ! prefix)
  • 🧼 --reset-config confirmation prompt
  • πŸ“Š --stats usage statistics
  • 🎯 --scope / --template / --copy flags

v1.3.0

  • πŸ” --review AI code review
  • πŸ“‹ --pr PR description generator
  • πŸ“¦ --squash squash commit message
  • πŸ“ --changelog changelog generator
  • πŸ’Ύ --copy clipboard support

v1.2.0

  • 🎨 4 commit styles: conventional, emoji, simple, detailed
  • 🏷️ Auto scope detection from file paths
  • βš™οΈ .aicommit.toml config support

v1.0.0

  • πŸš€ Initial release with DeepSeek API support

πŸ“ License

MIT Β© Ghy


Built with ❀️ for developers who'd rather write code than commit messages

About

AI writes your git commit messages. DeepSeek, OpenAI, Anthropic, Ollama. 4 styles, templates, review, PR, changelog, monorepo.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages