Skip to content

Latest commit

 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

commitcraft

Auto-generate meaningful git commit messages from your staged diff using AI (Claude or Gemini).

npx commitcraft init

Install

npm install -g @syedfahadandrabi/commitcraft

Or use without installing:

npx commitcraft gen

Setup

Configure your API keys:

commitcraft setup

Or 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 init

Now just stage your changes and commit as usual:

git add .
git commit   # ← message is auto-generated

Generate and commit in one step

Bypasses the editor entirely:

git add .
commitcraft commit

Dry run (preview without committing)

commitcraft gen

With a hint

commitcraft gen --hint "fixing the broken login redirect"

With a commit body (verbose)

commitcraft gen --verbose

Force a provider

commitcraft gen --provider claude
commitcraft gen --provider gemini

Manage API keys

commitcraft config list              # Show stored keys (masked)
commitcraft config delete GEMINI_API_KEY   # Remove a key

Uninstall hook

commitcraft uninstall

Example 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 detection

Commands

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

  1. commitcraft init installs a prepare-commit-msg git hook in your repo
  2. On every git commit, git runs the hook automatically
  3. The hook calls commitcraft gen --write, which:
    • Runs git diff --cached to get your staged changes
    • Sends the diff to AI (Claude Haiku or Gemini Flash)
    • Writes the generated message to your commit file
  4. Your editor opens pre-filled — edit or accept and save

Provider auto-detection

If no --provider flag is given, commitcraft picks the first available:

  1. ANTHROPIC_API_KEY → Claude
  2. GEMINI_API_KEY → Gemini

Development

npm install
npm run build    # Compile TypeScript
npm test         # Run tests

License

MIT

About

commitcraft — AI-powered Git Commits

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages