AI-powered git commit message generator using Claude Agent SDK
Project description
claude-commit 
🤖 AI-powered git commit message generator using Claude Agent SDK and Claude Code CLI
What is this?
claude-commit uses Claude AI to analyze your code changes and write meaningful commit messages. Claude reads your files, understands the context, and generates commit messages following best practices.
Demo
Installation
Prerequisites
- Python 3.10+
- Node.js
- Git
Recommended: pipx (for CLI tools)
pipx is the best way to install Python CLI tools. It creates isolated environments automatically:
# 1. Install pipx
brew install pipx # macOS
# or
pip install --user pipx # Linux/Windows
pipx ensurepath
# 2. Install Claude Code CLI (required)
npm install -g @anthropic-ai/claude-code
# 3. Install claude-commit
pipx install claude-commit
Alternative: pip
If you prefer pip, use one of these methods:
Option 1: User installation (no admin rights needed)
# Install to user directory
pip install --user claude-commit
# Make sure ~/.local/bin is in your PATH
export PATH="$HOME/.local/bin:$PATH"
Option 2: Virtual environment
python3 -m venv ~/.venvs/claude-commit
source ~/.venvs/claude-commit/bin/activate
pip install claude-commit
Authentication
claude-commit supports two ways to authenticate with Claude:
Option 1: Official Claude Code Login (Recommended)
Option 2: Custom API Endpoint (Environment Variables)
For custom Claude API endpoints or proxies, set these environment variables:
# Required: Set custom endpoint and credentials
export ANTHROPIC_BASE_URL="https://your-endpoint.com"
export ANTHROPIC_AUTH_TOKEN="your-auth-token"
# Optional: Specify custom model name
export ANTHROPIC_MODEL="your-model-name"
# Then use claude-commit normally
claude-commit --commit
Add these to your ~/.zshrc or ~/.bashrc to persist across sessions.
Usage
Basic Commands
# Generate commit message (default: staged changes only)
claude-commit
# Auto-commit with generated message
claude-commit --commit
# Include all changes (staged + unstaged)
claude-commit --all
# Copy message to clipboard
claude-commit --copy
Common Options
| Option | Description |
|---|---|
-a, --all |
Include unstaged changes |
-c, --commit |
Auto-commit with generated message |
--copy |
Copy message to clipboard |
--preview |
Preview message only |
-v, --verbose |
Show detailed analysis |
-p, --path PATH |
Specify repository path |
--max-diff-lines N |
Limit diff lines (default: 500) |
Aliases
Create shortcuts for common commands:
Install Shell Aliases
# Install to your shell config
claude-commit alias install
# Activate in current terminal. Very important!
source ~/.zshrc # zsh
source ~/.bashrc # bash
Default Aliases
| Alias | Command | Description |
|---|---|---|
ccc |
claude-commit --commit |
Quick commit |
ccp |
claude-commit --preview |
Preview message |
cca |
claude-commit --all |
Include all changes |
ccac |
claude-commit --all --commit |
Commit all changes |
ccopy |
claude-commit --copy |
Copy to clipboard |
After installation, just use:
git add .
ccc # analyzes and commits
Custom Aliases
# Create your own aliases
claude-commit alias set quick --all --commit
claude-commit alias list
claude-commit alias unset quick
How It Works
Claude autonomously analyzes your changes:
- Reads your modified files to understand context
- Searches the codebase for related code
- Understands the intent and impact of changes
- Generates a clear commit message following conventions
Example:
feat: add JWT authentication
Implement secure authentication system with token refresh.
Includes login, logout, and session management.
Examples
Typical Workflow
# Make changes
git add .
# Preview message
claude-commit --preview
# Commit if satisfied
claude-commit --commit
With Aliases
# Make changes
git add .
# Quick commit
ccc
Large Changes
# Limit analysis for faster results
claude-commit --max-diff-lines 200 --commit
Configuration
Configuration files:
- Aliases:
~/.claude-commit/config.json - Shell integration:
~/.zshrc,~/.bashrc, or$PROFILE
Platform Support
| Platform | Status | Shells |
|---|---|---|
| macOS | ✅ | zsh, bash, fish |
| Linux | ✅ | bash, zsh, fish |
| Windows | ✅ | PowerShell, Git Bash |
Windows PowerShell first-time setup:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Troubleshooting
Fatal error in message reader: Command failed with exit code 1 (exit code: 1)
Fatal error in message reader: Command failed with exit code 1 (exit code: 1)
Error output: Check stderr output for details
Traceback (most recent call last):
Solution: This error means you haven't authenticated with Claude. Choose one method:
Method A: Official Claude Code login (recommended)
claude
Method B: Set custom API endpoint
export ANTHROPIC_BASE_URL="https://your-endpoint.com/api/v1"
export ANTHROPIC_AUTH_TOKEN="your-auth-token"
# model name (optional)
export ANTHROPIC_MODEL="your-model-name"
# Add to ~/.zshrc or ~/.bashrc to persist
echo 'export ANTHROPIC_BASE_URL="https://your-endpoint.com/api/v1"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="your-auth-token"' >> ~/.zshrc
"externally-managed-environment" error (macOS/Linux)
If you see this error when using pip install:
error: externally-managed-environment
Solution: Use pipx (recommended for CLI tools):
brew install pipx
pipx install claude-commit
Or use pip install --user:
pip install --user claude-commit
Why this happens: Modern Python installations (Python 3.11+) protect the system Python to prevent conflicts. This is not a bug in claude-commit.
Claude Code not found
npm install -g @anthropic-ai/claude-code
No changes detected
git add . # stage changes
# or
claude-commit --all # include unstaged
Analysis too slow
claude-commit --max-diff-lines 200
Command not found after installation
If claude-commit is not found after installation:
With pipx:
pipx ensurepath
# Restart your terminal
With pip --user:
# Add to ~/.zshrc or ~/.bashrc
export PATH="$HOME/.local/bin:$PATH"
source ~/.zshrc # or ~/.bashrc
Aliases not working
claude-commit alias install
source ~/.zshrc # or ~/.bashrc
Development
# Clone and setup
git clone https://github.com/JohannLai/claude-commit.git
cd claude-commit
python -m venv venv
source venv/bin/activate
pip install -e ".[dev]"
# Run tests
pytest tests/
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a Pull Request
License
MIT License - see LICENSE file
Links
Made with ❤️ by Johann Lai
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_commit-0.7.0.tar.gz.
File metadata
- Download URL: claude_commit-0.7.0.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f59e7c50c7a5837252da6bb96cb5507b3c52e6f36478e4fff2df4bf9d58a138
|
|
| MD5 |
a53a85810089ab49099994ff51c0bef5
|
|
| BLAKE2b-256 |
a553608603dba9b69780723ceeea0751ba69e313b68290ca109678d66b4e99a1
|
Provenance
The following attestation bundles were made for claude_commit-0.7.0.tar.gz:
Publisher:
auto-release.yml on JohannLai/claude-commit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_commit-0.7.0.tar.gz -
Subject digest:
4f59e7c50c7a5837252da6bb96cb5507b3c52e6f36478e4fff2df4bf9d58a138 - Sigstore transparency entry: 1101333680
- Sigstore integration time:
-
Permalink:
JohannLai/claude-commit@c77048e724fc5b6842b17e4bef6c91e98aa2324c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/JohannLai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
auto-release.yml@c77048e724fc5b6842b17e4bef6c91e98aa2324c -
Trigger Event:
push
-
Statement type:
File details
Details for the file claude_commit-0.7.0-py3-none-any.whl.
File metadata
- Download URL: claude_commit-0.7.0-py3-none-any.whl
- Upload date:
- Size: 18.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58df76f6379276187b8d3f6fc24aa7fef1573c2c2dc8e4b8ab3a470935605cdb
|
|
| MD5 |
e425bf1795486daf140177a9b8469e59
|
|
| BLAKE2b-256 |
9fb33c83a675ee977ecee6c04ef84488f5dea3afe6c67292ef990de441f07795
|
Provenance
The following attestation bundles were made for claude_commit-0.7.0-py3-none-any.whl:
Publisher:
auto-release.yml on JohannLai/claude-commit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_commit-0.7.0-py3-none-any.whl -
Subject digest:
58df76f6379276187b8d3f6fc24aa7fef1573c2c2dc8e4b8ab3a470935605cdb - Sigstore transparency entry: 1101333737
- Sigstore integration time:
-
Permalink:
JohannLai/claude-commit@c77048e724fc5b6842b17e4bef6c91e98aa2324c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/JohannLai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
auto-release.yml@c77048e724fc5b6842b17e4bef6c91e98aa2324c -
Trigger Event:
push
-
Statement type: