Skip to content

Latest commit

 

History

History
228 lines (162 loc) · 4.67 KB

File metadata and controls

228 lines (162 loc) · 4.67 KB

🤖 Smart Commit

AI-powered Git commit message generator

Stop writing boring commit messages. Let AI do it for you.

npm version License: MIT Node.js

FeaturesInstallUsageConfigContributing


✨ Features

  • 🔍 Smart Analysis — Reads your git diff and understands what changed
  • 🤖 Multi-Provider AI — Supports OpenAI, Anthropic, Ollama (local/free!), and Gemini
  • 📝 Multiple Styles — Conventional Commits, Gitmoji, or Simple format
  • 🌍 Multi-Language — Generate messages in any language
  • Interactive CLI — Edit, regenerate, copy, or commit directly
  • 🚀 Zero Config — Works out of the box with sensible defaults
  • 🔧 Git Alias Friendly — Use sc as a short alias

📦 Install

npm install -g smart-commit

Or use without installing:

npx smart-commit

🚀 Quick Start

# 1. Configure your AI provider
sc config

# 2. Stage your changes
git add .

# 3. Generate commit message
sc

That's it! Smart Commit analyzes your staged changes and generates a perfect commit message.

Demo

📖 Usage

Basic Usage

# Generate from staged changes
sc

# Stage all changes and generate
sc --all
# or
sc -a

# Commit directly without confirmation
sc --yes
# or
sc -y

# Only copy message to clipboard
sc --copy

Configuration

# Interactive setup
sc config

# Show current config
sc config --show

# Set AI provider
sc config --provider ollama
sc config --provider openai
sc config --provider anthropic
sc config --provider gemini

# Set commit style
sc config --style conventional   # feat:, fix:, docs:
sc config --style emoji          # ✨, 🐛, 📝
sc config --style simple         # Add, Fix, Update

# Set output language
sc config --language english
sc config --language indonesian
sc config --language spanish

# Set API key
sc config --api-key sk-your-key-here

# Set specific model
sc config --model gpt-4o
sc config --model claude-3-5-sonnet-20241022
sc config --model llama3.2

Git Alias

Add this to your ~/.gitconfig for even faster access:

[alias]
    ai = !sc

Then just use:

git ai
git ai --all
git ai --yes

🤖 Supported Providers

Provider Model Free? Setup
Ollama llama3.2, codellama, etc. ✅ Yes Install Ollama
OpenAI gpt-4o-mini, gpt-4o Get API key
Anthropic Claude 3.5 Sonnet Get API key
Gemini gemini-2.0-flash ✅ Free tier Get API key

Using Ollama (Free & Local)

# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh

# Pull a model
ollama pull llama3.2

# Configure smart-commit
sc config --provider ollama --model llama3.2

⚙️ Configuration

Config is stored in ~/.smart-commit/config.json:

{
  "provider": "openai",
  "model": "gpt-4o-mini",
  "apiKey": "sk-...",
  "language": "english",
  "style": "conventional",
  "autoCommit": false,
  "temperature": 0.3
}

Environment Variables

You can also use environment variables instead of storing API keys:

export OPENAI_API_KEY=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
export GEMINI_API_KEY=...

📝 Commit Styles

Conventional Commits (default)

feat(auth): add OAuth2 login flow
fix(api): handle null response in user endpoint
docs: update installation guide
refactor(utils): simplify date formatting logic

Gitmoji

✨ feat: add dark mode toggle
🐛 fix: resolve memory leak in worker pool
📝 docs: add API reference for v2
♻️ refactor: extract payment logic to service

Simple

Add dark mode toggle to settings page
Fix memory leak in background worker pool
Update API reference documentation
Extract payment processing into separate service

🤝 Contributing

Contributions are welcome! Here's how to get started:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feat/amazing-feature)
  3. Commit your changes (sc --yes)
  4. Push to the branch (git push origin feat/amazing-feature)
  5. Open a Pull Request

📄 License

MIT © Lwuisyy


If this tool helped you, consider giving it a ⭐ on GitHub!