git-reword
v0.0.2
Published
AI-powered Git commit message rewriter
Readme
git-reword
📝 AI-powered Git commit message rewriter.
Features
- 📚 Batch Rewording: Reword multiple commits at once
- 🤖 AI-Powered: Generate professional commit messages using AI
- 🔌 Multi-Provider: Support OpenAI, Anthropic, Google, MiniMax, and more
- 💬 Interactive UI: Review and accept/skip/regenerate suggestions
- 🎯 Flexible Targeting: Support
--last,--since, range, and single commit - ~~☁️ Agent Friendly: First-class integration for AI agents (WIP)~~
Comparison
| Tool | Limitation | | ----------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | | Most AI commit message tools (e.g., aicommits, opencommit) | Only handles the most recent commit | | AI coding assistants (Claude Code, etc.) | Inconvenient for processing batches of commits in conversation | | Manual rebase | Tedious for multiple commits |
Getting Started
Installation
npm i -g git-reword
# or
bun add -g git-rewordQuick Start
# Reword the last commit (default)
git-reword
# Reword the last N commits
git-reword --last 5
# Reword commits from a specific ref
git-reword --since abc1234
# Reword commits in range
git-reword HEAD~3..HEAD
# Reword a specific commit
git-reword abc1234
# Generate commit message for staged changes
git-reword --stagedUsage
Reword Commits
Interactive Mode
Interactive UI displays commits with AI-generated suggestions. For each commit, you can:
- Accept: Use AI-generated message
- Skip: Keep original message
- Regenerate: Request new AI message
- Abort: Cancel entire operation
# Interactive mode (default)
git-reword --last 3
# Skip confirmation - apply all changes automatically
git-reword --yes --last 3AI Commit (Staged Changes)
Generate a commit message for staged changes:
# Stage your changes first
git add .
# Generate and apply commit message
git-reword --staged
# Output:
# Suggested message:
# feat(api): add user authentication middleware
#
# Apply? [y/n]
# y: git commit with suggested message
# n: cancel, no commitOptions
| Option | Description |
| -------------------- | --------------------------------------------- |
| --last <n> | Reword the last N commits |
| --since <ref> | Reword commits from ref's next commit to HEAD |
| --dry-run | Preview without executing rebase |
| --yes, -y | Skip confirmation, apply all changes |
| --skip-check, -k | Skip uncommitted changes check (debugging) |
| --staged | Generate commit message for staged changes |
Configuration
Create ~/.git-rewordrc:
provider=anthropic
model=claude-sonnet-4-20250514
apiKey=your-api-keySupported Providers
| Provider | Default Model |
| ----------- | ------------------ |
| openai | gpt-5-mini |
| anthropic | claude-haiku-4-5 |
| google | gemini-2.5-flash |
Provider Configuration Examples
OpenAI
provider=openai
model=gpt-5-mini
apiKey=sk-...Anthropic
provider=anthropic
model=claude-haiku-4-5
apiKey=sk-ant-...provider=google
model=gemini-2.5-flash
apiKey=AIza...MiniMax
provider=anthropic
model=MiniMax-M2.5
baseUrl=https://api.minimax.io/anthropic/v1
apiKey=sk-...MiniMax (CN)
provider=anthropic
model=MiniMax-M2.5
baseUrl=https://api.minimaxi.com/anthropic/v1
apiKey=sk-...Advanced
GPG Signing
When rewording GPG-signed commits:
- Signed commits remain signed:
git commit --amendwithout-Spreserves the signature - Unsigned commits remain unsigned: No new signature is added
If you use GPG-signed commits and git-reword prompts for passphrase during rebase:
Extend GPG agent cache lifetime:
echo "default-cache-ttl 86400" >> ~/.gnupg/gpg-agent.conf echo "max-cache-ttl 604800" >> ~/.gnupg/gpg-agent.conf gpgconf --reload gpg-agentRefresh cache before running git-reword:
git commit --amend --no-edit -S
Verify signatures after reword:
git log --show-signature -5Agent Skill Integration (WIP)
The CLI outputs structured text for easy parsing by Skills:
// 1. Preview mode - show what would change
const preview = exec("git-reword --dry-run --last 5");
// 2. Execute mode - apply changes
const result = exec("git-reword --yes --last 5");
// Output:
// ✓ Commit abc123 rewrote
// ✓ Commit def456 rewrote
// Done. 2/2 commits rewroteBranch Constraint
All reword operations target commits on the current branch only. This tool uses git rebase internally, which replays commits onto the current branch.
# ✅ Correct: operate on current branch
git checkout feature-a
git-reword --last 3
# ✅ Correct: checkout target branch first
git checkout feature-b
git-reword --since abc1234Pre-flight Checks
Before rewording commits (not --staged):
- No uncommitted changes: Ensures safe rebase operation
- Fast-forward possible: Verifies commits haven't been rebased or amended
Use --skip-check to bypass these checks (for debugging).
Reference
Exit Codes
| Code | Meaning |
| ---- | ------------------------------------------------- |
| 0 | Success: all commits rewrote |
| 1 | Error: invalid arguments, config error, git error |
| 2 | User interrupt: aborted with q or Ctrl+C |
| 3 | Partial: some commits rewrote, some skipped |
Apache-2.0 © yelo, 2026 - present
