Skip to main content

AI-powered Pull Request Description Generator

Project description

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. Azure OpenAI (Default - Highest Priority)

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

    • ANTHROPIC_API_KEY: Anthropic API key
  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
  • --from: Starting commit for range analysis (SHA, branch, tag, etc.)
  • --to: Ending commit for range analysis (defaults to HEAD, requires --from)

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

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)

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)"

Supported AI Models

Choose from multiple AI providers:

Provider Model Notes
Anthropic claude-sonnet-4-6 Claude Sonnet 4.6 (default)
claude-opus-4-8 Claude Opus 4.8
claude-sonnet-4-5-20250929 Claude Sonnet 4.5 (legacy pin)
claude-opus-4-1-20250805 Claude Opus 4.1 (legacy pin)
claude alias for claude-sonnet-4-6
opus, claude-opus aliases for claude-opus-4-8
Azure OpenAI azure/gpt-5-mini default Azure model
azure/gpt-4.1-nano Lightweight model
azure/gpt-5-chat Conversational model
azure/gpt-5-nano Most lightweight model
azure alias for azure/gpt-5-mini
OpenAI gpt-5 Latest GPT-5 model (default)
gpt-5-mini Mid-tier GPT-5 model
gpt-5-nano Lightweight GPT-5 model
openai alias for gpt-5
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

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.

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

pr_generator_agent-1.5.2.tar.gz (113.3 kB view details)

Uploaded Source

Built Distribution

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

pr_generator_agent-1.5.2-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file pr_generator_agent-1.5.2.tar.gz.

File metadata

  • Download URL: pr_generator_agent-1.5.2.tar.gz
  • Upload date:
  • Size: 113.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pr_generator_agent-1.5.2.tar.gz
Algorithm Hash digest
SHA256 c81a90303b801dc9ee9083c3fbc2a1f3a54dcc503ba6381a41fb5d782ea8f4b2
MD5 aa5e9862432da0c3cddd6ca91bb8247f
BLAKE2b-256 7a50ba2b56eb0a0cf35382a51a4be911b6dffec65c18a21b2a68e49b01444c64

See more details on using hashes here.

File details

Details for the file pr_generator_agent-1.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pr_generator_agent-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 40d67c0c74b8a00268b7e933ef8f56316845d153dcd83a6a9f1b98424591adca
MD5 55b8df758a8833ad409bf8a582c29df9
BLAKE2b-256 ffb8fa69441c1d66a54594b2007f41aa1cf5e0c351e56ff828464d5ddfcab22e

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