Skip to content

feat(pr-review-toolkit): add local-git-first diff collection - #58

Merged
cblecker merged 4 commits into
mainfrom
pr-review-toolkit-local-git-tooling-plan
Jun 25, 2026
Merged

feat(pr-review-toolkit): add local-git-first diff collection#58
cblecker merged 4 commits into
mainfrom
pr-review-toolkit-local-git-tooling-plan

Conversation

@cblecker

@cblecker cblecker commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add local-git-first diff collection to the pr-review-toolkit skill, with MCP fallback when local git is unavailable
  • Root skill checks out GitHub's refs/pull/N/merge synthetic merge ref, verifies merge parents against PR metadata, builds a compact manifest from git diff, and optionally passes the full merge diff to the workflow
  • Pre-checkout environment checks (repo detection, clean worktree, origin URL) use dynamic context injection — no Bash tool calls needed
  • Post-checkout commands use scoped Bash() permissions with exact syntax (git fetch, git checkout, git rev-parse *, git diff *)
  • Workflow conditionally skips MCP file pagination when local manifest is provided; specialist prompts branch on diff source (full diff in context, Read/Grep on merged checkout, or MCP patch access)
  • reviewMeta.sources tracks manifest source, patch source, merge parent SHAs, and fallback reason for full provenance
  • Version bump 1.6.2 → 1.7.0

Test plan

  • Run /pr-review-toolkit:review-pr on a PR where origin matches the base repo — verify reviewMeta.sources.manifestSource is local-git and working tree is detached HEAD
  • Run on a PR where full diff exceeds 200K chars — verify sources.fullDiffIncluded is false and specialists use Read/Grep
  • Run with a dirty worktree — verify fallback to MCP with reason "worktree has uncommitted changes"
  • Run where origin points to a different repo — verify fallback with reason "origin does not match PR base repository"
  • Run outside a git repo — verify existing MCP collection path works unchanged
  • Run claude plugin validate ./pr-review-toolkit — passes
  • Run markdownlint and skillsaw — no errors

Summary by CodeRabbit

  • New Features

    • Added local git-based PR diff collection with verified merge checkout and richer diff context for reviews.
    • Introduced provenance tracking for review inputs, including source details and fallback information.
  • Documentation

    • Expanded the README and workflow plan with clearer execution flow, permissions, validation scenarios, and fallback behavior.
  • Chores

    • Bumped the toolkit version to 1.7.0.

cblecker added 3 commits June 24, 2026 19:42
Assisted-by: Codex:gpt-5
Add findings from execution model exploration: merge ref approach
using refs/pull/N/merge, preloaded skill with dynamic context
injection, and explicitly scoped Bash commands in skill frontmatter.

Update source adapters, tool access model, and Phase 3a with the
resolved approach. Document 7 evaluated approaches and viability
assessment in capability spike results.

Assisted-by: Claude:claude-opus-4-6
Use an origin-verified local merge ref as the local-git fast path, simplify source provenance, and keep review agents on Read/Grep without shell access.

Assisted-by: Codex:gpt-5
Copilot AI review requested due to automatic review settings June 25, 2026 06:00
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@cblecker, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 45 minutes and 22 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f7b4fb85-1ad7-4aa5-ab0b-d88a11d05969

📥 Commits

Reviewing files that changed from the base of the PR and between 183f7fb and bf935c8.

📒 Files selected for processing (5)
  • pr-review-toolkit/.claude-plugin/plugin.json
  • pr-review-toolkit/README.md
  • pr-review-toolkit/docs/WORKFLOW_REWRITE_PLAN.md
  • pr-review-toolkit/skills/review-pr/SKILL.md
  • pr-review-toolkit/skills/review-pr/review-pr.js
📝 Walkthrough

Walkthrough

The PR-review toolkit now verifies a local PR merge checkout when possible, builds a file manifest and optional full diff from it, and carries source provenance through workflow prompts, review metadata, docs, and validation guidance.

Changes

Local-git PR review provenance

