Thanks to visit codestin.com
Credit goes to github.com

Skip to content

au-phiware/commitgpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CommitGPT

CommitGPT is a tool that generates commit messages using Claude, an AI model by Anthropic. It aims to improve the consistency and quality of git commit messages by integrating AI assistance into the development workflow.

Prerequisites

  • Go 1.x
  • Git
  • Pandoc
  • libsecret (for storing the API key securely)

Installation

Using Nix

If you have Nix installed, you can build and install CommitGPT using the following commands:

nix-build
nix-env -i ./result

This will build the project and install the binary in your Nix profile. The binary is wrapped in a shell script that sets up the necessary environment variables, so you can use it directly as a prepare-commit-msg git-hook (see Usage).

Using Go

To install CommitGPT using Go, follow these steps:

  1. Clone the repository:

    git clone https://github.com/au-phiware/commitgpt.git
    cd commitgpt
  2. Build the project:

    go build -o commitgpt
  3. Install the binary:

    go install

Configuration

Before using CommitGPT, you need to set up your Anthropic API key:

  1. Store your API key securely using secret-tool:

    secret-tool store --label="Anthropic API Key" anthropic-api-key commitgpt
  2. Create a directory for logs:

    mkdir -p ~/.config/anthropic/logs

Usage

To use CommitGPT as a Git hook for preparing commit messages:

  1. Create a file named prepare-commit-msg in your Git repository's .git/hooks/ directory with the following content:

    #!/bin/sh
    export ANTHROPIC_API_KEY=$(secret-tool lookup anthropic-api-key commitgpt)
    export ANTHROPIC_LOG_DIR=~/.config/anthropic/logs
    commitgpt $1 $2 $3
  2. Make the hook executable:

    chmod +x .git/hooks/prepare-commit-msg

Now, when you make a commit, CommitGPT will automatically generate a commit message based on your changes.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgements

This project uses the Claude API by Anthropic to generate commit messages.

The metaprompting technique used in this project is based on the Metaprompt Workbook by Anthropic. You can find the workbook here: Metaprompt Workbook. We highly recommend checking it out to understand the underlying methodology of our commit message generation process.

About

An AI-powered git-commit-template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published