Skip to content
Notifications
Clear all

Just built a prompt generator that pulls the last 5 PRs as context - holy speed increase

1 Posts
1 Users
0 Reactions
0 Views
(@annak8)
Trusted Member
Joined: 2 weeks ago
Posts: 47
Topic starter   [#22807]

Okay, so I have to share this workflow I just cemented because the efficiency gain is honestly a little ridiculous. 😅 We all know the pain: you jump into a new codebase or even just a new feature area in your own repo, and you're asking the assistant about patterns, or to draft something, but you spend half your prompt just pasting in relevant file paths and explaining recent changes.

I was manually copying PR descriptions and diff highlights like a chump. Not anymore.

My new setup automatically pulls the last 5 merged Pull Requests (title, description, and the list of changed files) and injects them as context at the start of every coding session with my assistant. The difference in contextual awareness is night and day.

Here’s the recipe breakdown:

* **The Core Idea:** Before starting a deep work session, I run a local script that fetches PR context from GitHub. This gives the AI a perfect "what have we been doing lately" briefing.
* **My Toolstack:** I use the GitHub CLI (`gh`) because it's simple and I'm already authenticated. The script is just a shell script that I run in my terminal, and it outputs a beautifully formatted text block.
* **The Workflow:**
1. Navigate to my project repo in terminal.
2. Run my command: `./pr-context.sh` (or I have it aliased to `ctx`).
3. It spits out the last 5 PRs with a clear separator.
4. I copy that entire block and paste it right into my assistant's custom instructions/context window for the session.

The script essence (conceptual, since we don't use code blocks here) is using `gh pr list --state merged --limit 5` to get the numbers, then looping to get each PR's details with `gh pr view --json title,body,files`. I format it cleanly with headers.

**The value is so concrete:**
- No more "we recently added a notification service" preamble. The assistant *sees* that PR #42 was "Add Firebase Cloud Messaging layer" and knows the new files.
- Asking for a new function following "existing patterns" actually works now, because it has the last 5 patterns right there.
- Onboarding to a new area is faster. I just did this for a colleague's project, and I was productive in minutes instead of hours.

It's like giving your assistant a short-term memory of the team's momentum. The prompts are sharper, the outputs are more aligned, and I'm not constantly fighting to provide background.

Has anyone else built similar context-harvesting automations? I'm thinking of expanding this to grab recent Jira tickets or Figma comment threads next. The potential for stitching together *project* context, not just code context, feels huge for avoiding siloed thinking.

happy evaluating



   
Quote