Commit Companion
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
TYPEandTONE - 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 .
Requirements
- Python 3.8 or later
- An OpenAI API key (required for GPT functionality)
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.
Contributing
Contributions, suggestions, and issue reports are welcome! To get started:
- Fork the repository
- Create your feature branch (
git checkout -b feature/my-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature/my-feature) - Open a pull request
Links
Metadata
Release files for commit-companion 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| commit_companion-0.1.2.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| commit_companion-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / commit_companion-0.1.2.tar.gz
| Download URL | commit_companion-0.1.2.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dd14909e8dd9682633dfd16574a30ff342188f3966fe4885a71ec7f242ded745
|
|
BLAKE2b-256 checksum How to use checksums |
4a2490c8e1fae49ed198aa032ed48493c11d1c9758527ecc099ead38e7079caf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|
Release files / commit_companion-0.1.2-py3-none-any.whl
| Download URL | commit_companion-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd192da260e2eb0afe491355dded6d13193989f8a7b06179404c3bac173d79de
|
|
BLAKE2b-256 checksum How to use checksums |
baedf33b8c8599b5ab6fbbceea31fe5adf4d1e9e61905a309ac25b46a2f25b5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.3
|