I commit often, but writing proper messages slows me down or gets neglected..
git-msg-unfck
rewrites your recent Git commit messages by analyzing the diffs and generating clean, descriptive messages using AI models like Claude 3.5/3.7, GPT-4, DeepSeek, or your own local LLM.
# Clone the repository
git clone https://github.com/yourusername/git-msg-unfck.git
cd git-msg-unfck
# Install Poetry if you don't have it
curl -sSL https://install.python-poetry.org | python3 -
# Build the package
poetry build
# Install the built package
pip install dist/git_msg_unfck-0.1.0.tar.gz
After installation, the unfck
command will be available in your terminal.
# This method is not yet available
pip install git-msg-unfck
- π Analyzes
git diff
for each of your last commits - π€ Asks an LLM to explain the changes and rewrite the commit message
- β Optionally asks you why you made the change
- β Lets you approve suggestions interactively
- π οΈ Can automatically rewrite messages using
git rebase
- π Fix messages for N last commits or the entire branch
- π¦ Supports GPT-4, Claude, DeepSeek, local LLMs (via OpenRouter)
- π§βπ» Interactive mode (dry-run with confirmation)
- π€ Fully automated mode (
--just-fix-it
) - πΏ Multi-branch and CI/CD support
- π§© Configurable via
.unfckrc
with secure token management - π Secure API token storage with command-line management
changes in git working directory wont let program finish updating git tree, tokens are lost [critical]
# Process all commits in the current branch
unfck .
changes in git working directory wont let program finish updating git tree, tokens are lost [critical]
unfck --just-fix-it
changes in git working directory wont let program finish updating git tree, tokens are lost [critical]
unfck last 2
changes in git working directory wont let program finish updating git tree, tokens are lost [critical]
unfck first 5
changes in git working directory wont let program finish updating git tree, tokens are lost [critical]
unfck last 1 --model gpt-4
OpenRouter supports various models including:
gpt-4
gpt-3.5-turbo
claude-3-opus
claude-3-sonnet
claude-3-haiku
unfck --all-branches
unfck --only-main
# Provide a global reason for all commits
unfck last 3 --why "Fixing authentication bugs"
# Interactively prompt for a reason (once for multiple commits)
unfck last 3 --ask-why
Add a config file at ~/.unfckrc:
[provider]
engine = gpt-4
api_key = YOUR_OPENROUTER_KEY
[defaults]
auto_apply = false
prompt_user_for_why = true
See the .unfckrc.example
file for all available options.
You can manage your configuration using the following commands:
# Set your OpenRouter API token
unfck config set-token YOUR_API_KEY
# View your current token (masked for security)
unfck config get-token
# Set any configuration value
unfck config set provider engine claude-3-opus
unfck config set defaults auto_apply true
unfck config set behavior remove_quotes false
# Get a specific configuration value
unfck config get provider engine
# List all configuration values
unfck config list
You can also override settings via CLI flags for individual commands.
- Finds commits via git rev-list
- For each commit:
- Gets git diff and current message
- Optionally asks you "Why did you make this change?"
- Sends everything to the AI model
- Receives and displays improved commit message
- If accepted:
- Uses git rebase -i or git commit --amend to replace message
All accessed via OpenRouter:
- GPT-4
- Claude 3.5 / 3.7
- DeepSeek
- Local models (if routed via OpenRouter or API endpoint)
Run automatically in pipelines:
- name: Clone repository
uses: actions/checkout@v3
with:
repository: vic-cieslak/git-msg-unfck
path: git-msg-unfck
- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python3 -
- name: Build and install git-msg-unfck
run: |
cd git-msg-unfck
poetry build
pip install dist/git_msg_unfck-0.1.0.tar.gz
- name: Fix last 5 commit messages
run: unfck last 5 --just-fix-it --model claude-3.5
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
Note: Docker support has limitations. The tool will only operate on the Git repository that's mounted to the container. You cannot specify an external Git repository path like
/home/user/Git_repo
as the tool is designed to work only with the current working directory mounted at/git
in the container.
To quickly test the tool on your current repository, use the provided script:
# First, set your API token (if you haven't already)
unfck config set-token YOUR_OPENROUTER_API_KEY
# Make the script executable if needed
chmod +x test-current-repo.sh
# Run the test script
./test-current-repo.sh
This will run the tool on the last commit in your current repository and show you the before and after commit messages.
The project includes integration tests that create a temporary Git repository, make commits with poor messages, and test the ability to improve them using the real OpenRouter API.
To run the integration tests:
# First, set your API token (if you haven't already)
unfck config set-token YOUR_OPENROUTER_API_KEY
# Run the test
unfck-test
# Or you can still use environment variables if preferred
export OPENROUTER_API_KEY=your_openrouter_api_key
unfck-test
Note: These tests make real API calls to OpenRouter using Claude 3.7, which will incur costs.
- Pre-commit hook integration
- PR title/description generation
- Model fallback logic
- Local LLM CLI support
- Message tone: concise / formal / playful
This tool modifies Git history using git rebase. Use it on safe branches, not shared ones, unless you know what you're doing.
MIT