Skip to content

CommitAI is a command-line tool that helps you generate informative and relevant commit messages for your Git repositories using GPT-4 by OpenAI. It analyzes your staged changes, combines it with a high-level explanation provided by you, and creates a commit message based on this information

Notifications You must be signed in to change notification settings

lguibr/commitai

Repository files navigation

CommitAi - Your AI-Powered Commit Assistant

CI codecov PyPI Python Version License

CommitAi simplifies the Git commit message creation process by leveraging AI technologies, including GPT-4 and Claude. Designed for developers who value clarity and precision in commit histories, CommitAi offers a streamlined workflow that transforms your staged changes and high-level explanations into informative commit messages. Enhance your project documentation and streamline your development process with commit messages that truly reflect your changes.

Demo

CommitAi Demo

This demo GIF shows CommitAi in action, demonstrating how it generates a commit without any additional input, using Claude 3 Opus.

Features

  • Intelligent Commit Generation: Leverages state-of-the-art AI models to generate meaningful commit messages from your changes.
  • Pre-commit Checks: Automatically runs configured pre-commit hooks to ensure quality and consistency before generating messages.
  • Template Support: Utilizes both global and repository-specific commit message templates to maintain a consistent style across your projects.
  • AI Model Integration: Supports multiple AI models, including GPT-4 by OpenAI and Claude by Anthropic, ensuring versatility in natural language processing capabilities.

Getting Started

Prerequisites

  • Python 3.6 or later
  • API keys for GPT-4 and Claude, as required

Installation

Install CommitAi directly from PyPI:

pip install commitai

Configuration

API Keys

Set the necessary API keys as environment variables:

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

Commit Templates

Set a global commit template environment variable:

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

Or, create a repository-specific template using:

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

This creates a hidden template file within the .git directory of your repository.

Usage

To generate a commit message, provide a high-level explanation of your changes:

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

Options

  • -a, --add: Stage all changes before generating the commit message.
  • -c, --commit: Automatically create the commit using the generated message.
  • -t, --template: Specify a commit template. Defaults to the global template if available.
  • -m, --model: Choose the AI model (gpt-4 by default).

Additional Commands

  • commitai-create-template: Set a custom template specific to your repository.

Contributing

Contributions are welcome! Feel free to fork the repository, push your changes to a branch, and open a pull request. For bugs, questions, or feature requests, please open an issue through the GitHub issue tracker.

License

CommitAi is open-source software licensed under the MIT License. See the LICENSE file for more details.

About

CommitAI is a command-line tool that helps you generate informative and relevant commit messages for your Git repositories using GPT-4 by OpenAI. It analyzes your staged changes, combines it with a high-level explanation provided by you, and creates a commit message based on this information

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages