Skip to main content

Smarter Git commit messages using GPT.

Project description

Commit Companion

PyPI version

AI-powered Git commit assistant that summarizes staged changes using GPT.
Save time, stay in flow, and write better commit messages — automatically.


Features

  • Uses GPT to summarize your staged diffs into clear commit messages
  • Supports Conventional Commits
  • Tone customization (neutral, casual, formal, funny, etc.)
  • Git hook integration via prepare-commit-msg
  • Supports environment variables for default TYPE and TONE
  • Optional auto mode to skip confirmation (for non-interactive use)

Quick Start

1. Install via pip (recommended):

pip install commit-companion

Or, to install from source:

git clone https://github.com/nelson-zack/commit-companion.git
cd commit-companion
pip install .

2. Add your OpenAI API key:

Commit Companion requires access to the OpenAI API. You can provide your key in one of two ways:

Option 1: .env file (for local use)

OPENAI_API_KEY=sk-...

Option 2: Environment variable (for global use)

Add to your shell config (~/.zshrc, ~/.bashrc, etc):

export OPENAI_API_KEY="sk-..."

Then run:

source ~/.zshrc   # or ~/.bashrc

3. Install CLI tool locally:

pip install --editable .

Usage

CLI (manual):

commit-companion suggest --tone casual --type feat

Will output something like:

feat: add basic functionality to README.md

Example usage:

git add <file>
commit-companion suggest --tone casual --type feat
git commit -m "your message here"
git push

Git Hook (auto):

Install the Git hook with:

commit-companion install-hook

This creates a .git/hooks/prepare-commit-msg script that auto-generates commit messages using GPT. By default, it uses --tone neutral and --type feat.

Once installed, your flow becomes:

git add <file>      # Stage your changes
git commit          # Commit Companion will auto-suggest the message
git push            # Push to remote

Customize per commit:

Override tone or type like this:

TYPE=fix git commit
TONE=funny git commit
TYPE=fix TONE=funny git commit

Uninstall the hook:

commit-companion uninstall-hook

Optional: Global Installation

To use commit-companion from any repo without activating a virtual environment:

1. Install globally:

pip install .

2. Add your OpenAI key to your shell config (~/.zshrc or ~/.bashrc):

export OPENAI_API_KEY="sk-..."

3. Ensure your Python bin path is on your system PATH:

export PATH="$PATH:/Library/Frameworks/Python.framework/Versions/3.12/bin"

4. Reload your shell:

source ~/.zshrc   # or ~/.bashrc

5. Use it anywhere:

commit-companion install-hook

Roadmap Ideas

  • Config file support (.commitcompanion.json)
  • VS Code extension
  • Web version / hosted API
  • ✅ PyPI distribution (available via pip install commit-companion)

Why Use This?

Writing commit messages breaks flow. Commit Companion helps you:

  • Stay focused on your code
  • Standardize commits with no effort
  • Impress your teammates with clear, consistent commit messages

License

MIT License.

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

commit_companion-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

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

commit_companion-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file commit_companion-0.1.0.tar.gz.

File metadata

  • Download URL: commit_companion-0.1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for commit_companion-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e4e7e20b6de678fe3d90a15e222d3e99385b0b7cc44a067b85afad95c5e3c362
MD5 2edf2c37b9ed4db3587bb78b33a478a4
BLAKE2b-256 f4a5e4c3adca11bf919237ce817603fe3d7ec8553c2e20dfc18dee00c6beb0c1

See more details on using hashes here.

File details

Details for the file commit_companion-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for commit_companion-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9227c725613ebd26fe42a87a6ce2745853b39d3a1f723e29a69c680a09a2b9f6
MD5 4006a25e90f21dc29c349f260995e0a2
BLAKE2b-256 6573b07e9c3592d1207026938729b29a946fbed60592537d875dd01470156a52

See more details on using hashes here.

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