Skip to main content

AIPR - Agentic Pull Request Description Generator

CI Release Python Code style: black Checked with mypy License

Automatically analyze git diffs and vulnerabilities to generate comprehensive, well-structured pull request descriptions. By intelligently detecting changes, performing security scans, and leveraging state-of-the-art AI models, AIPR helps teams save time while maintaining high-quality, consistent pull request descriptions.

AI-Driven Development

AI-Driven Claude Ready

This project follows an AI-driven development workflow:

  • 🤖 Built with AI - Developed using Claude Code with comprehensive AI guidance
  • 📋 AI Task Assignment - Structured workflow for AI agents documented in CONTRIBUTING.md
  • 📚 AI-Friendly Documentation - Comprehensive guides for AI agents in CLAUDE.md and Architecture Decision Records
  • 🏗️ Architecture-First Design - ADRs define behavior and guide implementation patterns
# Install with pipx (recommended)
pipx install pr-generator-agent

# Or with pip
pip install pr-generator-agent

# Set the environment variable for the API key
export ANTHROPIC_API_KEY="your-api-key"

# Generate a PR description
aipr

# Generate a conventional commit message
aipr commit

# Generate PR description from commit range
aipr pr --from abc123 --to def456

# Generate commit message from commit range
aipr commit --from v1.0.0

# Custom usage - Analyze changes against main branch
# Include: Vulnerability scanning
# Use: Azure OpenAI GPT-5 Mini model
# Prompt: meta template
# Output: Verbose
aipr pr -t main --vulns -p meta -m azure/gpt-5-mini -v

# Inline with merge request creation
gh pr create -b "$(aipr pr -s)" -t "feat: New Feature"

# Inline with commit creation
git commit -m "$(aipr commit)"

Key Features

  • 🔍 Smart Detection: Automatically analyzes working tree changes, compares branches, or analyzes commit ranges
  • 📝 Conventional Commits: Generate conventional commit messages from staged changes or commit ranges
  • 📊 Commit Range Analysis: Generate descriptions and commit messages from any commit range (SHA to SHA)
  • 🛡️ Security First: Optional vulnerability scanning between branches using Trivy
  • 🤖 AI-Powered: Multiple AI providers (Azure OpenAI, OpenAI, Anthropic, Gemini) for optimal results
  • 🔄 CI/CD Ready: Seamless integration with GitLab and GitHub workflows

Example Output

Change Summary:

1. **Added User Authentication**
   - Implemented JWT middleware
   - Added login/register endpoints
   - Updated bcrypt to v5.1.1

2. **Security Updates**
   - Fixed 2 medium severity vulnerabilities
   - Updated deprecated crypto functions

Security Analysis:
✓ No new vulnerabilities introduced

Commit Message Generation

$ git add src/auth.py tests/test_auth.py
$ aipr commit
feat(auth): add OAuth2 authentication support

$ git add requirements.txt
$ aipr commit
build(deps): update dependencies to latest versions

$ git add README.md docs/guide.md
$ aipr commit
docs: update installation and usage documentation

Requirements

  • Python 3.11 or higher (3.11, 3.12 officially supported)
  • Git
  • LLM API Key (Anthropic, OpenAI, or Azure OpenAI)
  • Trivy (used for --vulns scanning)

Environment Variables

The tool automatically detects which provider to use based on available environment variables, with the following priority order:

  1. Anthropic (Default - Highest Priority)

    • ANTHROPIC_API_KEY: Anthropic API key
  2. Azure OpenAI

    • AZURE_API_KEY: Azure OpenAI API key
    • AZURE_OPENAI_ENDPOINT: Azure endpoint URL
    • AZURE_API_VERSION: API version (default: "2024-02-15-preview")
  3. OpenAI

    • OPENAI_API_KEY: OpenAI API key
  4. Google Gemini

    • GEMINI_API_KEY: Google Gemini API key
  5. xAI

    • XAI_API_KEY: xAI API key for Grok models

Usage

AIPR provides two main commands:

PR Command (Pull Request Descriptions)

aipr pr [options]  # or just 'aipr' for backward compatibility

Options:

  • -t, --target: Compare changes with specific branch (default: auto-detects main/master)
  • -p, --prompt: Select prompt template (e.g., 'meta')
  • --vulns: Include vulnerability scanning
  • --working-tree: Use working tree changes
  • --context: Additional context for the PR description
  • --from: Starting commit for range analysis (SHA, branch, tag, etc.)
  • --to: Ending commit for range analysis (defaults to HEAD, requires --from)
  • --max-input-tokens: Refuse to call the API above this estimated input size (default 100000, 0 disables)

