Skip to main content

Commitai helps you generate git commit messages using AI

Project description

CommitAi - Commit Message AI

CI codecov PyPI Python Version License

CommitAi is a command-line tool that helps you generate informative and relevant commit messages for your Git repositories using AI language models like GPT-4 and Claude. It analyzes your staged changes, combines them with a high-level explanation provided by you, and creates a commit message based on this information. Additionally, it supports custom commit message templates. This not only saves you time and effort but also ensures a consistent and meaningful commit history.

Features

  • Automatically runs the repository's pre-commit hook (if it exists) before generating the commit message to avoid discarded commit costs.
  • Generates informative and relevant commit messages based on staged changes and user-provided explanations.
  • Supports custom commit message templates.
  • Integrates with AI language models like GPT-4 and Claude for intelligent commit message generation.

Prerequisites

  • Python 3.x
  • API keys for the desired language models (e.g., OpenAI API key for GPT-4, Anthropic API key for Claude)

Installation

You can install commitai using pip:

pip install commitai

Configuration

Environment Variables

Before using commitai, you need to set the API key environment variables for the language models you want to use. For example:

export OPENAI_API_KEY="your_openai_api_key" export ANTHROPIC_API_KEY="your_anthropic_api_key"

You can also set the TEMPLATE_COMMIT environment variable to define a global template for your commit messages:

export TEMPLATE_COMMIT="My global custom template: {message}"

Template Configuration

Creating a Template for the Repository

You can create a custom template specific to the repository using the create-template command. This template will override the global template set in the TEMPLATE_COMMIT environment variable if present.

commitai create-template "My repository-specific template: {message}"

This command will create a hidden file inside the .git directory to store the template.

Usage

Generating Commit Messages

commitai generate "This is a high-level explanation of my commit"

  • Use the -a or --add flag to stage all changes.
  • Use the -c or --commit flag to automatically create the commit.
  • Use the -t or --template flag for custom templates or utilize the TEMPLATE_COMMIT environment variable. If no template is provided, a default or global template will be used.
  • Use the -m or --model flag to specify the language model to use (default: gpt-4).

Contributing

We welcome contributions to the commitai project! Please feel free to submit issues, feature requests, or pull requests.

License

This project is released under the MIT License.

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

commitai-0.1.15.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

commitai-0.1.15-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file commitai-0.1.15.tar.gz.

File metadata

  • Download URL: commitai-0.1.15.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for commitai-0.1.15.tar.gz
Algorithm Hash digest
SHA256 1d61be5b3733f3a6cb80f6269d24d6ac40515076f850acd3efb0fef4525c316f
MD5 f5e9b355a6c56853d16f21b6808f188f
BLAKE2b-256 e86ef856752a07348c341d70589047edca0d15f39cb444f3f06220843fd5cb36

See more details on using hashes here.

File details

Details for the file commitai-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: commitai-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for commitai-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 830ed541d19d803fee6c4d1fcc0d0a5e65e03d570c9b15e3481854e29991430b
MD5 e9e74a6da81295dd003e9e22b29a0177
BLAKE2b-256 55178b853b23327f36522d661bae88a89e56eddd6c030e5b9173308e12cc540e

See more details on using hashes here.

Supported by

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