Skip to content

refactor(review-pr): delegate diff collection to workflow agents - #49

Merged
cblecker merged 1 commit into
mainfrom
refactor/review-pr-delegate-diff-collection
Jun 18, 2026
Merged

refactor(review-pr): delegate diff collection to workflow agents#49
cblecker merged 1 commit into
mainfrom
refactor/review-pr-delegate-diff-collection

Conversation

@cblecker

@cblecker cblecker commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Delegate diff collection to agents: Each workflow agent now collects its own patches via diffPreamble() — local agents use git diff, remote agents use GitHub MCP get_files/get_file_contents. Eliminates shuttling large diffs through the orchestration layer.
  • Move agent selection to orchestrator: Replace regex-based selectAgents() in the workflow with intelligent selection by the orchestrator using git diff --name-status and judgment about which specialist agents are warranted.
  • Simplify workflow args: Pass baseRef and agents instead of changedFiles/excludedFileSummary — agents handle file filtering (vendor, generated) themselves.

Test plan

  • Run /review-pr on a local PR (where isLocal is true) and verify agents collect diffs via git
  • Run /review-pr on a remote PR (where isLocal is false) and verify agents collect diffs via GitHub MCP
  • Verify agent selection works correctly — code-reviewer always runs, optional agents selected based on file changes
  • Confirm vendor and generated files are filtered by agents, not the orchestrator
  • Run claude plugin validate ./pr-review-toolkit — passes
  • Run node -c pr-review-toolkit/skills/review-pr/review-pr.js — no syntax errors
  • Run markdownlint on SKILL.md — no errors

Summary by CodeRabbit

  • Refactor
    • Streamlined the PR review workflow with more deterministic agent selection.
    • Improved local vs. remote review context by using merge-base-aware diff collection.
    • Refined diff information gathering for review prompts, including stronger filtering to skip vendor and common generated files.
  • Documentation
    • Updated the PR review skill instructions to restrict allowed tooling and enforce constrained data processing.
  • Updates
    • Bumped the plugin version to 1.2.0.

Copilot AI review requested due to automatic review settings June 17, 2026 23:31
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 14eac812-1598-4bbc-917d-72f17eefeb0d

📥 Commits

Reviewing files that changed from the base of the PR and between e79a9ee and 13a788c.

📒 Files selected for processing (3)
  • pr-review-toolkit/.claude-plugin/plugin.json
  • pr-review-toolkit/skills/review-pr/SKILL.md
  • pr-review-toolkit/skills/review-pr/review-pr.js
✅ Files skipped from review due to trivial changes (1)
  • pr-review-toolkit/.claude-plugin/plugin.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • pr-review-toolkit/skills/review-pr/review-pr.js
  • pr-review-toolkit/skills/review-pr/SKILL.md

📝 Walkthrough

Walkthrough

The review-pr skill is refactored to remove in-skill file categorization and diff fetching. SKILL.md tightens tool permissions, rewrites PR metadata and locality detection, and streamlines Phase 1 to pass only headSha, baseRef, isLocal, and agents to the workflow. review-pr.js introduces diffPreamble() to embed diff collection instructions per agent, and agent selection shifts from changedFiles-derived logic to config.agents directly. plugin.json is bumped to 1.2.0.

Changes

review-pr diff collection and agent orchestration refactor

Layer / File(s) Summary
SKILL.md tool constraints and Phase 1 orchestration
pr-review-toolkit/skills/review-pr/SKILL.md
Restricts allowed-tools to git diff --name-status *, adds a Constraints section enforcing git/jq/MCP-only data processing. Rewrites Phase 1 to extract head.sha/base.ref and compute isLocal via git rev-parse HEAD vs headSha, adds git fetch origin <baseRef> for merge-base readiness, selects optional agents from git diff --name-status origin/<baseRef>...HEAD with explicit inclusion rules, and removes in-skill file categorization and changedFiles/excludedFileSummary construction.
diffPreamble() implementation and agent prompt assembly
pr-review-toolkit/skills/review-pr/review-pr.js, pr-review-toolkit/.claude-plugin/plugin.json
Introduces diffPreamble() which generates local-vs-remote-aware diff collection instructions with shared filename filter rules. Updates main execution to read agents from config.agents instead of deriving them via selectAgents()/changedFiles. Each parallel agent prompt is composed as diffPreamble() + PROMPTS[name]. Updates code-reviewer agent text to reference diff collected in setup section. Plugin version bumped to 1.2.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • cblecker/claude-plugins#45: Introduced the workflow-based review-pr orchestration in review-pr.js that this PR directly refactors.
  • cblecker/claude-plugins#47: Added excludedFileSummary-driven context and large-PR file filtering in review-pr.js, which this PR's diffPreamble() and simplified agent selection supersedes.

Poem

🐰 With diffPreamble hops, the agents now align,
No file sifting in the skill—just a tidy design!
Each reviewer gets their setup, constraints run tight,
1.2.0 marks the refactor done right! ✨

🚥 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 accurately and concisely describes the main refactoring objective: delegating diff collection responsibilities from the orchestrator to workflow agents, which is the primary focus of all three modified files.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/review-pr-delegate-diff-collection

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Biome (2.5.0)
pr-review-toolkit/skills/review-pr/review-pr.js

