Uses the fantastic gptel to extend forge with LLM-powered pull request description generation.
Inspired by gptel-magit, which provides similar functionality for generating commit messages in magit.
(use-package gptel-forge-prs
:after forge
:config
(gptel-forge-prs-install))In packages.el:
(package! gptel-forge-prs
:recipe (:host github :repo "ArthurHeymans/gptel-forge-prs"))In config.el:
(use-package! gptel-forge-prs
:after forge
:config
(gptel-forge-prs-install))When creating a pull request with forge-create-pullreq, you have two options:
- Press
M-gto generate a PR description from the diff between source and target branches. - Press
M-rto first enter a rationale (explaining why the changes were made), then generate a description with that context.
When you create a pull request, forge automatically inserts any PR template from your repository (e.g., .github/PULL_REQUEST_TEMPLATE.md) into the buffer. gptel-forge-prs detects this existing content and passes it to the LLM as a structure to follow.
The LLM will:
- Keep all section headers from the template unchanged
- Fill in each section with relevant information based on the code diff
- Write ‘N/A’ for sections that don’t apply to the changes
This means you get properly structured PR descriptions that follow your repository’s conventions automatically.
To disable this behavior and generate descriptions without following the buffer template, set gptel-forge-prs-use-buffer-template to nil.
Prompts, model, backend, and PR template behavior can be customised. See customize-group gptel-forge-prs.
gptel-forge-prs-pr-prompt- The system prompt for generating PR descriptions. Two presets are available:
gptel-forge-prs-prompt-defaultandgptel-forge-prs-prompt-conventional(for conventional commit style). gptel-forge-prs-model- Override the gptel model (defaults to
gptel-model). gptel-forge-prs-backend- Override the gptel backend (defaults to
gptel-backend). gptel-forge-prs-use-buffer-template- Whether to use existing buffer content as a template structure (default:
t).