GitAIGitAICLI

Smart CLI for AI-driven Git commit & PR generation.

terminal
~ $
ℹ Creating GitAI CLI configuration from ...
✔ GitAI CLI configuration created successfully in .gitai
✔ Created .env-example file in current directory.

AI Git Commit Message

Generate commit messages automatically based on code changes and Conventional Commits

Pull Request Docs Generation

Generate pull request docs according to your predefined template

Multi Model Support

Support multiple models, including GPT, GROK, Gemini and Ollama (Private and secure)

How GitAI Works

GitAI leverages the power of AI to analyze your code changes and generate meaningful commit messages and PR descriptions.

GitAI CLI Flow Diagram

1. Analyzes Your Changes

GitAI CLI reads your current git diff, file tree, and branch information directly from your repository.

2. Leverages AI Models

Your changes are processed by advanced language models like GPT-4, Gemini, or local models via Ollama.

3. Generates Quality Output

Get standardized commit messages following Conventional Commits specification or comprehensive PR descriptions.

Quick Start

Get up and running with GitAI CLI in minutes

NPM Installation

Quick install via npm (requires Node.js 20+)

1

Install globally

npm i -g @lastwhisper-dev/gitai-cli
2

Initialize in your project

gitai init
3

Set up environment

cp .env-example .env

Build from Source

Build and install from the latest source code

1

Clone repository

git clone https://github.com/keli-wen/gitai-cli.git
2

Install dependencies

cd gitai-cli && npm install
3

Build and link locally

npm run build && npm link

Usage Examples

Commit Generation

git add . && gitai commit -n 3

Generate 3 commit message suggestions

PR Description

gitai pr -t master

Generate PR description against master branch

Advanced Usage

gitai commit -p "Use Chinese"

Generate commit with custom context

Configuration

GitAI CLI is highly customizable to fit your workflow

Flexible Configuration

Customize providers, models, and settings per command

Multiple Providers

Support for OpenAI, DeepSeek, Gemini, Grok, and Ollama

Secure by Default

Environment-based secrets management

Command-specific Settings

Fine-tune behavior for commits and PRs separately

config.yaml
llm:
  default:
    provider: openai
    model: gpt-4o-mini
    apiKeyEnvVar: 'OPENAI_API_KEY'
    baseUrlEnvVar: 'OPENAI_BASE_URL'
    temperature: 0.7
  commands:
    commit:
      # provider: deepseek # Example: override for commit command
      # model: deepseek-chat
      # apiKeyEnvVar: 'DEEPSEEK_API_KEY'
    pr:
      # provider: ollama    # Can be changed to 'grok' or 'gemini' ...
      # model: deepseek-r1:32b
      # temperature: 0.4

commit:
  suggestions: 3
  prompt_template: './prompts/commit_prompt.txt'

pr:
  base_branch: main         # When user doesn't pass --target
  include_file_tree: true   # Whether to include the file tree generated by ls-files
  include_unstaged: false   # Corresponds to --unstaged
  max_lines_per_file: 300   # Diff truncation threshold
  warn_on_conflict: true    # Whether to interrupt when merge conflicts are detected
  prompt_template: ./prompts/pr_prompt.txt

Command Showcase

Explore the powerful commands GitAI CLI offers

Generate Commit Messages

Generate meaningful commit messages that follow the Conventional Commits specification

# Generate commit messages for staged changes
gitai commit

# Provide additional context to the AI
gitai commit -p "Focus on refactoring of user service"

# Get 5 suggestions
gitai commit -n 5

# (macOS example) Copy prompt to clipboard for use with web-based AI
gitai commit --print-prompt | pbcopy
  • Generate multiple suggestions at once
  • Follows Conventional Commits format
  • Add custom context with the -p flag
  • Customize the number of suggestions with -n

Future Roadmap

Exciting features planned for upcoming GitAI CLI releases

gitai query

gitai query --prompt "xxx"

Query your Git repository using natural language. Get information about branches, recent commits, and status with the power of AI.

  • All local and remote branches
  • Current branch name
  • Recent Git log (last 10 commits)
  • Current git status

gitai context

gitai context --format json

Export project information as AI-friendly context in Markdown or JSON format for external AI models or debugging.

  • Current git diff (staged, working directory or between specified commits)
  • Project file structure (filterable by depth, size, extension)
  • package.json dependencies, current branch name, recent commit history

Demo Preview

Input:

What changes were made in the last week?

Output:

Analyzing recent commits (last 7 days):

1. feat(auth): Add OAuth2 provider integration
   - Added OAuth2 client configuration
   - Implemented token refresh logic
   - Added user profile sync

2. fix(api): Handle rate limiting edge cases
   - Added retry mechanism
   - Improved error messages

3. docs: Update API authentication guide
   - Added OAuth2 setup instructions
   - Updated example requests