Optimization rules for handling large PRs in `/rite:pr:review`.
From ritenpx claudepluginhub b16b1rd/cc-rite-workflow --plugin ritepr/references//review-context-optimizationOptimization rules for handling large PRs in `/zen:pr:review`.
Optimization rules for handling large PRs in /rite:pr:review.
Check the change scale to determine the need for context optimization:
gh pr view {pr_number} --json additions,deletions,changedFiles --jq '{additions: .additions, deletions: .deletions, files: .changedFiles}'
Scale determination table:
| Scale | Condition | Diff Retrieval Method |
|---|---|---|
| Small | Total changed lines <= 500 AND file count <= 10 | Retrieve entire diff at once |
| Medium | Does not meet small-scale conditions, total changed lines <= 2000, file count <= 30 | After retrieving diff, each reviewer references their relevant file sections |
| Large | Total changed lines > 2000 OR file count > 30 (31 or more) | Retrieve only related file diffs per reviewer |
Conditions are evaluated top-down. total_changes = additions + deletions.
Retrieve the PR diff in bulk:
gh pr diff {pr_number}
Retrieve only the related file diffs per reviewer. First retrieve the changed file list:
gh pr view {pr_number} --json files --jq '.files[].path'
Then extract per-reviewer diffs in Phase 4.3.
When a large diff is detected during the end-to-end flow (/rite:issue:start):
| State | Action |
|---|---|
| Context headroom available | Continue review as normal |
| Signs of context pressure | Automatically switch to per-file split mode |
Signs of context pressure (OR evaluation, optimization applied if any one matches):
Under pressure, apply optimization of passing only related diffs per reviewer.
Optimize diff passing based on scale:
| Scale | How to Pass Diff | Context Efficiency |
|---|---|---|
| Small (<= 500 lines) | Pass entire diff to all reviewers | Normal |
| Medium (501-2000 lines) | Pass only related file diffs to each reviewer | Optimized |
| Large (> 2000 lines) | Pass only related file diffs + summary information to each reviewer | Significantly optimized |
Use file pattern analysis results from Phase 2.2 to narrow down the diff passed to each reviewer.
Actual behavior:
gh pr diff {pr_number}For diffs exceeding 2000 lines, pass the following information to each reviewer:
{change_summary} format:
### 変更概要(大規模 diff - {total_changes} 行)
| ファイル | 追加行 | 削除行 | 種別 |
|---------|--------|--------|------|
| {file_path} | +{additions} | -{deletions} | {file_type} |
**注**: コンテキスト最適化のため、あなたの専門領域に関連するファイルの diff のみを以下に含めています。
他のファイルの詳細が必要な場合は、Read ツールで該当ファイルを取得してください。
{file_type} classification: Determined from extension (.md -> Document, .ts/.tsx -> TypeScript, .py -> Python, etc.).
{diff_content} embedding varies by scale:
| Scale | {diff_content} Content |
|---|---|
| Small (<= 500 lines) | Embed entire diff as-is |
| Medium (501-2000 lines) | Embed only diffs for files matching {relevant_files} |
| Large (> 2000 lines) | Embed {change_summary} and diffs for files matching {relevant_files}, plus retrieval instructions |
How {relevant_files} is determined:
{relevant_files} is a different file list for each reviewer depending on their area of expertise. Only files matching the reviewer's Activation pattern are included.
Example: Security Expert receives files matching **/auth/**, Frontend Expert receives files matching **/*.tsx.
Reviewers retrieve additional files with the Read tool in the following cases:
Path specification method: The "File" column in the change summary table contains paths relative to the repository root (e.g., plugins/rite/commands/pr/review.md). For the Read tool, specify this path as-is or convert it to an absolute path from the working directory.