DEV Community

Huynh Thanh Phuc
Huynh Thanh Phuc

Posted on

GoCommit: Never Write Another Git Commit Message Again 🤖

We've all been there. You've just spent hours implementing a complex feature or fixing a tricky bug, and then... you stare at the terminal, trying to come up with a meaningful commit message. Should it be "fix stuff" or "update code"? 😅

What if I told you there's a better way? Meet GoCommit - an AI-powered CLI tool that generates meaningful, conventional commit messages automatically by analyzing your staged changes.

The Problem 🤔

Writing good commit messages is hard. It requires:

  • Understanding what changed and why
  • Following consistent formatting conventions
  • Being descriptive but concise
  • Categorizing changes appropriately (feat, fix, docs, etc.)

Most developers either spend too much time crafting the perfect message or resort to generic ones like "update" or "fix". Both approaches hurt code maintainability and team collaboration.

The Solution ✨

GoCommit leverages Google's Gemini AI to analyze your git diff and generate contextually appropriate commit messages that follow the conventional commits specification.

Here's what makes it special:

🎯 Smart Analysis

The tool examines your staged changes and understands the context - whether you're adding a feature, fixing a bug, updating documentation, or refactoring code.

📝 Conventional Commits

All generated messages follow the conventional commits format:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation changes
  • refactor: Code refactoring
  • perf: Performance improvements
  • And more...

🔧 Zero Configuration Hassle

Built-in configuration wizard makes setup a breeze - just run gocommit --config and you're ready to go.

📊 Comprehensive Logging

Every interaction is logged for analysis and prompt improvement, helping the tool get better over time.

Quick Start 🚀

Installation

Linux/macOS:

curl -sSL https://raw.githubusercontent.com/thanhphuchuynh/gocommit/main/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Windows (PowerShell):

Invoke-WebRequest -Uri "https://raw.githubusercontent.com/thanhphuchuynh/gocommit/main/install.ps1" -OutFile "install.ps1"; .\install.ps1
Enter fullscreen mode Exit fullscreen mode

Setup

# Configure your Gemini API key
gocommit --config
Enter fullscreen mode Exit fullscreen mode

Usage

# Stage your changes
git add .

# Generate and commit with AI
gocommit
Enter fullscreen mode Exit fullscreen mode

That's it! GoCommit will analyze your changes and create a meaningful commit message automatically.

Real-World Example 💡

Let's say you've just added user authentication to your web app. Instead of writing:

git commit -m "auth stuff"
Enter fullscreen mode Exit fullscreen mode

GoCommit might generate:

feat(auth): implement user authentication with JWT tokens

- Add login and registration endpoints
- Implement JWT token generation and validation
- Add password hashing with bcrypt
- Create middleware for protected routes
Enter fullscreen mode Exit fullscreen mode

Much better, right? 🎉

Technical Deep Dive 🔧

Architecture

GoCommit is built in Go and follows a clean architecture:

├── main.go              # CLI entry point and orchestration
├── config/              # Configuration management
│   └── config.go       # API key validation and storage
├── logger/              # Request/response logging
│   └── logger.go       # JSON structured logging
└── tools/               # Analysis utilities
    └── analyze_logs.go  # Usage pattern analysis
Enter fullscreen mode Exit fullscreen mode

Key Features

🔐 Secure Configuration

  • API keys are validated (must start with "AIza" and be 39 characters)
  • Stored securely in user's home directory
  • Easy reconfiguration with --config flag

📈 Smart Logging
All interactions are logged in JSON format for analysis:

{
  "timestamp": "2024-01-15T10:30:00Z",
  "git_diff": "...",
  "ai_prompt": "...",
  "ai_response": "...",
  "user_selection": "...",
  "success": true
}
Enter fullscreen mode Exit fullscreen mode

🔍 Built-in Analytics
Run analysis on your usage patterns:

go run tools/analyze_logs.go
Enter fullscreen mode Exit fullscreen mode

Get insights into:

  • Success rates and error patterns
  • Most common commit types
  • Daily activity patterns
  • User choice preferences

Cross-Platform Support

GoCommit supports all major platforms:

  • Linux (x64, ARM64)
  • macOS (Intel, Apple Silicon)
  • Windows (x64)
  • FreeBSD (x64)

Pre-built binaries are available for all platforms, or you can build from source.

Why Choose GoCommit? 🌟

vs. Manual Commit Messages

  • Consistency: Never worry about format variations again
  • Speed: Generate messages in seconds, not minutes
  • Quality: AI understands context better than quick human thoughts

vs. Other AI Tools

  • Specialized: Built specifically for git workflows
  • Offline-First: Only sends diffs to AI, not your entire codebase
  • Logging: Built-in analytics to improve over time
  • Easy Installation: One-command setup across all platforms

vs. IDE Extensions

  • Universal: Works with any editor or terminal
  • Lightweight: No IDE dependencies
  • Scriptable: Easy to integrate into workflows and scripts

Future Roadmap 🛣️

Some exciting features being considered:

  • Support for additional AI providers (OpenAI, Claude, etc.)
  • Template customization for team-specific formats
  • Integration with popular git workflows
  • Commit message suggestions based on issue numbers
  • Team analytics and best practices sharing

Get Started Today! 🎯

Ready to level up your git workflow? Here's how to get started:

  1. Install GoCommit:
   curl -sSL https://raw.githubusercontent.com/thanhphuchuynh/gocommit/main/install.sh | bash
Enter fullscreen mode Exit fullscreen mode
  1. Get a Gemini API key from Google AI Studio

  2. Configure and start using:

   gocommit --config
   # Stage some changes
   git add .
   gocommit
Enter fullscreen mode Exit fullscreen mode

Contributing 🤝

GoCommit is open source and welcomes contributions! Whether it's:

  • Bug reports and feature requests
  • Code contributions
  • Documentation improvements
  • Usage feedback and suggestions

Check out the GitHub repository to get involved.

Conclusion 🎉

Writing good commit messages doesn't have to be a chore. With GoCommit, you can focus on writing great code while AI handles the documentation part.

The tool is designed by developers, for developers, with real-world workflows in mind. It's fast, reliable, and gets better over time through usage analytics.

Give it a try and let me know what you think! Your future self (and your teammates) will thank you for the clear, consistent commit history.


Have you tried GoCommit? What's your experience with AI-powered development tools? Share your thoughts in the comments below! 👇

P.S. If you found this useful, consider starring the GitHub repo to help others discover it!

Top comments (0)