Skip to content

feat(review-pr): semantic contextualization against existing review threads - #51

Merged
cblecker merged 1 commit into
mainfrom
feat/review-pr-contextualize-threads
Jun 19, 2026
Merged

feat(review-pr): semantic contextualization against existing review threads#51
cblecker merged 1 commit into
mainfrom
feat/review-pr-contextualize-threads

Conversation

@cblecker

@cblecker cblecker commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replaces the deterministic string-match dedup with a Contextualize workflow phase that uses model-driven agents to classify findings against existing PR review threads
  • Fetch agent retrieves all review threads with full reply chains and the current user's identity
  • Classify agent compares each finding against threads — marks as new, duplicate (fully covered), or partial_overlap (rescores based on what we found that others missed)
  • Verify agent (re-reviews only) checks whether resolved threads from our previous review were adequately addressed — fixed, pushed back, or unaddressed
  • Adds a standardized presentation template in SKILL.md with numbered findings, grouped by category
  • Trims ~1000 tokens from agent prompts by removing dead-weight sections (When to invoke, Structured Output Requirements, Anthropic-specific patterns, personality coaching)
  • Fixes severity/confidence conflation in code-reviewer prompt, aligns silent-failure-hunter severity labels to schema enum
  • Adds required arrays to all new schemas, renames isReReview to hasOwnResolvedThreads
  • Bumps plugin version to 1.3.0

Test plan

  • Run claude plugin validate ./pr-review-toolkit
  • Run npx markdownlint-cli2 on pr-review-toolkit/**/*.md
  • Run /pr-review-toolkit:review-pr on a PR with no existing comments — verify all findings show status: "new"
  • Run on a PR with existing review threads — verify findings are classified as new/duplicate/partial_overlap
  • Run on a PR where we previously left comments — verify thread verifications appear
  • Verify no Python/jq/awk scripts are spawned during the review

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced PR review workflow now classifies findings as new, duplicate, or partial overlap.
    • Added a context-aware Contextualize step that links findings to existing review threads and includes prior review status when available.
    • Phase 3 review output now supports guided selection (including presets) and improved severity grouping.
  • Improvements

    • More consistent, structured review responses with tighter confidence/severity mapping and improved handling of resolved threads.
    • Updated skill configuration to strengthen output/format constraints.
  • Chores

    • Updated plugin version to 1.3.0.

Copilot AI review requested due to automatic review settings June 18, 2026 21:43
@coderabbitai

coderabbitai Bot commented Jun 18, 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 51 minutes and 5 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 refill rate.

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

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: a250cb12-9efc-468a-bb69-057266ea189e

📥 Commits

Reviewing files that changed from the base of the PR and between 0c95b1e and b7bc82b.

📒 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
📝 Walkthrough

Walkthrough

Adds a "Contextualize" phase to the review-pr skill. After the existing Analyze phase, the skill now fetches existing PR review threads, classifies each finding as new, duplicate, or partial_overlap via agent calls against three new JSON schemas, enriches findings accordingly, and optionally verifies resolved threads. SKILL.md is updated to document the new Phase 3 contract and user-facing presentation template. Sub-agent prompts receive minor adjustments. The plugin manifest is bumped to 1.3.0.

Changes

review-pr Contextualize Phase

Layer / File(s) Summary
Contextualization schemas, phase metadata, and SKILL.md contract
pr-review-toolkit/skills/review-pr/review-pr.js, pr-review-toolkit/skills/review-pr/SKILL.md
Adds the Contextualize phase to meta.phases and inserts THREAD_SCHEMA, CLASSIFICATION_SCHEMA, and VERIFICATION_SCHEMA constants. Updates SKILL.md to forbid ad-hoc scripts and require direct JSON reading. Documents the full Phase 3 JSON response contract (findings enrichment fields, positiveObservations, threadVerifications, reviewMeta), the structured AskUserQuestion presentation template, score-resolution rules, and selection modes.
Contextualize phase execution
pr-review-toolkit/skills/review-pr/review-pr.js
Implements the three-step Contextualize phase: fetches existing review threads, classifies findings as new/duplicate/partial_overlap, enriches finding objects with matchedThreadId, existingCoverage, delta, and adjusted scores while computing reviewMeta counters, then optionally verifies resolved threads and appends threadVerifications.
Sub-agent prompt adjustments and version bump
pr-review-toolkit/skills/review-pr/review-pr.js, pr-review-toolkit/.claude-plugin/plugin.json
Removes the code-reviewer "When to invoke" block and adjusts severity-grouping text; adds a no-suppression rule and structured "Your Output Format" section to silent-failure-hunter while removing the Sentry error-ID mention; shortens pr-test-analyzer tail instructions; updates comment-analyzer and type-design-analyzer output guidance with confidence thresholds; bumps manifest to 1.3.0.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Skill as review-pr skill
  participant ThreadAgent as Thread-fetch agent
  participant ClassifyAgent as Classification agent
  participant VerifyAgent as Verification agent

  User->>Skill: invoke review-pr
  rect rgba(100, 149, 237, 0.5)
    note over Skill: Phase: Analyze
    Skill->>Skill: run sub-agents (code-reviewer, silent-failure-hunter, etc.)
    Skill->>Skill: collect allFindings
  end
  rect rgba(60, 179, 113, 0.5)
    note over Skill: Phase: Contextualize
    Skill->>ThreadAgent: fetch existing review threads (THREAD_SCHEMA)
    ThreadAgent-->>Skill: threads[]
    alt threads exist
      Skill->>ClassifyAgent: classify findings (CLASSIFICATION_SCHEMA)
      ClassifyAgent-->>Skill: enriched findings with status/matchedThreadId/delta
      Skill->>Skill: compute reviewMeta counts
      opt current user has resolved threads
        Skill->>VerifyAgent: verify resolutions (VERIFICATION_SCHEMA)
        VerifyAgent-->>Skill: threadVerifications[]
      end
    end
    Skill-->>User: findings + threadVerifications + reviewMeta
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • cblecker/claude-plugins#45: Introduced the review-pr workflow that this PR extends with the new Contextualize phase and thread classification schemas.
  • cblecker/claude-plugins#46: Added numeric confidence to findings and sorting logic that this PR builds on with "effective" severity/confidence resolution using adjusted values.
  • cblecker/claude-plugins#49: Modified review-pr workflow and code-reviewer prompt logic that this PR further refines with the Contextualize phase and prompt tightening.

