A while back, I wrote a Medium article on writing effective pull request descriptions, focusing on how thoughtful, well-structured descriptions can make code reviews more efficient for teams. As part of improving our internal workflow, I created detailed guidelines for my team, and we saw a big improvement in our PR process.
But I wanted to take it a step further. Instead of writing these descriptions manually every time, I thought: why not automate it using AI? So I built a small tool that does just that—it generates PR descriptions automatically based on the git diff, guidelines, and any templates in your repo.
What Does the Tool Do?
Here’s the basic rundown:
- It looks at the changes (diff) in your current branch and uses that information to summarize what’s happening.
- It checks for a
.pr_guidelines.md
file in your repo, which contains any PR description guidelines, and incorporates them into the output. - If your project has a pull request template (located at
.github/pull_request_template.md
), the tool will fill that in as well. - It uses OpenAI models (from GPT-4 to GPT-3) to generate a clear, concise PR description. More advanced models = better descriptions.
No more repetitive, manual work on writing out PR descriptions. The tool handles it all with a simple command.
How It Works
It’s pretty straightforward to use. Once you’ve got the tool set up and configured, just run:
npx prghost
Here’s what happens behind the scenes:
- The tool grabs the current branch name and repo info.
- It gets (or creates) the pull request on GitHub.
- It asks if there’s any extra context you want to add to help make the description more informative.
- It fetches the PR diff and combines it with the guidelines and PR template.
- Using that info, it generates a description through OpenAI and automatically updates the PR.
AI Model Priorities
The tool uses a prioritized list of AI models, starting with the most advanced (GPT-4 and GPT-4-Turbo). If those models are available, you’ll get more context-aware and polished descriptions. But it falls back to other models if needed, like GPT-3.5 and GPT-3, which still do a solid job.
Why I Built This
After refining how our team writes PR descriptions, I saw an opportunity to remove some of the repetitive manual work. Automating the process with AI not only speeds things up, but it also ensures descriptions follow our guidelines, and are more standardized across the team. There are other tools and GitHub Actions that can help with PR automation, but for me, it's important to stick to our custom guidelines and templates when creating descriptions. This tool is a small step towards making our PR process faster and more efficient, especially for larger projects.
Give It a Try
If you think this might save you time or make your workflow smoother, feel free to check it out on GitHub. You can fork it, customize it for your team, or just use it as-is to make your PR descriptions a little less painful to write.
Top comments (0)