XMC Review PR
Interactive multi-agent PR review workflow enforcing code rules, open direction discussions, explicit confirmation gates, inline comment deduplication, and follow-up re-review verification.
Warnings for the author
- "name" should use lowercase letters, digits and single hyphens only
- "name" should match the name of the directory that holds SKILL.md
- Not listed through the skills extension: the directory must be named after the skill.
Interactive Pull Request Review Playbook
This skill provides an end-to-end multi-agent workflow for conducting comprehensive, collaborative, rule-backed reviews of GitHub Pull Requests.
[!IMPORTANT] All execution steps in this skill MUST strictly adhere to the mandatory policy rules defined in PR Review Guidelines, Core Engineering Standards, Skills & Automation Guidelines, and file-extension language guidelines under
rules/languages/.
Architecture & Workflow Overview
graph TD
A["User triggers XMC Review PR"] --> B["Agent runs review_pr_generate_audit.py (fetches and checks out the PR head)"]
B --> C{"Select Operational Mode"}
C -->|"Mode A: Initial Review"| D["Phase 1: Open User Direction Discussion Window"]
D --> E["Phase 2: Dynamic Expert Subagent Panel (Critical Thinking & Passable 'No Findings')"]
E --> F["Phase 3: Generate Interactive Audit Checklist (pr_review_audit_checklist.md in session dir)"]
F --> G["Phase 4: Mandatory Explicit Confirmation Gate (Y/n)"]
G --> H["Phase 5: Strictly Inline Posting (review_pr_post_inline_comment.py)"]
H --> I["Phase 6: 1-to-1 Posted Verification (review_pr_verify_posted.py)"]
C -->|"Mode B: Re-Review"| J["Phase 1: Author Reply & Delta Inspection"]
J -->|"full_review_recommended"| D
J --> K["Phase 2: Evaluate Author Claims, Pushback & Substantial Deltas"]
K --> L["Phase 3: Markdown Iteration Report (pr_rereview_audit_report.md in session dir)"]
L --> M["Phase 4: Explicit Confirmation Gate for Resolving/Counter-Replying"]
M --> N["Phase 5: Batch Thread Reply & Resolution Execution"]
N --> O["Phase 6: Programmatic Resolution Verification"]
Guidelines for Using Helper CLI Tools (tools/pr_review/review_pr_*.py)
When invoking helper CLI scripts under tools/pr_review/ (review_pr_generate_audit.py, review_pr_post_inline_comment.py, review_pr_verify_posted.py):
- Do not read tool source code: Refer to Skills & Automation Guidelines.
- Inspect parameters via
--help: Run tools with--helpto inspect parameter schemas and usage flags. - Parse Structured JSON Output: Tools output structured JSON; check the exit code per Helper Tool Exit Codes.
- Store Artifacts strictly inside a Session Scratch Directory (
--out-dir): All generated markdown audit checklists, reports, and review inputs (pr.diff,pr_meta.json,review_threads.json) go to a session scratch directory outside the repository (<session_scratch_dir>) rather than the workspace root to prevent accidental git repository commits. - Virtual Environment & Execution Safety: Invoke tools with plain
python3. Allreview_pr_*.pytools rely strictly on standard library modules (argparse,pathlib,json,re,subprocess,urllib) +ghCLI, so they execute deterministically in any Python environment and need no virtual environment (see Python Guidelines for tools that do). - Arbitrary Long Comment File Safety (
-f/--message-file): Always write proposed inline review comments containing markdown diff blocks or detailed explanations to a file and pass-f message_file.mdto prevent bash escaping errors or length truncation. - Run helpers from a trusted checkout: Every
tools/pr_review/...command in this skill (Mode A and Mode B) means<trusted_repo>/tools/pr_review/..., run with cwd at<review_dir>.<trusted_repo>is a checkout you trust (e.g. your up-to-datemain), never the review worktree. After--checkouta review worktree sits at a PR head (on a re-review, the previous round's head), so relative paths would run PR-authored helpers with your GitHub credentials.
Mode A: Initial PR Review & Collaborative Scoping
Phase 1: Open User Direction Discussion Window ("Where should I look?")
Before launching deep code analysis or subagent review panels, the agent must inspect basic PR metadata and open an interactive dialogue with the reviewer:
-
Run Initial Audit Script at the PR Head:
python3 <trusted_repo>/tools/pr_review/review_pr_generate_audit.py <owner> <repo> <pr_number> --mode initial \ --out-dir <session_scratch_dir> --checkoutThis fetches PR details, diff file touchpoints, extracts task or issue references (#123, issue links) from the description, indexes existing inline comments for deduplication, initializes the Core 8-Pillar Baseline Audit Matrix (with explicit N/A resolution), and creates
pr_review_audit_checklist.mdplus its machine-readable sidecarpr_review_audit_checklist.jsoninside<session_scratch_dir>(a directory outside the repository).With
--out-dirit also fetchespull/<pr_number>/headand writes the review inputs there:pr.diff(base...head),pr_meta.json(base/head refs and SHAs, file list with +/- counts), andreview_threads.json.--checkoutchecks the PR head out detached so every file you read is the PR's version. When tracked files have local changes, or git refuses the checkout (e.g. an untracked file sits at a path the PR adds), it skips the checkout and returnschecked_out: falseplus the exactcheckout_command; it never discards local work. Commit or stash, then run that command, or review frompr.diffonly. The tool runs every git command with hooks disabled (-c core.hooksPath=/dev/null), andcheckout_commandcarries the same flag.--checkoutmoves HEAD of the worktree you run it in, so relativetools/paths then point at the PR's version of the helpers. Prefer a dedicated review worktree (git -c core.hooksPath=/dev/null worktree add --detach <review_dir>) and run with cwd at<review_dir>. When reviewing in your own worktree, note the current branch first and return withgit -c core.hooksPath=/dev/null switch -after the review. Run every helper by absolute path from your trusted checkout, never by relative path (guideline 7). Whenever you run git yourself against a tree that contains or contained PR files, pass-c core.hooksPath=/dev/null. With a relativecore.hooksPathsuch as.githooks, git otherwise runs the PR's hooks with your credentials.- Read-Only Fetch-First Inspection: Throughout Phase 1 and Phase 2 subagent reviews, follow Non-Mutating Fetch-First PR Inspection. The command above already fetches
pull/<pr_number>/headand only checks it out in a clean worktree. When the checkout was skipped, inspect files viagit show <head_sha>:<path>or a detached worktree (git -c core.hooksPath=/dev/null worktree add --detach <tmp_dir> <head_sha>) rather than runninggh pr checkoutin a dirty workspace or reading unchecked-out local working-tree paths.
[!IMPORTANT] Never review PR files from a worktree that is not at
pr_meta.json'shead_sha. Take base/head SHAs and the diff frompr_meta.jsonandpr.diff; do not guessgh pr view --jsonfield names (baseRefOiddoes not exist on olderghreleases) or chaingh/git rev-parsecalls. - Read-Only Fetch-First Inspection: Throughout Phase 1 and Phase 2 subagent reviews, follow Non-Mutating Fetch-First PR Inspection. The command above already fetches
-
Present Scoping Summary & Open Direction Window: Display PR metadata, touched package matrix, task references, and ask the user for guidance before launching subagent reviews:
"I have fetched metadata for PR #<pr_number>: <Title>. - Base ← Head:
<base>←<head>(<sha>) - Referenced Tasks/Bugs:<bug_references>- Modified Packages:pkg/auth,cmd/xid_service, etc. - Existing Inline Threads Indexed: <count> threads (deduplication active)Before I launch our expert review panel, please let me know:
- Are there specific subsystems, security boundaries, or edge cases you want the review panel to focus on?
- Do you have initial inline feedback or direction where you'd like me to look?
- Should I give special attention to API / configuration contract compatibility?"
Phase 2: Dynamic Expert Subagent Panel & Rule Alignment
Once the user provides initial directional guidance (or confirms to proceed), the Main Orchestrator dynamically spawns specialized reviewer subagents tailored to the modified file types.
Reviewer Inputs & Tool Access
- Give every reviewer the absolute paths of
pr.diff,pr_meta.json, andreview_threads.jsonfrom<session_scratch_dir>, plus thehead_sha. Reviewers that only read files can review from these inputs. Whenpr_meta.jsonhasthreads_error, the thread fetch failed andreview_threads.jsonis not authoritative: tell reviewers, and deduplicate against the PR on GitHub instead. - Reviewers that must run code (tests,
git log/git blame, builds) need a shell and must work in a worktree athead_sha. Do not hand such tasks to read-only reviewers; run the command yourself and pass them the output instead.
Hybrid Baseline Rubric + Dynamic Specialist Role Architecture
To eliminate stochastic omission variance (where dynamic subagents might forget core engineering principles) while retaining deep subsystem expertise, every PR code review enforces a Hybrid Evaluation Architecture:
-
Deterministic Core 8-Pillar Baseline Audit Matrix (
with explicit N/A resolution): Every PR review artifact (pr_review_audit_checklist.md) incorporates a deterministic inspection rubric covering:- Pillar 1: Linear Control Flow & Guard Clauses (
core_engineering.md#2-kiss) - Pillar 2: Single Responsibility Principle & Target Complexity Limit (
core_engineering.md#1-srp) - Pillar 3: Defensive Input Validation & Boundary Checks (
core_engineering.md) - Pillar 4: Concurrency &
context.ContextPropagation Safety (golang.md/python.md) - Pillar 5: Test Double Fidelity & Deterministic Test Execution (
core_engineering.md#4) - Pillar 6: Backward Compatibility & Contract Protection (
core_engineering.md) - Pillar 7: Dependency Graph & Build System Boundaries (
core_engineering.md) - Pillar 8: Documentation & Contract Alignment (
core_engineering.md#5) Crucially, every pillar MUST be evaluated as either anACTIONABLE FINDING,COMPLIANT / PASS, or- [ ] N/A — Subsystem / pattern not touched by PRwith brief rationale, ensuring zero silent omissions.
- Pillar 1: Linear Control Flow & Guard Clauses (
-
Mandatory Subagent: The review panel MUST always include a dedicated
PR Description & Task Reference Reconciliation Specialist, tasked with evaluating whether the actual git diff matches what the PR title and description claim to do, and verifying that referenced task references, issue links, or design specs are fulfilled. -
Dynamic Domain Subagents (Synthesized by Agent): Subagents must NOT concentrate solely on line-by-line code mechanics. When main dependency pillars, workload orchestrators, or scheduling subsystems are touched, the agent should dynamically craft specialized domain expert subagent roles (1–3 roles with tightly scoped prompts). Examples include (but are not limited to):
- Example (Scheduling & Workload Dependency Pillar):
Kueue Expert / Subsystem SpecialistauditingClusterQueue,LocalQueue, Workunit resource reservation, quota enforcement, preemptor interaction, and Kueue CRD updates whenever scheduling or workload actuation is touched. - Example (Kubernetes Infrastructure Pillar):
Kubernetes (K8s) Expert Specialistevaluating controller-runtime reconciler loops, informer cache synchronization, RBAC ClusterRole permissions, pod disruption budgets, and GKE lifecycle behavior whenever K8s resources, CRDs, or Helm charts are touched. - Example (Go Backend):
Go Concurrency & Interface Safety Reviewercheckingcontext.Contextpropagation, mutex boundaries, and test double fidelity (prototest.Modify). - Example (Python Tooling):
Python CLI & Shell Injection Security Reviewerauditing standard library preferences, error handling, and argument escaping. - Example (UI Frontend):
Modern Angular Signal & Immutability Reviewerverifying declarative template patterns and state immutability. - Example (Infrastructure / API):
Protobuf & Helm Backward-Compatibility Reviewerverifying breaking schema or deployment changes.
- Example (Scheduling & Workload Dependency Pillar):
Strict Directives for Subagent Prompting
All expert subagents invoked during Phase 2 MUST receive the following mandatory guidelines:
- Critical Thinking Required: Apply genuine engineering critical thinking. Do not output trivial mechanical formatting comments or stylistic preferences.
- "No Findings" is a Passable and Respected Result: Expressly instruct subagents:
"Returning 'No actionable findings — code cleanly complies with project rules and guidelines' is a valid, high-value engineering conclusion. Do NOT manufacture artificial issues or exaggerate minor stylistic choices just to return findings."
- PR Description & Requirement Audit: Verify whether code modifications actually achieve what the author stated in the PR title, description, and referenced task definitions.
- Strict Inline Deduplication & Already-Resolved Thread Governance:
- Inspect the supplied existing comment index (
comments) and never generate duplicate inline comments for problems already raised on the PR. - Already Resolved Threads on GitHub UI (
[RESOLVED ON GITHUB]): Treat threads marked resolved on GitHub as closed engineering decisions. Do NOT re-open or propose duplicate inline comments unless a new commit explicitly regressed that exact file line.
- Inspect the supplied existing comment index (
- Strict Mock & Fixture Isolation Audit: Explicitly audit production files for mock data leakage. Production components, handlers, and service files must NEVER contain static mock datasets, sample entities, or fallback mock branching. All test doubles and fixtures belong strictly in dedicated test files (
*_test.ts,*_test.go,test_*.py) or testing helpers (cmd/ui/app/testing/mock_*.ts,test/fixtures/) percore_engineering.md#4.
Phase 3: Generate Interactive Audit Checklist Artifact (pr_review_audit_checklist.md)
After subagents complete their reviews, the Main Orchestrator synthesizes findings, filters out duplicate/trivial comments, and formats the Interactive Audit Checklist inside <session_scratch_dir>/pr_review_audit_checklist.md.
Crucially, the Main Orchestrator MUST partition every finding into two distinct scope categories based on git diff patch boundaries:
- Group A: Inline PR Diff Patch Items (
Patch-In-Scope): Target lines that were actually modified or added in the PR diff patch. These can be posted directly as inline GitHub diff comments (tools/pr_review/review_pr_post_inline_comment.py). - Group B: Out-of-Diff Scope Observations (
Unchanged-Line-Out-of-Scope): Target unchanged surrounding lines in modified files outside the PR diff patch. Because GitHub's inline comment API rejects non-diff lines with 422 errors, these cannot be posted as inline review comments.
Each proposed item in pr_review_audit_checklist.md must specify:
- Item ID (
#1,#2, ...) - Scope Classification:
[Group A: Inline Patch]vs[Group B: Out-of-Diff Scope] - Status:
Draft(default until user confirms) - File Path & Line Number (with patch vs unchanged line status clearly flagged)
- Rule Reference (canonical path, e.g.,
core_engineering.md#1-single-responsibility-principleorpr_review_guidelines.md#1-code-review--inspection-guidelines) - Priority:
Blocker/Actionable Optimization/Clarity Question/Nit - Proposed Inline Comment Text (with concrete git diff block suggestions where applicable)
Files of this skill
This skill has no supporting files.