Poem

🐇 Hop, hop through the diff I go,
Threads and findings all in a row,
New or duplicate, overlap too—
The Contextualize phase sees it through!
With JSON schemas neat and bright,
This bunny reviews code just 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 describes the main change: adding semantic contextualization against existing review threads, which is the core feature introduced across 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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/review-pr-contextualize-threads

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.

@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 647-669: The classification records are being applied directly to
classMap without validation, which can cause findings to be mislabeled with
dedupe or partial_overlap status even when contextual fields are missing. Before
the classifications.forEach loop populates classMap, add a normalization step to
ensure each classification record contains all required contextual fields
(matchedThreadId, existingCoverage, delta, adjustedSeverity, adjustedConfidence)
with appropriate defaults when missing, so that dedupe status is only assigned
when sufficient evidence exists in the enriched findings map.
- Around line 551-580: The code contains top-level await statements (such as the
await calls to agent() in the Contextualize phase around line 557) and return
statements (around lines 569 and 677) that are not inside any function, which
causes JavaScript parse errors. Wrap the entire execution code block—starting
from before the phase definitions and ending after all the return statements—in
an async function or an immediately-invoked async function expression (IIFE) to
allow these statements to be valid at the function scope rather than module
scope.

In `@pr-review-toolkit/skills/review-pr/SKILL.md`:
- Around line 101-112: The `newIssueDescription` field in the
threadVerifications example is set to null, but the workflow schema defines this
field as a string type. Update the example in the threadVerifications array to
either provide an actual string value for newIssueDescription or omit the field
entirely to match the schema contract and avoid confusion.
🪄 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: 9e72b1fe-5707-4062-827d-2fc94798cd61

📥 Commits

Reviewing files that changed from the base of the PR and between 8877e42 and feeb224.

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

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 evolves the pr-review-toolkit plugin's review-pr skill from a deterministic string-match dedup step into a model-driven Contextualize workflow phase. After the existing parallel review agents produce findings, three new agents run: a fetch agent pulls all existing review threads (with replies) plus the authenticated user's login, a classify agent labels each finding new/duplicate/partial_overlap against those threads, and a verify agent (only when the current user has resolved threads from a prior review) judges whether those threads were adequately addressed. The skill's SKILL.md is updated with the new return schema and a standardized presentation template, and the agent prompts are trimmed of non-essential sections.

Changes:

  • Adds a Contextualize phase to review-pr.js with three new structured-output schemas (THREAD_SCHEMA, CLASSIFICATION_SCHEMA, VERIFICATION_SCHEMA) and enrichment/aggregation logic returning findings, threadVerifications, and reviewMeta.
  • Rewrites SKILL.md Phase 3 to document the new return object and a numbered, category-grouped presentation template; removes get_me from allowed-tools and rewrites the data-processing constraint.
  • Trims agent prompts (removes "When to invoke", "Structured Output Requirements", tone/personality sections), aligns severity wording to the schema enum, and bumps the plugin version to 1.3.0.

Reviewed changes

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

File Description
pr-review-toolkit/skills/review-pr/review-pr.js Adds the Contextualize phase, new schemas, fetch/classify/verify agents, and result enrichment; trims agent prompts and fixes severity wording.
pr-review-toolkit/skills/review-pr/SKILL.md Documents new return JSON, adds presentation template, renames Phase 3, removes get_me from allowed-tools, updates constraints.
pr-review-toolkit/.claude-plugin/plugin.json Version bump 1.2.0 → 1.3.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 Outdated
@cblecker
cblecker force-pushed the feat/review-pr-contextualize-threads branch from feeb224 to 56a4073 Compare June 18, 2026 22:00
@cblecker
cblecker requested a review from Copilot June 18, 2026 22:00

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

Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jun 18, 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.

