A tool to generate pull request prompts using git cli commands.
Project description
pr-prompt
Generate pull request prompts (review, description, or custom) from git diffs, commits, and context files.
🚀 Features
🤖 Pull Request Prompt
- Prompt Instructions: Generate review or description prompts, or supply custom instructions.
- Diff: Display differences between the current and base branches.
- Context Patterns: Include matched files in the prompt for additional context.
- Blacklist Patterns: Exclude noisy files (e.g.,
*.lock).
🛠️ Usage & Integration
- Python API: Usable as a library in your own tools.
- CLI Interface: Simple command-line for quick use.
- TOML Configuration: Configure via
pyproject.toml. - Vendor Agnostic: Works with any LLM.
📥 Installation
pip install pr-prompt
📚 Requirements
- Python 3.9+
- git installed and on PATH (or set GIT_PYTHON_GIT_EXECUTABLE)
⚡ Quick Start
🐍 Python API (PrPromptGenerator)
from pr_prompt import PrPromptGenerator
generator = PrPromptGenerator.from_toml() # uses defaults + any TOML config
prompt = generator.generate_review() # compares current HEAD to default base branch
print(prompt)
🖥️ CLI Usage
# Review prompt (default type) to stdout
pr-prompt
# Description prompt to stdout
pr-prompt description
# Custom prompt (requires custom_instructions in TOML config)
pr-prompt custom
# Copy review prompt to clipboard
pr-prompt review | xclip -selection clipboard
Options:
--base-ref / -bbase branch or commit--writesave to.pr_prompt/<type>_<timestamp>.mdinstead of stdout--blacklistrepeatable pattern exclusion--contextrepeatable pattern inclusion--fetch / --no-fetchfetch the base ref before diff. Default:False
🔗 Shell Aliases
Add to your shell config (e.g., ~/.bashrc or ~/.zshrc):
alias review='uvx pr-prompt review | xclip -selection clipboard'
alias desc='uvx pr-prompt description | xclip -selection clipboard'
⚙️ Configuration
🔧 Parameters Reference
PrPromptGenerator / CLI / TOML shared parameters:
blacklist_patterns(list[str])File patterns to exclude from diffs and context file inclusion. Default:["*.lock"]context_patterns(list[str])File patterns to include in prompt (after blacklist filtering). Default:["AGENTS.md"]fetch_base(bool)Fetch base ref before generating diff. Default:Falsediff_context_lines(int)Number of context lines around changes in diffs. Default:999999include_commit_messages(bool)Include commit messages in prompt. Default:Truerepo_path(str | None)Target repo path. Default:cwdremote(str)Git remote name. Default:origindefault_base_branch(str | None)Used when base_ref not passed. Inferred if omitted.custom_instructions(str | None)Used wheninstructionsare not provided in generate_custom.
📜 Parameter Precedence Order
Highest wins (later overrides earlier):
- Internal defaults (dataclass field defaults)
- pyproject.toml / pr_prompt.toml [tool.pr-prompt] values
- Explicit constructor args / CLI flags (mapped to generator args)
- Per-call method arguments (e.g., base_ref passed to generate_review)
Notes:
- If you call
generate_review(base_ref=...), that overrides both default_base_branch and any TOML value. - For
customprompts: ifinstructionsarg omitted,custom_instructions(TOML or constructor) must be set or an error is raised.
🎯 Prompt Types
🔍 Review
Guides the LLM to write a code review (quality, correctness, security, performance, clarity).
📝 Description
Guides the LLM to write a clear PR description (summary, rationale, impact).
🛠️ Custom
Arbitrary instructions. Requires:
- Pass
instructions=...ingenerate_custom, OR - Set
custom_instructionsin constructor/TOML (used when CLI type=custom)
📄 Prompt Example
## Instructions
You are a senior software engineer...
## Pull Request Details
Repository: pr-prompt
Branch: `feature` -> `origin/main`
Commits: Bumped minor
## Context Files
File: `README.md`...
## Changed Files
`src`/
└── `pr_prompt`/
M └── `__init__.py`
## File diffs
Modified `src/pr_prompt/__init__.py`
```diff
-__version__ = "0.3.0"
+__version__ = "0.4.0"
```
⚙️ Using pyproject.toml / pr_prompt.toml
🔧 Default Configuration
[tool.pr-prompt]
blacklist_patterns = ["*.lock"]
context_patterns = ["AGENTS.md"]
fetch_base = false
diff_context_lines = 999999
include_commit_messages = true
# repo_path =
remote = "origin"
# default_base_branch =
# custom_instructions =
🤝 Contributing
Contributions welcome. Please open issues / PRs.
📜 License
MIT License (see LICENSE).
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 pr_prompt-1.2.1.tar.gz.
File metadata
- Download URL: pr_prompt-1.2.1.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7988b83d6b5ad7ffdcd6990817b8214618a44e5eebd54d7785766fdfb708d463
|
|
| MD5 |
1e127fc3e2e3c35732f95751e4907c3b
|
|
| BLAKE2b-256 |
1731c3c02a23bec982f2545527c07734f9318117c2a625a2b95c15e3c5aac41f
|
File details
Details for the file pr_prompt-1.2.1-py3-none-any.whl.
File metadata
- Download URL: pr_prompt-1.2.1-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc5e1d30a9f944ba5ca1d91ecdd5caceaa37734331dcf97273cf4edca3291e07
|
|
| MD5 |
3b46960bc00711211a6ba0ca3f10a1d0
|
|
| BLAKE2b-256 |
25e0cd715a7077b90d5b390da8faf39ff3c0b895178494a89f02897c56680bac
|