Skip to main content

Generate summaries and code reviews for GitLab Merge Requests or GitHub Pull Requests using LLM

Project description

GitLab Merge Request Summary Generator

This command-line tool generates a "What's New" summary for a GitLab Merge Request. It uses the GitLab API to fetch technical details (like commit messages and code changes) and then leverages the Google Gemini API to translate them into a clear, benefit-oriented summary suitable for non-technical clients.

Features

  • Fetches Merge Request details, commit history, and code diffs from GitLab.
  • Uses the Gemini API to generate an intelligent, human-readable summary.
  • Formats the output in Markdown with "New Features" and "Bug Fixes" sections.
  • Creates client-friendly language by focusing on benefits, not technical jargon.
  • Includes a debug mode to inspect the exact prompt sent to the AI.

Prerequisites

Before you begin, ensure you have the following:

Installation

Install with pipx (recommended)

Use pipx to install and run the CLI in an isolated virtual environment, available globally as git-ai:

# If you don't have pipx yet (macOS/Homebrew)
brew list pipx >/dev/null 2>&1 || brew install pipx
pipx ensurepath

# From a cloned repo or local path
git clone https://github.com/AlexzanderF/git-ai-cli.git
cd git-ai-cli
pipx install .

# Upgrade later
pipx upgrade git-ai

You can also install directly from Git using:

pipx install git+https://github.com/AlexzanderF/git-ai-cli.git

After installation, the global command is git-ai.

Install with pip (alternative)

pip install -r requirements.txt

Persisting configuration (TOML)

When required values are missing, the tool will prompt you interactively and then persist them to ~/.git-ai/config.toml automatically. Subsequent runs will load values from the config file. Precedence matches AWS CLI: command-line flags > environment variables > config file. Example config.toml:

GITLAB_URL = "https://gitlab.com"
GITLAB_PRIVATE_TOKEN = "<your_token>"
GITLAB_PROJECT_ID = "<project_id>"
GEMINI_API_KEY = "<gemini_api_key>"

Usage

After installation with pipx, use the global command git-ai. The tool provides two main commands: summarize and code-review.

Summarize a Merge Request

Generates a "What's New" summary for a GitLab Merge Request, tailored to different audiences.

git-ai summarize <mr_id> [--style <style1> <style2>...] [--debug]
  • <mr_id>: The IID (Internal ID) of the Merge Request to analyze (e.g., 42).
  • --style: One or more summary styles. Choices: clients, devops, developers. You can also use all to generate all of them. If omitted, it defaults to generating all styles.
  • --debug: Save the full prompt to a debug file for inspection.

Examples

# Generate summaries for all styles (default behavior)
git-ai summarize 42

# Generate a client-focused summary
git-ai summarize 42 --style clients

# Generate summaries for both developers and devops
git-ai summarize 42 --style developers devops

This command will:

  1. Fetch data for the specified Merge Request from the configured GitLab project.
  2. Generate a summary for each specified style using Gemini.
  3. Print the summaries to the console.
  4. Save each summary to a file named release_summary_mr_<iid>.<style>.md (e.g., release_summary_mr_42.clients.md).

Review a Merge Request's Code

Generates a comprehensive, structured code review from the Merge Request's diffs.

git-ai code-review <mr_id> [--debug]
  • <mr_id>: The IID of the Merge Request to review.
  • --debug: Save the full prompt to a debug file.

This command outputs a code_review_mr_<iid>.md file containing a detailed review with structured findings on security, correctness, performance, readability, and more, along with an actionable checklist.

Debug Mode

For both summarize and code-review, you can use the --debug flag to inspect the exact prompt being sent to the Gemini API.

This will create an additional file named debug_prompt_mr_<iid>.<style>.md (for summaries) or debug_code_review_prompt_mr_<iid>.md (for code reviews).

Styles

Choose one or more --style options for the summarize command to match your target audience. If you don't provide a style, summaries for all audiences will be generated by default.

  • clients: Benefit-oriented, non-technical “What’s New” for customers. Uses friendly tone and focuses on outcomes. Sections: New Features, Bug Fixes.
  • devops: Operational brief for DevOps/SRE. Highlights environment variables, database migrations, seeds, infrastructure/IaC, CI/CD, logging/monitoring, security, dependencies, operational tasks/runbook, and breaking changes.
  • developers: Technical synopsis for implementers. Sections may include: Features/Enhancements, Bug Fixes, Refactors, API Changes, Configuration (incl. env vars), Database, Dependencies/Tooling, Tests, Known Issues, Deployment Checklist.

Output Example

The tool will generate a Markdown file with a summary similar to this:

We've been working hard to improve your experience! This update brings some exciting new capabilities and resolves a few pesky issues. Here’s a look at what’s new.

✨ New Features

  • Faster & More Secure Logins: We've completely overhauled our authentication system, making the login process quicker and more secure for your peace of mind.
  • New User Profile Page: You can now view and manage your account details on a redesigned, easy-to-use profile page.

🐛 Bug Fixes

  • Fixed an issue where the application would occasionally crash when uploading a new profile picture.
  • Resolved a bug that caused incorrect data to be displayed on the dashboard for some users.

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

gitai_tool-0.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitai_tool-0.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file gitai_tool-0.1.0.tar.gz.

File metadata

  • Download URL: gitai_tool-0.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for gitai_tool-0.1.0.tar.gz
Algorithm Hash digest
SHA256 912af1c8b57ce769dde036adc41f435b3ef552fc1434e4cc7c75e9656634477f
MD5 b75e9c08be2b79515876f9f5f95191a2
BLAKE2b-256 245c65cc0b027656a1f5567ba5544acab39f2e5a66a27b1de1c4fcc07fc3b7ed

See more details on using hashes here.

File details

Details for the file gitai_tool-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gitai_tool-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for gitai_tool-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f760d5ad3b63668b0fa9e989c774639ee2d0528580ea75e5490191768992c28
MD5 1168e4722616edec13a473acc3e971c0
BLAKE2b-256 ceafc46a2b3937194c588f2c3afb99c0400da91c87f8281360eac8b1f37b0040

See more details on using hashes here.

Supported by

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