🧹 Nitpick comments (1)
pr-review-toolkit/skills/review-pr/review-pr.js (1)

36-66: 💤 Low value

Consider adding required arrays to nested schema items for consistency.

The PR objectives mention adding required arrays to all new schemas. CLASSIFICATION_SCHEMA and VERIFICATION_SCHEMA both specify required at the item level, but THREAD_SCHEMA does not define required fields for threads items or replies items.

The current code handles missing fields gracefully (line 615's filter treats undefined isResolved/author as falsy), so this is non-blocking. However, adding explicit required fields would make the contract clearer and align with the other schemas.

♻️ Optional: Add required arrays for consistency
         properties: {
           id: { type: 'string' },
           file: { type: 'string' },
           line: { type: 'number' },
           author: { type: 'string' },
           body: { type: 'string' },
           isResolved: { type: 'boolean' },
           replies: {
             type: 'array',
             items: {
               type: 'object',
               properties: {
                 author: { type: 'string' },
                 body: { type: 'string' }
-              }
+              },
+              required: ['author', 'body']
             }
           }
-        }
+        },
+        required: ['id', 'author', 'isResolved']
       }
     },
🤖 Prompt for 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.

In `@pr-review-toolkit/skills/review-pr/review-pr.js` around lines 36 - 66, Add
`required` arrays to the nested schema definitions in THREAD_SCHEMA for
consistency with CLASSIFICATION_SCHEMA and VERIFICATION_SCHEMA. Specifically,
add a `required` property to the items schema of the `threads` array (after the
properties definition) to specify which fields are mandatory for each thread
object, and add a `required` property to the items schema of the `replies` array
to specify which fields are mandatory for each reply object. This will make the
schema contract explicit and align with the pattern used in other schemas.
🤖 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.

Nitpick comments:
In `@pr-review-toolkit/skills/review-pr/review-pr.js`:
- Around line 36-66: Add `required` arrays to the nested schema definitions in
THREAD_SCHEMA for consistency with CLASSIFICATION_SCHEMA and
VERIFICATION_SCHEMA. Specifically, add a `required` property to the items schema
of the `threads` array (after the properties definition) to specify which fields
are mandatory for each thread object, and add a `required` property to the items
schema of the `replies` array to specify which fields are mandatory for each
reply object. This will make the schema contract explicit and align with the
pattern used in other schemas.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a0fabd0d-6d70-47f1-8549-d434ae17fc7d

📥 Commits

Reviewing files that changed from the base of the PR and between feeb224 and 56a4073.

📒 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 as they are similar to previous changes (1)
  • pr-review-toolkit/.claude-plugin/plugin.json

@cblecker
cblecker force-pushed the feat/review-pr-contextualize-threads branch from 56a4073 to 0c95b1e Compare June 19, 2026 00:29

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

🤖 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 93-116: The required array in the VERIFICATION_SCHEMA constant
(inside the items object of the verifications array) is missing three critical
fields that the Phase 3 presentation depends on. Update the required array to
include 'file', 'originalConcern', and 'newIssueIntroduced' in addition to the
existing required fields 'threadId', 'resolution', 'assessment', and
'isAdequate' to ensure all necessary data is validated before processing.

In `@pr-review-toolkit/skills/review-pr/SKILL.md`:
- Around line 123-130: The presentation template displays findings using a
format that always includes the line number (file:line), but the documentation
acknowledges that line numbers may be absent for file-level or PR-level
findings. Update the template sections in the New, Partial, and Duplicate
sections (around lines 168-199) to conditionally render the line number only
when it exists. If line is present, show the file:line format; if line is
absent, show only the file path to avoid rendering invalid locations like
path/to/file:undefined.
🪄 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: a0c3b910-6258-479f-8412-17c2ab997637

📥 Commits

Reviewing files that changed from the base of the PR and between 56a4073 and 0c95b1e.

📒 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 as they are similar to previous changes (1)
  • pr-review-toolkit/.claude-plugin/plugin.json

Comment thread pr-review-toolkit/skills/review-pr/review-pr.js
Comment thread pr-review-toolkit/skills/review-pr/SKILL.md
…xisting review threads

Replace the deterministic string-match dedup with a Contextualize workflow
phase that uses model-driven agents to:

- Fetch all existing review threads with full reply chains
- Classify each finding as new/duplicate/partial_overlap with rescored
  confidence for partial overlaps based on the delta
- Verify resolved threads from previous reviews (fixed, pushed back,
  or unaddressed) and flag incomplete fixes or new issues

Add standardized presentation template for Phase 3 with sections for
new findings, partial overlaps, duplicates, thread verifications, and
positive observations.

Assisted-by: Claude:claude-opus-4-6
Copilot AI review requested due to automatic review settings June 19, 2026 00:38
@cblecker
cblecker force-pushed the feat/review-pr-contextualize-threads branch from 0c95b1e to b7bc82b Compare June 19, 2026 00:38
@cblecker
cblecker merged commit 08fd171 into main Jun 19, 2026
12 checks passed
@cblecker
cblecker deleted the feat/review-pr-contextualize-threads branch June 19, 2026 00:39

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 no new comments.

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