Consolidate PR data pre-fetch across three skills-reviewer workflows - #47392
Merged
Conversation
…flows Extract the duplicate pre-agent-steps from pr-code-quality-reviewer, impeccable-skills-reviewer, and mattpocock-skills-reviewer into a new shared/pr-diff-data-fetch.md component. Add a new pr-data-prefetch.yml (non-agentic) workflow that warms the Actions cache (key: pr-prefetch-<sha>) before reviewer agent jobs start, so all three reviewers can skip their GitHub API calls on cache hit. This reduces the three independent GitHub API fetch sets (~9 calls) to one shared fetch (~3 calls) per PR event, saving ~10k REST API quota/day. Closes #47345 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Consolidate shared GitHub reads across skills-reviewer workflows
Consolidate PR data pre-fetch across three skills-reviewer workflows
Jul 22, 2026
pelikhan
marked this pull request as ready for review
July 22, 2026 20:27
Copilot stopped reviewing on behalf of
pelikhan due to an error
July 22, 2026 20:28
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot could not run the full agentic suite for this review because it was automatically requested on a bot-authored pull request. Request a review from Copilot under Reviewers to retry with the full agentic suite. Improved support for bot-authored pull requests is coming soon.
Introduces a shared “pre-agent” step for fetching PR diff/metadata/review comments and adds a dedicated workflow to prefetch + cache this data once per commit, reducing duplicated GitHub API calls across PR reviewer workflows.
Changes:
- Added reusable shared component to fetch PR diff, PR metadata, and inline review comments with a cache-hit short-circuit.
- Added
pr-data-prefetch.ymlworkflow to warm an Actions cache keyed by head SHA. - Updated reviewer workflows to import the shared prefetch component instead of duplicating shell steps.
Show a summary per file
| File | Description |
|---|---|
| .github/workflows/shared/pr-diff-data-fetch.md | Adds shared pre-agent prefetch logic with cache-hit detection and standardized output files. |
| .github/workflows/pr-data-prefetch.yml | New workflow to prefetch PR data on ready_for_review and save it to Actions cache. |
| .github/workflows/pr-code-quality-reviewer.md | Switches from inline pre-agent steps to importing the shared prefetch component. |
| .github/workflows/pr-code-quality-reviewer.lock.yml | Regenerated lockfile reflecting the new shared import and prompt changes. |
| .github/workflows/mattpocock-skills-reviewer.md | Switches from inline pre-agent steps to importing the shared prefetch component. |
| .github/workflows/mattpocock-skills-reviewer.lock.yml | Regenerated lockfile reflecting the new shared import and updated env/run blocks. |
| .github/workflows/impeccable-skills-reviewer.md | Switches from inline pre-agent steps to importing the shared prefetch component. |
| .github/workflows/impeccable-skills-reviewer.lock.yml | Regenerated lockfile reflecting the new shared import and updated env/run blocks. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 8/8 changed files
- Comments generated: 6
- Review effort level: Low
Comment on lines
+62
to
+66
| - name: Save PR data to cache | ||
| uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | ||
| with: | ||
| key: pr-prefetch-${{ github.event.pull_request.head.sha }} | ||
| path: /tmp/gh-aw/agent |
Comment on lines
+32
to
+36
| if [ -f /tmp/gh-aw/agent/pr-diff.patch ] && [ -f /tmp/gh-aw/agent/pr-meta.json ] && [ -f /tmp/gh-aw/agent/pr-review-comments.json ]; then | ||
| LINES=$(wc -l < /tmp/gh-aw/agent/pr-diff.patch) | ||
| COMMENT_COUNT=$(jq 'length' /tmp/gh-aw/agent/pr-review-comments.json) | ||
| echo "Cache hit: using pre-fetched PR data (${LINES} diff lines, ${COMMENT_COUNT} review comments)" | ||
| else |
| COMMENT_COUNT=$(jq 'length' /tmp/gh-aw/agent/pr-review-comments.json) | ||
| echo "Cache hit: using pre-fetched PR data (${LINES} diff lines, ${COMMENT_COUNT} review comments)" | ||
| else | ||
| { gh pr diff "$PR_NUMBER" --repo $EXPR_GITHUB_REPOSITORY \ |
Comment on lines
+44
to
+45
| gh pr view "$PR_NUMBER" \ | ||
| --repo $EXPR_GITHUB_REPOSITORY \ |
| COMMENT_COUNT=$(jq 'length' /tmp/gh-aw/agent/pr-review-comments.json) | ||
| echo "Cache hit: using pre-fetched PR data (${LINES} diff lines, ${COMMENT_COUNT} review comments)" | ||
| else | ||
| { gh pr diff "$PR_NUMBER" --repo $EXPR_GITHUB_REPOSITORY \ |
Comment on lines
+42
to
+43
| || true; } | head -n "${PR_DIFF_MAX_LINES}" > /tmp/gh-aw/agent/pr-diff.patch | ||
| LINES=$(wc -l < /tmp/gh-aw/agent/pr-diff.patch) |
Contributor
|
🎉 This pull request is included in a new release. Release: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pr-code-quality-reviewer,impeccable-skills-reviewer, andmattpocock-skills-reviewereach independently fetched the same PR diff/metadata/comments on everyready_for_reviewevent — 9 API calls where 3 suffice, consuming ~40% of the repo's daily REST API quota (~10k calls/day).Changes
shared/pr-diff-data-fetch.md(new): Sharedpre-agent-stepscomponent that fetches PR diff, metadata, and review comments. Handles bothpull_requestandslash_commandevents via${{ github.event.issue.number || github.event.pull_request.number }}.Three reviewer workflows: Replaced identical inline
pre-agent-stepsblocks withimports: - shared/pr-diff-data-fetch.md. Thecache:keys and skip-if-cached logic are unchanged.pr-data-prefetch.yml(new): A non-agentic plain GitHub Actions workflow on the samepull_request: [ready_for_review]trigger that fetches PR data and saves it toactions/cachewith keypr-prefetch-<sha>. Because it has no AI engine or containers, it completes in ~30–60 s — before the reviewer workflows finish their activation jobs and reach the cache-restore step in their agent jobs.Cache warm-up flow
On cache miss (e.g., first run before prefetch saves), the shared component falls back to fetching as before. Subsequent runs on the same SHA and re-triggers always hit cache.