Global Options:

  • -v, --verbose: Show API interaction details
  • -d, --debug: Preview prompts without API calls
  • -s, --silent: Output only the description
  • -m, --model: Specify AI model to use
  • -V, --version: Show the installed aipr version and exit

The tool intelligently detects changes by:

  1. Using staged/unstaged changes if present
  2. Comparing against target branch if working tree is clean

Commit Command (Conventional Commit Messages)

aipr commit [options]

Options:

  • --conventional: Generate conventional commit message (default)
  • --format: Message format (currently only 'conventional')
  • --context: Additional context for the commit message
  • --from: Starting commit for range analysis (SHA, branch, tag, etc.)
  • --to: Ending commit for range analysis (defaults to HEAD, requires --from)
  • --max-input-tokens: Refuse to call the API above this estimated input size (default 100000, 0 disables)

Examples:

# Basic commit message generation from staged changes
git add .
aipr commit

# Generate commit message from commit range
aipr commit --from abc123 --to def456

# Generate commit message from specific commit to HEAD
aipr commit --from abc123

# With additional context
aipr commit --context "upstream sync"

# Use in automation
git commit -m "$(aipr commit)"

Cost Safeguards

Before any API call, aipr shapes the diff and checks its size:

  • Lock files, minified bundles, images, notebooks, and build or vendor directories are replaced by a one-line marker. The model still sees that the file changed, not its contents.
  • A single file longer than 1500 diff lines is cut with a marker so one generated file cannot crowd out the rest.
  • The estimated input size is printed to stderr, and anything over the ceiling is refused with a clear message and a non-zero exit before a request is sent. Set the ceiling with --max-input-tokens or AIPR_MAX_INPUT_TOKENS; 0 disables it.
  • On the commit command, a subject line the model overruns past 72 characters triggers one rewrite request before the fallback wrap into the body. That retry resends the diff, so the worst case is twice the admitted budget.

Supported AI Models

Choose from multiple AI providers:

Provider Model Notes
Anthropic claude-sonnet-5-5 Claude Sonnet 5.5 (default)
claude, sonnet aliases for claude-sonnet-5-5
Azure OpenAI azure/gpt-5-nano default Azure model
azure/gpt-4.1-nano Lightweight model
azure/gpt-5-chat Conversational model
azure/gpt-5-mini Mid-tier model
azure alias for azure/gpt-5-nano
OpenAI gpt-6-luna GPT-6 Luna (default)
openai alias for gpt-6-luna
Google Gemini gemini-2.5-flash Best price-performance (default)
gemini-2.5-pro Flagship thinking model with 1M token context
gemini-2.5-flash-lite Most cost-effective model
gemini alias for gemini-2.5-flash
xAI grok-code-fast-1 Specialized for coding tasks
grok, xai aliases for grok-code-fast-1

Claude Sonnet 5.5 runs with adaptive thinking at medium effort. Requests opt into Anthropic's server-side refusal fallback, so a diff the safety classifiers decline is retried on a fallback model where one is available instead of failing the commit.

Custom Prompts

AIPR supports custom prompt templates that allow you to tailor merge request descriptions to your team's specific needs. Custom prompts enable you to:

  • Define consistent formatting across your team
  • Include organization-specific requirements
  • Add custom sections and validation rules
  • Provide examples that match your team's standards

For detailed information on creating and using custom prompts, see our Custom Prompts Tutorial.

Contributing

We welcome contributions! See our Contributing Guide for details on:

  • Setting up your development environment
  • Our development workflow
  • Code style guidelines
  • Pull request process
  • Running tests

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for pr-generator-agent 1.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pr-generator-agent 1.8.0
File Size Uploaded Provenance
pr_generator_agent-1.8.0.tar.gz 208.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pr-generator-agent 1.8.0
File Interpreter ABI Platform
pr_generator_agent-1.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 246.9 kB

Release files / pr_generator_agent-1.8.0.tar.gz

Download URL pr_generator_agent-1.8.0.tar.gz
Size 208.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c2734ac3aa2e3d4981512cfbb42d7dee3573570070446072e3e3c07d2d440282
BLAKE2b-256 checksum
How to use checksums
6d4b0ff81798e5ede42d3553d4a3b6b7620550e4fe375a2c8c63eda9f01c31a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / pr_generator_agent-1.8.0-py3-none-any.whl

Download URL pr_generator_agent-1.8.0-py3-none-any.whl
Size 38.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8985219b8e7cae6bcb21fa2ff43ac4fde349537f5c573ce92934f3b9ae35c4ee
BLAKE2b-256 checksum
How to use checksums
bdbc3f524e699f2324ca0f5b4e68f77f949ead5ffc5fb54f1848b7aa8f9aaed2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for pr-generator-agent 1.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page