TIL: How to generate PR descriptions with Aider
One of my least favourite things about writing code is writing PR descriptions. After writing the code, annotating all the types, adding docstrings, writing markdown documentation on usage, it feels like I’m repeating myself yet again. Also I can only look at one page of git diffs a ta time, so writing this extra document is a slow process.
One real-world use case for AI in my workflow addresses this need. I’ve written previously on my AI setup with Aider and Openrouter here. I’ve included this command in my shell to quickly draft an appropriate PR description:
git diff main..HEAD -- ':(exclude)uv.lock' > PULL_REQUEST.md && aider PULL_REQUEST.md \
--read .github/PULL_REQUEST_TEMPLATE.md \
--message-file ~/.aider/message_files/replace_diff_with_pr_description.md
This uses the message I’ve written at ~/.aider/message_files/replace_diff_with_pr_description.md
:
I have given you a git diff.
Can you write a pull request description for this change using the template?
Replace all the content in the file.
Please keep it as short and direct as possible.
Aider is a fantastic tool that will add all the files with context that it
needs. The end result is a new PULL_REQUEST.md
file with a draft of the
description which I can easily edit before posting.
I haven’t done any “prompt engineering” for this, and I’ve only ignored the
uv.lock
file in my python projects. But this is a nice little template that
can be modified easily.