life is too short for a diary




Monkey Patching Claude commit for AWS Bedrock

Tags: claude code ai monkey-patching

Author
Written by: Tushar Sharma
Featured image for Monkey Patching Claude commit for AWS Bedrock

When AI is writing code, there's no reason not to have AI write the commit message too. I tried the handy tool claude-commit, but ran into two issues when using Claude via AWS Bedrock on Python 3.14: a compatibility error with Rich's Console.print() and missing Bedrock credentials.

Initial Installation

First, install claude-commit using pipx:

pipx install claude-commit

Problems Encountered

1. TypeError with Console.print()

When running claude-commit you may see this error:

TypeError: Console.print() got an unexpected keyword argument 'file'

Root cause: Python 3.14 compatibility issue with the rich library's Console.print() method. The file parameter is no longer supported in newer versions.

2. Authentication Issues

Even after fixing the TypeError, authentication fails because claude-commit doesn't automatically pick up AWS Bedrock credentials from Claude Code's configuration file (~/.claude/settings.json).

The Solution: Creating a Patched Wrapper

Create a a monkey-patched wrapper script that fixes both issues.

Step 1: Create the Wrapper Script

Create a file at ~/.local/bin/claude-commit-patch with the following content. The script does two things: load environment variables from your Claude Code settings and monkey-patch rich.Console.print to drop the unsupported file argument.

Shebang notes

Find the pipx venv python with:

ls -la ~/.local/pipx/venvs/claude-commit/bin/python

Example shebang options:

Absolute (reliable):

#!/Users/youruser/.local/pipx/venvs/claude-commit/bin/python

Portable (uses PATH):

#!/usr/bin/env python3
ls -la ~/.local/pipx/venvs/claude-commit/bin/python

Step 2: Make It Executable

chmod +x ~/.local/bin/claude-commit-patch

Step 3: Update Git Configuration

Add convenient aliases to your ~/.gitconfig (adjust paths for your home):

[alias]
    claude = "!/Users/tushar/.local/bin/claude-commit-patch"
    claude-auto = "!/Users/tushar/.local/bin/claude-commit-patch --commit"
    claude-all = "!/Users/tushar/.local/bin/claude-commit-patch --all"
    claude-copy = "!/Users/tushar/.local/bin/claude-commit-patch --copy"
    cc = "!/Users/tushar/.local/bin/claude-commit-patch --commit"

Note: Update the path to match your home directory.

How It Works

What the wrapper does

Usage

With alias g='git' in your shell (.zshrc or .bashrc):

# Preview commit message
g claude

# Auto-commit with AI-generated message
g cc

# Include all untracked files
g claude-all

# Copy message to clipboard (no commit)
g claude-copy

Or run directly:

claude-commit-patch
claude-commit-patch --commit

Verification

Test that it works:

cd /path/to/your/repo
claude-commit-patch

Expected output (example):

Claude is analyzing your changes...
✨ Analysis complete!

╭─── 📝 Generated Commit Message ───╮
│                                   │
│  your commit message here         │
│                                   │
╰───────────────────────────────────╯

Troubleshooting

Troubleshooting


comments powered by Disqus