LLM plugin to generate GitHub PR titles/bodies and create PRs using the 'gh' CLI.
Project description
llm-gh-pr
llm plugin to generate GitHub Pull Request titles and bodies based on repository changes and interactively create PRs.
Installation
This plugin requires llm and the GitHub CLI (gh) to be installed.
You can install this plugin using llm install like so:
llm install llm-gh-pr
Ensure you have the GitHub CLI (gh) installed and authenticated:
gh auth login
Usage
From within a Git repository, run:
llm gh-pr
This command will:
- Identify new commits on your current branch compared to the target branch (defaulting to
mainor auto-detected). - Optionally include the
git diffas context. - Send this context to your configured Large Language Model to generate a PR title and body.
- Present the LLM-generated PR title and body for you to review and edit.
Interactive PR Message Editing and Refinement: The plugin provides a powerful interactive interface for reviewing, editing, and refining the LLM-generated PR title and body.
-
Initial Editing: You can directly edit the suggested title and body.
- For the PR Title: Type and press
Enterto submit.Ctrl+CorCtrl+Dto cancel. - For the PR Body:
- To add a NEW LINE: Press
Enter. - To SUBMIT message: Press
Esc, thenEnter(orAlt+Enter/Option+Enter). - To CANCEL: Press
Ctrl+CorCtrl+D.
- To add a NEW LINE: Press
- For the PR Title: Type and press
-
Interactive Chat Refinement (Ctrl+I):
- During the PR body editing phase, press
Ctrl+Ito enter a dedicated chat mode. - In this mode, you can converse with the LLM to iteratively refine the PR body.
- How it works:
- Type your queries, feedback, or additional instructions to the LLM.
- The LLM will respond conversationally and may propose a new version of the PR body.
- If the LLM proposes a new message, you will be prompted to accept (Y) or reject (N) it. Accepting updates the current draft.
- The chat continues until you decide to finalize the message.
- Chat Mode Commands:
/applyorCtrl+A: Use the current draft of the PR body and exit chat mode, returning to the main editor./cancel: Discard any changes made in the chat session and exit, returning the message as it was when you entered chat mode.
- During the PR body editing phase, press
After submitting the message (or if using -y), you'll get a final confirmation before the gh pr create command is executed.
Options
-t,--target-branch: The branch to merge into (e.g.,main,develop). Attempts to auto-detect if not provided.-s,--source-branch: The branch to merge from (your feature branch). Defaults to current branch.--title: Provide PR title directly, skipping LLM generation for it.--body: Provide PR body directly, skipping LLM generation for it.-m MODEL_ID,--model MODEL_ID: Specify which LLM model to use.-S SYSTEM_PROMPT,--system SYSTEM_PROMPT: Custom system prompt for PR generation.--max-commits-chars: Max characters from commit logs to send to LLM (default: 10000).--max-diff-chars: Max characters from git diff to send to LLM (default: 15000).--include-diff: Include git diff along with commit messages as context for the LLM.--draft: Create the PR as a draft.-y,--yes: Skip interactive editing and use the LLM's suggestions directly (still asks for final confirmation).
The System Prompt
The plugin uses a specific system prompt to guide the LLM in generating PR titles and bodies. Here's the default:
You are an expert software developer tasked with writing a clear, concise, and informative GitHub Pull Request.
You will be provided with a list of commit messages and optionally a git diff from the branch to be merged.
Your goal is to create a PR title and a PR body.
**Output Format (STRICT):**
You MUST output the PR title on the first line, followed by "---PR_BODY_SEPARATOR---", and then the PR body.
The PR body should be well-formatted markdown.
Example:
feat: Implement user authentication service
---PR_BODY_SEPARATOR---
This pull request introduces the new user authentication service.
**Key Changes:**
- Added `AuthService` for handling user login and registration.
- Integrated with the existing user database.
- Includes unit tests for all new endpoints.
**Motivation:**
To provide a secure way for users to access the application.
**How to Test:**
1. Run the application.
2. Attempt to register a new user via the `/register` endpoint.
3. Attempt to log in with the new credentials via the `/login` endpoint.
**Related Issues (if any):**
Closes #123
**PR Title Guidelines:**
- Follow conventional commit style (e.g., `feat:`, `fix:`, `docs:`, `chore:`, `refactor:`).
- Be concise, ideally 50-70 characters.
- Summarize the main purpose of the PR.
**PR Body Guidelines:**
- Start with a brief overview of the changes.
- Use markdown for formatting (headings, bullet points, code blocks).
- Clearly explain the "what" and "why" of the changes.
- If applicable, include steps on "how to test" the changes.
- If applicable, mention any related issues (e.g., "Closes #issue_number").
- If the branch contains many small commits, synthesize them into a coherent narrative.
- Focus ONLY on the changes presented. Do not invent features or describe unrelated parts of the project.
- If new files were added, describe their collective purpose or the feature they enable.
Configuration
You can configure llm-gh-pr using llm's configuration system. This allows you to set default values for options like the model, system prompt, and character limits.
To open your llm configuration file, run:
llm config path
Then, edit the config.json file (or config.yaml if you prefer YAML) to add an llm-gh-pr section. For example:
{
"plugins": {
"llm-gh-pr": {
"model": "gpt-4",
"system_pr_generation": "You are a helpful assistant...",
"default_target_branch": "main",
"max-commits-chars": 12000,
"max-diff-chars": 18000
}
}
}
Development
To set up this plugin locally for further development:
- Ensure you have the project code in a local directory.
- It's recommended to use a Python virtual environment:
cd path/to/your/llm-gh-pr python3 -m venv venv source venv/bin/activate # On Linux/macOS # .\venv\Scripts\activate # On Windows
- Install the plugin in editable mode along with its dependencies (including
llmitself if not in the venv):pip install -e .
Now you can modify the code, and the changes will be live when you runllm gh-pr.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_gh_pr-0.1.1.tar.gz.
File metadata
- Download URL: llm_gh_pr-0.1.1.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95bc169da696b33ff9593dd8ef90b86aed110ab0219a66a80171c3da3dec83f5
|
|
| MD5 |
9c376bdd3fb34539b52535f5da9e676d
|
|
| BLAKE2b-256 |
8aed52562d8ec46ddb0ab5e1b5271670b097da32f02619ab9e19b7248ceadf37
|
Provenance
The following attestation bundles were made for llm_gh_pr-0.1.1.tar.gz:
Publisher:
build-and-publish.yml on ShamanicArts/llm-gh-pr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_gh_pr-0.1.1.tar.gz -
Subject digest:
95bc169da696b33ff9593dd8ef90b86aed110ab0219a66a80171c3da3dec83f5 - Sigstore transparency entry: 250452537
- Sigstore integration time:
-
Permalink:
ShamanicArts/llm-gh-pr@c98b0e369b16407f3f70f1d425b34732f2e51a17 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ShamanicArts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-publish.yml@c98b0e369b16407f3f70f1d425b34732f2e51a17 -
Trigger Event:
push
-
Statement type:
File details
Details for the file llm_gh_pr-0.1.1-py3-none-any.whl.
File metadata
- Download URL: llm_gh_pr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ea34080c4ad2f70ae723636f2d30fbb74e8eba237f9bb806dfe81bd5be9c4c6
|
|
| MD5 |
1333c22d28cb1bc1f9e940b0c8789dea
|
|
| BLAKE2b-256 |
96c39c6a7528fcae6455956259995eddcbad1c95f5b0e25751a8f211e436675e
|
Provenance
The following attestation bundles were made for llm_gh_pr-0.1.1-py3-none-any.whl:
Publisher:
build-and-publish.yml on ShamanicArts/llm-gh-pr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_gh_pr-0.1.1-py3-none-any.whl -
Subject digest:
2ea34080c4ad2f70ae723636f2d30fbb74e8eba237f9bb806dfe81bd5be9c4c6 - Sigstore transparency entry: 250452564
- Sigstore integration time:
-
Permalink:
ShamanicArts/llm-gh-pr@c98b0e369b16407f3f70f1d425b34732f2e51a17 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ShamanicArts
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-publish.yml@c98b0e369b16407f3f70f1d425b34732f2e51a17 -
Trigger Event:
push
-
Statement type: