Show HN: GitPT – Git Prompt Tool

4 days ago 2

Git Prompt Tool is a CLI tool that helps you write commit messages using AI through OpenRouter or a local LLM. It acts as a complete git wrapper, enhancing specific commands with AI while passing through all other git commands directly.

  • Acts as a complete git replacement - all git commands are supported

  • Generate commit messages with AI based on your code changes

    gitpt commit

  • Create pull requests with AI-generated titles and descriptions

    gitpt pr create

  • Compatible with all regular git options (flags, arguments, etc.)

  • Edit suggested messages before committing

  • Works with various AI models via OpenRouter

  • Support for local LLMs with OpenAI-compatible API

  • Commitlint support - read directly from your repository

# Install globally npm install -g gitpt # Or use npx npx gitpt

To configure GitPT with your OpenRouter API key and select a model:

This will guide you through:

  1. Entering your OpenRouter API key
  2. Selecting an AI model from popular options or specifying a custom one

It's recommended using small models, such as openai/gpt-4.1-mini as your model choice. Mainly due to its large context window, fast response times & cost-effective pricing.

You'll need an OpenRouter account to get an API key.

Using GitPT as a Complete Git Replacement

GitPT can be used as a direct replacement for git - any git command can be run through GitPT:

# Standard git commands work exactly the same gitpt status gitpt log gitpt branch gitpt checkout -b new-feature gitpt push origin main # GitPT passes all arguments and options to git gitpt log --oneline --graph gitpt merge --no-ff feature-branch

Add files to the staging area just like you would with git:

# Same as git add . (supports all the regular git add options) gitpt add .

Generate an AI-powered commit message based on your staged changes:

gitpt commit # Or supply -m argument, if you want to avoid gitpt generating the message gitpt commit -m "feat: file hash validation" # Pass any other git commit options gitpt commit --amend

The tool will:

  1. Analyze your staged changes
  2. Generate a commit message using the configured AI model
  3. Validate against commitlint rules (if configured)
  4. Regenerate the message if it fails validation
  5. Show you the suggested message
  6. Let you edit the message before committing
  7. Create the commit with your approved message

You can change the AI model at any time:

# Select model interactively (either OpenRouter or a local LLM) gitpt model

It's recommended using small models, such as openai/gpt-4.1-mini as your model choice. Mainly due to its large context window, fast response times & cost-effective pricing.

GitPT works with any local LLM that provides an OpenAI-compatible API endpoint, such as:

If you have GitHub CLI (gh) installed, you can use GitPT to interact with GitHub (e.g. generate full pull requests).

Generate AI-powered pull request titles and descriptions based on your changes:

The tool will:

  1. Analyze the commits and files changed since branching from the base branch
  2. Generate a suitable PR title and detailed description
  3. Show you the suggested content
  4. Let you edit the title and description before submission
  5. Create the pull request with your approved content
# Create a draft PR gitpt pr create --draft # Specify a custom base branch gitpt pr create --base develop # Skip editing the PR details gitpt pr create --no-edit # Provide your own title instead of generating one gitpt pr create --title "Your PR title here"

GitPT leverages AI to enhance your Git workflow while acting as a complete git wrapper:

  • Command Handling: GitPT intelligently routes commands - enhanced commands (commit, pr) use AI capabilities while all other git commands are passed directly to git.

  • For commits: Sends a diff of your staged changes to the AI, which generates a contextual commit message following best practices.

  • Commitlint Integration: Automatically detects commitlint configuration files and validates generated commit messages against your project's commit conventions. If validation fails, it regenerates a compliant message.

  • For pull requests: Analyzes the commits and file changes between your branch and the base branch, then generates a suitable title and detailed description for your PR.

  • For other git commands: Passes them through directly to git with all arguments and options preserved, ensuring complete compatibility with your existing git workflow.

  • Local LLM Support: Can use locally running LLM servers with OpenAI-compatible APIs instead of cloud-based services, providing privacy and offline capabilities.

# Clone the repository git clone https://github.com/bartaxyz/GitPT.git cd GitPT # Install dependencies npm install # Build the project npm run build # Link for local development npm link

GitPT automatically detects and integrates with commitlint if it's configured in your repository:

  • Automatic Detection: GitPT checks for common commitlint configuration files (commitlint.config.js, .commitlintrc.*, etc.)

  • Rule-Aware Generation: When commitlint is detected, GitPT instructs the AI to generate messages that follow your specific commit conventions

  • Validation & Regeneration: Generated messages are validated against your commitlint rules before committing. If validation fails, GitPT automatically regenerates a compliant message

  • Error Feedback: Validation errors are sent to the AI to help it understand how to fix the message

This integration ensures that all AI-generated commit messages follow your team's established commit conventions without requiring manual corrections.

MIT

Read Entire Article