Tags: claude code ai monkey-patching
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.
First, install claude-commit using pipx:
pipx install claude-commit
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.
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).
Create a a monkey-patched wrapper script that fixes both issues.
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
pipx virtualenv Python, use the absolute path to that Python as the shebang (example below). This is the most reliable way to ensure the wrapper runs with the same environment that installed claude-commit.#!/usr/bin/env python3 — it will pick the first python3 on PATH. Make sure that python3 is the one that has access to claude-commit and its dependencies.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
chmod +x ~/.local/bin/claude-commit-patch
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.
What the wrapper does
~/.claude/settings.json and sets them in os.environ so claude-commit can authenticate with Bedrock.rich.Console.print() to remove the unsupported file kwarg that causes a TypeError on Python 3.14.claude-commit from the environment the script is executed in.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
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 │
│ │
╰───────────────────────────────────╯
~/.local/bin (or wherever you put it) is in your PATH:
which claude-commit-patch
head -1 ~/.local/bin/claude-commit-patch
~/.claude/settings.json includes an env object, for example:
{
"env": {
"CLAUDE_CODE_USE_BEDROCK": "1",
"AWS_REGION": "us-east-1",
"AWS_PROFILE": "default"
}
}