File contains syntax errors that prevent linting: Line 562: Illegal return statement outside of a function


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 and usage tips.

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 refactors the /review-pr workflow so each review agent collects its own diff context (via diffPreamble()), while the orchestrator selects which agents to run based on git diff --name-status, reducing large diff payloads passed through the workflow layer.

Changes:

  • Moved diff collection responsibilities into workflow agents via a new diffPreamble() prompt block.
  • Replaced in-workflow regex agent selection with orchestrator-provided agents.
  • Updated skill documentation and bumped plugin version to 1.2.0.

Reviewed changes

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

File Description
pr-review-toolkit/skills/review-pr/SKILL.md Updates allowed tools and rewrites Phase 1 to fetch base ref + select agents via git diff --name-status.
pr-review-toolkit/skills/review-pr/review-pr.js Removes centralized diff/context building; adds diffPreamble() and switches to orchestrator-provided agents.
pr-review-toolkit/.claude-plugin/plugin.json Bumps plugin version to 1.2.0.

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

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

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 3

🤖 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/skills/review-pr/review-pr.js`:
- Around line 533-537: The code does not validate that config.agents exists
before accessing its .length property, which will crash if config.agents is
undefined, and it does not verify that agent names in config.agents have
corresponding prompts in the PROMPTS object before dispatching them. Add a guard
to ensure config.agents is provided with a fallback to an empty array if
missing, then filter the selected array to only include agent names where
PROMPTS[name] is defined before passing them to the parallel function. This
prevents crashes and ensures only valid agents with defined prompts are
executed.
- Around line 60-63: The remote collection instructions currently use
get_file_contents which loses the actual diff-hunk context and fails on deleted
or renamed files. Replace the instruction that uses get_file_contents with
instructions to retrieve and use patch hunks or diffs from the pull_request_read
method instead. This will preserve the true diff context, properly handle file
changes (including deletions and renames), and ensure line comments map
correctly to the actual PR diff lines.

In `@pr-review-toolkit/skills/review-pr/SKILL.md`:
- Line 13: The Bash skill definition in this file is too restrictive and only
permits `git diff --name-status`, but review-pr.js now requires running full
`git diff` commands with branch references and file filters (e.g., `git diff
origin/<baseRef>...HEAD -- <files>`). Update the Bash skill definition to allow
the complete git diff syntax needed for patch collection by removing the
restrictive `--name-status` flag constraint and permitting the full git diff
command with branch comparisons and file path arguments.
🪄 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: Repository: cblecker/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 80c4c1b0-6e52-450b-9099-f8046db1b351

📥 Commits

Reviewing files that changed from the base of the PR and between baaf598 and ac807bb.

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

Comment thread pr-review-toolkit/skills/review-pr/review-pr.js
Comment thread pr-review-toolkit/skills/review-pr/review-pr.js Outdated
Comment thread pr-review-toolkit/skills/review-pr/SKILL.md
@cblecker
cblecker force-pushed the refactor/review-pr-delegate-diff-collection branch from ac807bb to aeae0cc Compare June 18, 2026 00:20
@cblecker
cblecker requested a review from Copilot June 18, 2026 00:27

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread pr-review-toolkit/skills/review-pr/review-pr.js Outdated
@cblecker
cblecker force-pushed the refactor/review-pr-delegate-diff-collection branch from aeae0cc to e79a9ee Compare June 18, 2026 00:55
@cblecker
cblecker requested a review from Copilot June 18, 2026 00:55

@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: 1

🤖 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/skills/review-pr/review-pr.js`:
- Line 542: The prompt assembly is concatenating PROMPTS[name] before
diffPreamble(), but the role prompt expects setup instructions to appear above
it. Reverse the order of concatenation in the prompt assignment so that
diffPreamble() comes first, followed by PROMPTS[name], to match the expectation
referenced in the role prompt definition.
🪄 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: 9829e394-648b-4792-885f-12f091499876

📥 Commits

Reviewing files that changed from the base of the PR and between ac807bb and e79a9ee.

📒 Files selected for processing (3)
  • pr-review-toolkit/.claude-plugin/plugin.json
  • pr-review-toolkit/skills/review-pr/SKILL.md
  • pr-review-toolkit/skills/review-pr/review-pr.js
✅ Files skipped from review due to trivial changes (1)
  • pr-review-toolkit/.claude-plugin/plugin.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • pr-review-toolkit/skills/review-pr/SKILL.md

Comment thread pr-review-toolkit/skills/review-pr/review-pr.js

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

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

Comment thread pr-review-toolkit/skills/review-pr/SKILL.md Outdated
Comment thread pr-review-toolkit/skills/review-pr/SKILL.md Outdated
Move diff fetching from the orchestrator into each workflow agent via a
diffPreamble() that generates setup instructions. Agents now collect
their own patches using git (local) or GitHub MCP (remote), eliminating
the token cost of shuttling large diffs through the orchestration layer.

Agent selection moves from regex matching in the workflow to the
orchestrator, which can evaluate whether each specialist agent is
warranted based on the nature of the changes.

Assisted-by: Claude:claude-opus-4-6
@cblecker
cblecker force-pushed the refactor/review-pr-delegate-diff-collection branch from e79a9ee to 13a788c Compare June 18, 2026 06:43
@cblecker
cblecker requested a review from Copilot June 18, 2026 06:44

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread pr-review-toolkit/skills/review-pr/SKILL.md
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