Skip to main content

Generate PR titles and descriptions from git diff

Project description

prgen

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

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

Licensed under the GNU General Public License v3.0 (GPL-3.0-only): you may share and modify this program under those terms; see the license file for full conditions.

Requirements

  • Python 3.10+
  • git on your PATH (install Git and ensure git works in a terminal)

Install

From PyPI, install the prgen-cli package; the prgen command is what you run in the terminal.

From PyPI:

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

From a clone (installs all dependencies):

uv sync

Formatting / lint (see [tool.ruff] in pyproject.toml):

uv run ruff format .
uv run ruff check .

Setup

Store settings in ~/.config/prgen/config.json using prgen config (interactive prompts, or prgen config set …). Supported fields:

  • OPENAI_API_KEY — OpenAI API key (also merged into the environment when you run prgen, if not already set)
  • GOOGLE_API_KEY — Google AI Studio / Gemini API key (same behavior)
  • base — optional default for --base (see Defaults below)
  • provider — optional default for --provider
  • tier — optional default for --tier

Override the config directory with XDG_CONFIG_HOME (file is $XDG_CONFIG_HOME/prgen/config.json).

Defaults

Defaults apply to the main prgen command (generating a PR summary), not to prgen config … subcommands.

Built-in CLI defaults (no config file)

If you do not pass a flag and the key is not set in config.json, prgen uses:

What Default Meaning
Git repo current directory Diff and log are for the repo you run from. Use -C / --repo for another tree.
--base origin/main Compare HEAD to this ref (git diff / git log vs merge base). The ref must exist locally (e.g. run git fetch origin or use a local branch like main).
--provider auto Pick a backend from your API keys: Gemini if GOOGLE_API_KEY is set, otherwise OpenAI if OPENAI_API_KEY is set. If neither is set, prgen exits with an error until you configure keys.
--tier default Cheaper/faster model preset. pro selects a stronger model for the chosen provider.
--model (unset) Use the model for the current --tier (see presets in the source under defaults.py). --model ID overrides --tier entirely.
--context none Extra text merged into the prompt; the literal string none means “no extra context” unless you change it.

Optional overrides from config.json

If base, provider, or tier appear in config.json, they replace the built-in defaults only when you do not pass the matching flag.

  • Example: base in JSON is main, and you run prgen with no --base → effective base is main.
  • Example: same config, but you run prgen --base origin/main--base wins; the file is ignored for that run.

--model and --context are not read from the JSON file; only base, provider, and tier are.

Summary

  • Config file fills in --base, --provider, and --tier when those flags are omitted.
  • Explicit flags always override the file.
  • auto chooses Gemini vs OpenAI from which API keys are available (see --provider above).

Set keys from the CLI

Writes go to ~/.config/prgen/config.json (see prgen config path). Allowed keys: OPENAI_API_KEY, GOOGLE_API_KEY, base, provider, tier.

prgen config                    # wizard: API keys + base, provider, tier (Rich prompts)
prgen config set OPENAI_API_KEY sk-...
prgen config set GOOGLE_API_KEY - < key.txt    # value read from stdin
prgen config unset OPENAI_API_KEY
prgen config show                              # safe summary (keys as set/unset; colors if TTY)
prgen config path                              # print path to the file

Run on another project

Use -C (same idea as git -C) so you can run prgen from anywhere:

prgen -C ~/src/my-application

If prgen is not on your PATH, invoke it via uv from the prgen repo:

uv run --directory /path/to/prgen prgen -C ~/src/my-application

Install globally (optional)

From the prgen project directory:

uv tool install .
# or
pipx install .

Then prgen is available in new shells (ensure your tool install bin directory is on PATH).

Options

See prgen --help for all flags. In addition to Defaults:

  • If there is no diff and no commits compared to --base, prgen exits with an error (nothing to summarize).

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

prgen_cli-0.2.3.tar.gz (29.2 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.2.3-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prgen_cli-0.2.3.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for prgen_cli-0.2.3.tar.gz
Algorithm Hash digest
SHA256 272ee9bc1257ded24e44af35139e9745ca0ee5b8fcf757d32a0629ccd0f64ccc
MD5 802eee521effe480851b68db2e32b407
BLAKE2b-256 5776c966e903e29953cb81c4a1c2b4068dd4cf56e7dd123d13d4ba5820e848c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for prgen_cli-0.2.3.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.2.3-py3-none-any.whl.

File metadata

  • Download URL: prgen_cli-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for prgen_cli-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3118862a0512ebddf2c81a98f037f08178855c87fb8350f6a9112366b134ebcf
MD5 256750fa1a9d1dd5fe96ee5dd4145cdf
BLAKE2b-256 d03901a0246fcc930d6668366ef87973a4e89105e45288d9a361747f1d620611

See more details on using hashes here.

Provenance

The following attestation bundles were made for prgen_cli-0.2.3-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.

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