Skip to main content

An AI-powered CLI to generate git commit messages using Google Gemini.

Project description

GitComposer

GitComposer is a command-line tool that uses Google's Gemini AI to automatically generate concise, conventional commit messages from your staged Git changes. It streamlines your workflow by analyzing your diff and committing the changes for you with a single command.


The Problem It Solves

Writing clear and conventional commit messages is a best practice, but it can be tedious. GitComposer takes on this task for you. It reads your staged changes, understands the context, and generates a high-quality commit message in the imperative mood (e.g., "Add user authentication feature" instead of "Added a feature"). This saves you time and ensures your project's commit history remains clean, consistent, and easy to read.

Features

  • 🤖 AI-Powered Messages: Leverages the Google Gemini CLI to generate context-aware commit messages.
  • Interactive Workflow: Displays the suggested message and asks for your confirmation before committing.
  • ⚙️ Simple Interface: Runs with a single command: gitcomposer.
  • 📂 Directory-Aware: Works on any Git repository by pointing to its path or by running it from within the project directory.
  • 📦 Easy Installation: Packaged and ready for installation via pip.

Demo

Here is a typical workflow using gitcomposer:

# You've done some work and staged your files
$ git add .

# Run gitcomposer in your repository's directory
$ gitcomposer
Analyzing repository at: /home/user/projects/my-awesome-project
Sending staged changes to Gemini to generate a commit message...

✨ Suggested Commit Message ✨
---------------------------------
Refactor user service to use dependency injection
---------------------------------

Do you want to commit with this message? [Y/n]: y

Committing changes...

✅ Commit successful!
[main 7f3b1d9] Refactor user service to use dependency injection
 1 file changed, 5 insertions(+), 3 deletions(-)

Prerequisites

Before you can use GitComposer, you must have the following tools installed and configured on your system:

  1. Git: The version control system itself. Installation Guide

  2. Node.js and npm: Required to install the Gemini CLI. Installation Guide

  3. Google Gemini CLI: The core dependency that provides the AI capabilities.

    Install it globally via npm:

    npm install -g @google/generative-ai/cli
    

Installation

Once the prerequisites are met, you can install GitComposer directly from PyPI:

pip install gitcomposer

This will automatically install the click library and make the gitcomposer command available in your terminal.

Configuration

GitComposer works by calling the gemini command, which must be configured with your Google Gemini API key. If you haven't done so already, configure the Gemini CLI by running:

gemini auth

This command will prompt you to enter your API key. This is a one-time setup.

Usage

The command is simple and straightforward.

  1. Navigate to your Git repository in your terminal.

  2. Stage the changes you want to commit (git add ...).

  3. Run the command:

    gitcomposer
    

Alternatively, you can run the command from anywhere and pass the path to your repository as an argument:

gitcomposer /path/to/your/repository

The tool will then generate a message and prompt you for confirmation before committing.

How It Works

  1. The gitcomposer command is executed in a repository with staged changes.
  2. It runs git diff --staged to capture the code modifications.
  3. This diff is sent to the Gemini CLI with a carefully crafted prompt asking for a conventional commit message.
  4. Gemini returns a suggested message.
  5. The message is displayed to you for approval.
  6. If you confirm, the tool executes git commit -m "The generated message" to finalize the commit.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitcomposer-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitcomposer-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file gitcomposer-0.1.0.tar.gz.

File metadata

  • Download URL: gitcomposer-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for gitcomposer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3fc49fa811de5bdbcc938f31823980c22ef7f8a196073a5e6ec4b0a71c07fc01
MD5 828ef5b1bf57fb142a47c2c88143183f
BLAKE2b-256 5dc60240d13d1e149f58dac588d5a8d0779c25aa9b7b9e2376c213b0f841ddca

See more details on using hashes here.

File details

Details for the file gitcomposer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gitcomposer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for gitcomposer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 523b9a1bcc0cf514ddd423b29fdb551ae9f1f3d5ea7330d5d4dbcfa721894573
MD5 c5e96051e4c35ab073d44eba898c9994
BLAKE2b-256 51b5a21a250363712de7c98ff46677d66898c7e1182bba3f997f12ab04017d3c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page