Skip to main content

AI-powered CLI tool for generating git commit messages.

Project description

DiffCraft

Craft the perfect git commit, instantly.

PyPI version License: MIT GitHub Repo

DiffCraft is a smart command-line tool that uses Google's Gemini to instantly generate high-quality, conventional commit messages from your staged code changes.

Install:

pip install diffcraft

Features:

  • 🤖 AI-Powered Commits: Analyzes your git diff to create meaningful and descriptive commit messages that truly reflect your changes.
  • Enforce Best Practices: Automatically follows the Conventional Commits standard, improving your project's readability and making it easier to automate releases.
  • ⚙️ You're Always in Control: Interactively [A]ccept the suggestion, [E]dit it in your own editor, [R]egenerate a new one, or [Q]uit.
  • 🌍 Flexible & Powerful: Generate commits in different languages (--lang), provide context from your commit history (--history), and force specific types (--type).

Installation

DiffCraft is available on PyPI and can be installed with a single pip command.

pip install diffcraft

Setup & Configuration

To use DiffCraft, you need a Google Gemini API key.

Method 1: .env File (Recommended)

This method is easy and keeps your API key specific to your project.

  1. Get your free API key from Google AI Studio.

  2. In the root directory of your git project, create a new file named .env.

  3. Add the following line to the .env file, pasting your own key:

GEMINI_API_KEY="YOUR_API_KEY_HERE"

🔒 Important Security Note Remember to add the .env file to your project's .gitignore to ensure your secret API key is never committed to your repository! If your .gitignore doesn't have it, add this line:

.env

Method 2: Environment Variable (Advanced)

This method is ideal for servers, CI/CD pipelines, Docker containers, or any user who prefers to manage API keys globally. DiffCraft will always prioritize a system-wide environment variable over a local .env file. Open your terminal and use the appropriate command for your operating system.

macOS / Linux

export GEMINI_API_KEY="YOUR_API_KEY_HERE"

To make this permanent, add the command to your ~/.zshrc or ~/.bashrc file.

Windows (PowerShell)

$env:GEMINI_API_KEY="YOUR_API_KEY_HERE"

Windows (CMD)

set GEMINI_API_KEY="YOUR_API_KEY_HERE"

For permanent setup on Windows, search for "Edit the system environment variables" in the Start Menu. You will need to close and reopen your terminal for the changes to take effect.

Usage

The workflow is designed to be seamless.

  1. Stage your files as you normally would:
git add README.md
git add .
git add src/
  1. Run the craft command:
craft

This will generate a commit message and present you with the interactive prompt.

Or,

craft README.md
craft .
craft src/

This will both stage the files and generate a commit message.

Command-Line Options

For a full list of commands and detailed explanations, use the --help flag:

craft --help

Example: Generate a 'fix' commit and edit it immediately

craft --type fix --edit

Example: Generate a commit in Spanish using the last 3 commits for context

craft --lang Spanish --history 3

Contributing

Found a bug or have a feature request? We'd love your help! Please open an issue or submit a pull request on our GitHub Repository

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

diffcraft-2.0.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

diffcraft-2.0.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file diffcraft-2.0.0.tar.gz.

File metadata

  • Download URL: diffcraft-2.0.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for diffcraft-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ef7df1428a861bcb4892145d8a2d9f0f94c40029c8aeed1be5a3aff8c31a078f
MD5 65b09f65c22a48673271883d9cafb068
BLAKE2b-256 5f6ff2f808ee0735870f2647bef6da203b613a416f7919f17478b36aef3fad34

See more details on using hashes here.

File details

Details for the file diffcraft-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: diffcraft-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for diffcraft-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec2de8a82809f541f258caa9567882413a6458a092a1fa06b2ffb4122577032d
MD5 117548a0c9aa9d71a8ea8e33dab2a421
BLAKE2b-256 fb5972d89ba56d012461c3a27e20164cb5f3a6d6608f1f0cef0ee7a06722d4e7

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