@syedfahadandrabi/commitcraft
v2.0.1
Published
Auto-generate commit messages from git diffs using AI
Downloads
420
Maintainers
Readme
commitcraft
Auto-generate meaningful git commit messages from your staged diff using AI (Claude or Gemini).
npx commitcraft initInstall
npm install -g @syedfahadandrabi/commitcraftOr use without installing:
npx commitcraft genSetup
Configure your API keys:
commitcraft setupOr set them manually:
# Claude (Anthropic) — recommended, best quality
commitcraft config set ANTHROPIC_API_KEY "sk-ant-..."
# Gemini (Google) — free tier available
commitcraft config set GEMINI_API_KEY "AIza..."Keys are stored securely in ~/.config/commitcraft/keys.json. Environment variables take precedence over stored keys.
Usage
Install the git hook (recommended)
Works automatically on every git commit:
cd your-project
commitcraft initNow just stage your changes and commit as usual:
git add .
git commit # ← message is auto-generatedGenerate and commit in one step
Bypasses the editor entirely:
git add .
commitcraft commitDry run (preview without committing)
commitcraft genWith a hint
commitcraft gen --hint "fixing the broken login redirect"With a commit body (verbose)
commitcraft gen --verboseForce a provider
commitcraft gen --provider claude
commitcraft gen --provider geminiManage API keys
commitcraft config list # Show stored keys (masked)
commitcraft config delete GEMINI_API_KEY # Remove a keyUninstall hook
commitcraft uninstallExample output
feat(auth): add JWT refresh token rotation
- Replace single-use tokens with rotating refresh token strategy
- Store token family in Redis to detect reuse attacks
- Invalidate entire family on suspicious reuse detectionCommands
| Command | Description |
|----------------------|--------------------------------------------------|
| commitcraft init | Install git hook in current repo |
| commitcraft uninstall | Remove git hook from current repo |
| commitcraft commit | Generate message and commit directly |
| commitcraft gen | Generate a commit message (dry run) |
| commitcraft setup | Interactive API key setup |
| commitcraft config | Manage stored API keys (set/list/delete) |
Options for gen and commit
| Flag | Description |
|--------------------|--------------------------------------------------|
| --hint <text> | Give the AI a hint about what you changed |
| --verbose | Include a commit body with bullet points |
| --provider <name>| Force provider: claude or gemini |
How it works
commitcraft initinstalls aprepare-commit-msggit hook in your repo- On every
git commit, git runs the hook automatically - The hook calls
commitcraft gen --write, which:- Runs
git diff --cachedto get your staged changes - Sends the diff to AI (Claude Haiku or Gemini Flash)
- Writes the generated message to your commit file
- Runs
- Your editor opens pre-filled — edit or accept and save
Provider auto-detection
If no --provider flag is given, commitcraft picks the first available:
ANTHROPIC_API_KEY→ ClaudeGEMINI_API_KEY→ Gemini
Development
npm install
npm run build # Compile TypeScript
npm test # Run testsLicense
MIT