Layer / File(s) Summary
Workflow contract and source model
pr-review-toolkit/docs/WORKFLOW_REWRITE_PLAN.md
The plan adds local-git eligibility checks, MCP fallback parsing, provenance fields, specialist tool scoping, migration phases, and validation matrices for the review flow.
Skill preflight and manifest capture
pr-review-toolkit/skills/review-pr/SKILL.md
The skill parses the PR URL, verifies a detached merge checkout, builds the local manifest, optionally captures a capped full diff, and passes source metadata to the workflow.
Prompt and review metadata plumbing
pr-review-toolkit/skills/review-pr/review-pr.js
The runtime consumes localGitManifest and fullDiff inputs, varies patch instructions by source, builds files from local-git or MCP collection, and writes source provenance into review metadata.
Docs and release metadata
pr-review-toolkit/README.md, pr-review-toolkit/.claude-plugin/plugin.json
The README documents the local-git and MCP flow, permissions, and validation cases, and the plugin manifest version increments to 1.7.0.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • cblecker/claude-plugins#54: Updates the same review-pr workflow contract and shared review-board context that this PR extends with local-git provenance.
  • cblecker/claude-plugins#49: Changes diff-context collection and prompt routing in review-pr.js, which this PR builds on with source-aware patch instructions.
  • cblecker/claude-plugins#55: Also adjusts review-pr.js workflow routing and changed-file handling, overlapping with the new manifest and provenance plumbing.

Poem

🐰 I hopped the merge ref, quick and bright,
With NUL-delimited paths tucked tight.
If MCP hums, I still stay neat,
And stash my sources in every beat.
Review burrows shine tonight ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely captures the main change: introducing local-git-first diff collection for pr-review-toolkit.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pr-review-toolkit-local-git-tooling-plan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a "local-git-first" diff-collection path to the pr-review-toolkit plugin. Before launching the analysis workflow, the review-pr skill now fetches GitHub's synthetic refs/pull/N/merge ref, checks it out as a detached HEAD, verifies the merge's second parent against the PR's headSha, and builds a compact file manifest (plus an optional full diff under a 200K-character cap) that it passes to the workflow via args. When local git is unavailable or verification fails, the workflow falls back to the existing GitHub MCP get_files collection. Provenance (manifest source, patch source, merge SHAs, fallback reason) is recorded in reviewMeta.sources, and specialist prompts branch on the diff source (full diff in context, manifest + Read/Grep on the merged checkout, or MCP focused patch access).

Changes:

  • Skill-side preflight + manifest/diff collection using dynamically injected git env checks and scoped Bash() permissions; results passed to the workflow.
  • Workflow now consumes localGitManifest/fullDiff/sources, derives source-specific specialist instructions, and surfaces provenance in reviewMeta.
  • Documentation (README, WORKFLOW_REWRITE_PLAN) updated and plugin version bumped 1.6.2 → 1.7.0.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pr-review-toolkit/skills/review-pr/SKILL.md Adds git-environment injection, preflight, manifest/full-diff build steps, and new workflow args/Bash() permissions.
pr-review-toolkit/skills/review-pr/review-pr.js Consumes local manifest/full diff, adds patchInstructions, source-aware coverage/notes, and reviewMeta.sources.
pr-review-toolkit/README.md Documents the local-git provider, MCP fallback, permissions, and validation scenarios.
pr-review-toolkit/docs/WORKFLOW_REWRITE_PLAN.md Records the source-adapter design, tool-access model, and capability-spike results.
pr-review-toolkit/.claude-plugin/plugin.json Version bump 1.6.2 → 1.7.0 (minor).

