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.5.tar.gz (29.4 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.5-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prgen_cli-0.2.5.tar.gz
  • Upload date:
  • Size: 29.4 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.5.tar.gz
Algorithm Hash digest
SHA256 d2347509c0495b9789e1f477bee3e51dc415e3d33b4b6f6c6ab97417175d256f
MD5 ed359e92dc6ffbf493eba534c98693f8
BLAKE2b-256 140534cec8ca6166fef7328c3acbca21c63cf56d2ff576a1d3d6a5faacd765a9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: prgen_cli-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 30.3 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 eed7d458b06f08d5493bbe1c49fb1973cf618f506303e16e24aa50dd84b281a9
MD5 305dce40c45208cc075fc6a360df341b
BLAKE2b-256 b26bab193ad0619bddc1c6e0fbb5e6e8b3ecb5efa80ca50a5e220929428cb49f

See more details on using hashes here.

Provenance

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