Skip to main content

prgen

Generate a pull request title and description from git diff and commit history.

prgen CLI help

Author: Jean Paul Fernandez · github.com/jpxoi/prgen

Licensed under the GNU General Public License v3.0 (GPL-3.0-only).

Requirements

  • Python 3.10+
  • git on your PATH
  • One of:
    • OpenAI API access
    • Google Gemini API access
    • A local or remote Ollama server

Install

From PyPI:

pip install prgen-cli
# or
uv tool install prgen-cli

From a clone:

uv sync

Run the CLI with:

prgen --help

What It Does

prgen compares HEAD against a base ref, collects:

  • git diff <base>...HEAD
  • git log <base>..HEAD

It sends that context to an LLM and prints:

  • a PR title from <summary>...</summary>
  • a PR description from <body>...</body>

If the model does not return those tags, prgen prints the raw model output instead.

Providers

prgen supports three backends:

  • openai
  • gemini
  • ollama

--provider auto is the default.

In auto mode:

  • Gemini is chosen when GOOGLE_API_KEY is available
  • otherwise OpenAI is chosen when OPENAI_API_KEY is available
  • if neither key is configured, prgen exits with an error

Ollama is always explicit:

  • use --provider ollama
  • also pass --model <name>
  • --tier presets do not apply to Ollama

Quick Start

OpenAI:

prgen config set OPENAI_API_KEY sk-...
prgen

Gemini:

prgen config set GOOGLE_API_KEY your-key
prgen --provider gemini

Ollama:

prgen --provider ollama --model llama3.1:8b

If the Ollama model is missing locally, let prgen pull it:

prgen --provider ollama --model llama3.1:8b --pull

Configuration

Configuration lives in ~/.config/prgen/config.json.

If XDG_CONFIG_HOME is set, prgen uses:

$XDG_CONFIG_HOME/prgen/config.json

You can manage the file with:

prgen config
prgen config show
prgen config path

Supported persisted keys:

  • OPENAI_API_KEY
  • GOOGLE_API_KEY
  • OLLAMA_HOST
  • base
  • provider
  • tier

Notes:

  • OPENAI_API_KEY and GOOGLE_API_KEY are treated as secrets
  • OLLAMA_HOST is not secret and is merged into the environment if set
  • base, provider, and tier are optional CLI defaults
  • model and context are not persisted in config

Examples:

prgen config
prgen config set OPENAI_API_KEY sk-...
prgen config set GOOGLE_API_KEY your-key
prgen config set OLLAMA_HOST http://127.0.0.1:11434
prgen config set base origin/main
prgen config set provider ollama
prgen config set tier pro
prgen config unset OLLAMA_HOST
prgen config show

To read a secret value from stdin:

prgen config set OPENAI_API_KEY - < key.txt

Defaults

Built-in defaults:

Option Default Notes
--repo, -C current directory Uses the current git repo unless you point elsewhere
--base origin/main The ref must resolve locally
--provider auto Prefers Gemini over OpenAI when both keys exist
--tier default Used only for OpenAI and Gemini
--model unset Overrides tier selection; required for Ollama
--context none Extra text merged into the prompt
--pull false Only relevant for Ollama
--verbose, -v false Print usage, git size, and API response headers to stderr

Config-file defaults apply only when you omit the matching flag:

  • base
  • provider
  • tier

Explicit flags always win over the config file.

Current model presets:

  • OpenAI default: gpt-5-mini
  • OpenAI pro: gpt-5.4
  • Gemini default: gemini-3-flash-preview
  • Gemini pro: gemini-3.1-pro-preview

Usage

Basic usage:

prgen

Pick a different base:

prgen --base main

Run against another repository:

prgen -C ~/src/my-project

Override the model directly:

prgen --provider openai --model gpt-5.4
prgen --provider gemini --model gemini-3.1-pro-preview
prgen --provider ollama --model mistral-small3.1

Add extra context:

prgen --context "Focus on customer-facing impact and rollout notes."

Inspect API response headers (useful on rate-limit errors):

prgen --provider openai --verbose

With --verbose, prgen prints to stderr:

  • provider, model, git base, commit count, and prompt size
  • token usage (OpenAI / Gemini) or eval counts (Ollama)
  • HTTP status and useful response headers (rate limits, request id)

Transport headers are omitted. Authorization values and API keys in URLs are redacted.

Behavior Notes

  • prgen validates that --base resolves before generating anything
  • if there are no commits and no file changes vs the base ref, prgen exits with an error
  • when --provider ollama --pull is used, prgen can download the model automatically
  • when stderr is a TTY, loading states and Ollama downloads use Rich UI output
  • --verbose prints usage and API response headers after the call (or after an error), including rate-limit metadata when the provider sends it

Development

Install local dependencies:

uv sync

Format and lint:

uv run ruff format .
uv run ruff check .

Run from the repo without installing globally:

uv run prgen --help

Install the local checkout as a global tool:

uv tool install .
# or
pipx install .

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prgen_cli-0.4.0.tar.gz (34.9 kB view details)

Uploaded Source

Built Distribution

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

prgen_cli-0.4.0-py3-none-any.whl (36.9 kB view details)

Uploaded Python 3

File details

Details for the file prgen_cli-0.4.0.tar.gz.

File metadata

  • Download URL: prgen_cli-0.4.0.tar.gz
  • Upload date:
  • Size: 34.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for prgen_cli-0.4.0.tar.gz
Algorithm Hash digest
SHA256 4d7fad9e9ce6710cacd07daa94b7edff3aa58e1f0367cf0905cc0e35a010668d
MD5 3748012c8e388e82cfae7357a051135d
BLAKE2b-256 1f9b04aa0c7a1617dd7ae831bcb0659bbef05a180629e7085ba1346ed9ba9d03

See more details on using hashes here.

Provenance

The following attestation bundles were made for prgen_cli-0.4.0.tar.gz:

Publisher: publish.yml on jpxoi/prgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file prgen_cli-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: prgen_cli-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 36.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for prgen_cli-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0efd4c854baa2b3897aa97476a5031aabbbfb15d1d0df8e117cd52c995c3a403
MD5 4155c8c1e70e74aea750f1be9bb3966c
BLAKE2b-256 a6c53d7071f34365761c76e1706e7f57e49cdf99c60cca2d7593f9cbed0bd8f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for prgen_cli-0.4.0-py3-none-any.whl:

Publisher: publish.yml on jpxoi/prgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.4.1

2 files

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.1

2 files

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