The core merge-ref logic (HEAD^1 = base, HEAD^2 = PR head, git diff HEAD^1 HEAD) and the Bash() pattern coverage are correct, and helper usage (categorizePath, asNumber, signalsForFile) is consistent. Findings are limited to a few documentation/provenance accuracy nits. Note that the skill now mutates the user's working tree (detached-HEAD checkout with no auto-restore) and broadens Bash permissions, which has operational implications worth a human's attention.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pr-review-toolkit/skills/review-pr/SKILL.md Outdated
Comment thread pr-review-toolkit/README.md Outdated
Comment thread pr-review-toolkit/skills/review-pr/review-pr.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pr-review-toolkit/README.md`:
- Around line 203-212: The validation guidance is too broad because the new
local-git-first flow no longer sources all GitHub data from MCP. Update the
test-matrix wording in README to separate MCP-owned validation (metadata/threads
and fallback behavior) from the local-git provenance used for manifest/full-diff
generation in the review flow, and keep the fallback checks aligned with
`reviewMeta.sources` and the `review-pr.js` path.

In `@pr-review-toolkit/skills/review-pr/review-pr.js`:
- Around line 1504-1513: The fallback note in the review summary currently
implies specialists used a merged checkout even when the manifest came from MCP.
Update the notes-building logic in review-pr.js around the
summary.scale/fullDiffIncluded handling so it branches on
sources.manifestSource: keep the merged-checkout wording only for local/git
sources, and for mcp fallback describe the paginated file manifest and parsed
file snippets instead. Ensure the lowSignal and sources.fallbackReason notes
remain unchanged.

In `@pr-review-toolkit/skills/review-pr/SKILL.md`:
- Around line 214-236: The fallback launch path in Launch Analysis Workflow is
dropping the sources metadata that review-pr.js expects. Update the invocation
so the Workflow tool still receives sources when preflight fails, with
mergeCommit/baseSha/headSha empty and fallbackReason preserved, while omitting
only localGitManifest and fullDiff. Keep the fix localized to the Launch
Analysis Workflow call site so config.sources.fallbackReason remains available
at runtime.
- Around line 163-179: The `git diff --numstat -z` parsing guidance in the
review-pr skill is incorrect for renames/copies: it should describe a four-field
NUL-delimited record rather than a `{source} => {destination}` path token.
Update the instructions around the numstat parsing so the parser for rename/copy
entries in the skill’s review output handling treats the destination as the
fourth field (with source as the third), while normal files still use the
standard three-field additions/deletions/path format.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1c4ca3de-a20e-4706-b6a8-58cc4fa93e9f

📥 Commits

Reviewing files that changed from the base of the PR and between 6fad970 and 183f7fb.

📒 Files selected for processing (5)
  • pr-review-toolkit/.claude-plugin/plugin.json
  • pr-review-toolkit/README.md
  • pr-review-toolkit/docs/WORKFLOW_REWRITE_PLAN.md
  • pr-review-toolkit/skills/review-pr/SKILL.md
  • pr-review-toolkit/skills/review-pr/review-pr.js

Comment thread pr-review-toolkit/README.md Outdated
Comment thread pr-review-toolkit/skills/review-pr/review-pr.js
Comment thread pr-review-toolkit/skills/review-pr/SKILL.md Outdated
Comment thread pr-review-toolkit/skills/review-pr/SKILL.md Outdated
The root skill now attempts to check out GitHub's refs/pull/N/merge
synthetic merge ref before launching the workflow, building a compact
manifest from git diff and optionally passing the full merge diff when
it fits a 200K character cap. If local git is unavailable or
verification fails, the workflow falls back to MCP-based collection.

Pre-checkout environment checks (repo detection, clean worktree, origin
URL) use dynamic context injection so they run at skill preprocessing
time without Bash tool calls. Post-checkout commands (fetch, checkout,
rev-parse, diff) use scoped Bash permissions with exact syntax.

The workflow conditionally skips MCP file pagination when a local
manifest is provided, and specialist prompts branch on diff source:
full diff in context, Read/Grep on merged checkout, or MCP patch access.

reviewMeta.sources tracks manifest source, patch source, merge parent
SHAs, and fallback reason for full provenance.

Assisted-by: Claude:claude-opus-4-6
@cblecker
cblecker force-pushed the pr-review-toolkit-local-git-tooling-plan branch from 183f7fb to bf935c8 Compare June 25, 2026 06:19
@cblecker
cblecker merged commit 9d9ef2e into main Jun 25, 2026
11 checks passed
@cblecker
cblecker deleted the pr-review-toolkit-local-git-tooling-plan branch June 25, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants