0.0
The project is in a healthy, maintained state
AI-powered commit message generator that analyzes your git diff and creates meaningful, conventional commit messages using Claude AI. No more commit message writer's block!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 2.0
~> 0.3
~> 1.0
 Project Readme

AI Commit 🤖

Generate intelligent, conventional commit messages using Claude AI. No more struggling with commit message writer's block!

Features

  • AI-Powered: Uses Claude AI to analyze your git diff and generate meaningful commit messages
  • 📝 Conventional Commits: Follows conventional commit format (feat, fix, docs, etc.)
  • 🔒 Secure: API keys stored securely with proper file permissions
  • 🚀 Fast: Quick generation with Claude 3 Haiku
  • 🎯 Smart: Contextual analysis of your actual code changes
  • 💎 Ruby Gem: Simple installation and usage

Installation

Install the gem:

gem install smart-commit

Or add to your Gemfile:

gem 'smart-commit'

Setup

First, configure your Anthropic API key:

smart-commit setup

You'll be prompted to enter your API key. Get one at Anthropic Console.

Usage

Basic Usage

  1. Stage your changes:

    git add .
  2. Generate a commit message:

    smart-commit generate
  3. The tool will analyze your diff and suggest a commit message:

    ✨ Generated commit message:
    feat: add user authentication with JWT tokens
    
    To commit with this message, run:
    git commit -m "feat: add user authentication with JWT tokens"
    

Commands

  • smart-commit setup - Configure your API key
  • smart-commit generate - Generate commit message from staged changes
  • smart-commit config - Show current configuration
  • smart-commit help - Show help information

Examples

The AI generates contextual commit messages based on your actual changes:

# Adding a new feature
git add lib/user_auth.rb
smart-commit generate
# → "feat: add JWT-based user authentication system"

# Fixing a bug
git add lib/payment_processor.rb
smart-commit generate  
# → "fix: handle null payment amounts in processor"

# Documentation updates
git add README.md
smart-commit generate
# → "docs: update installation instructions"

# Refactoring code
git add lib/user_model.rb
smart-commit generate
# → "refactor: extract user validation into separate method"

Configuration

API Key Storage

  • Config stored in: ~/.smart-commit/config.yml
  • File permissions: 600 (secure)
  • Environment variable: ANTHROPIC_API_KEY (fallback)

Customizing the Prompt

The commit message generation prompt can be customized by editing: lib/ai/commit/claude_client.rb in the build_prompt method.

Requirements

  • Ruby 3.1.0+
  • Git repository
  • Anthropic API key
  • Staged changes in git

Development

After checking out the repo:

bin/setup                    # Install dependencies
rake test                   # Run tests
bin/console                 # Interactive prompt
bundle exec exe/smart-commit   # Run locally

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bmirzamani/smart-commit.

License

The gem is available as open source under the terms of the MIT License.

Changelog

See CHANGELOG.md for version history.


Made with ❤️ by Behrang Mirzamani