Skip to content

google/xmc

https://skillcdn.ai/gh/google/xmc

Connect this address to your AI to use this skill. How to connect

  • Unverified
  • Default branchmain
  • Commit4aa58c5
  • LicenseApache-2.0
  • Searchwords

Showing commit 4aa58c5

The newest commit, 81ffa97, is being indexed. Until it is ready, this page and every agent are served the last indexed commit.
View on GitHub

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.

Path
.agents/skills/xmc_review_pr/SKILL.md
License
Apache-2.0

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):

  1. Do not read tool source code: Refer to Skills & Automation Guidelines.
  2. Inspect parameters via --help: Run tools with --help to inspect parameter schemas and usage flags.
  3. Parse Structured JSON Output: Tools output structured JSON; check the exit code per Helper Tool Exit Codes.
  4. 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.
  5. Virtual Environment & Execution Safety: Invoke tools with plain python3. All review_pr_*.py tools rely strictly on standard library modules (argparse, pathlib, json, re, subprocess, urllib) + gh CLI, so they execute deterministically in any Python environment and need no virtual environment (see Python Guidelines for tools that do).
  6. 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.md to prevent bash escaping errors or length truncation.
  7. 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-date main), never the review worktree. After --checkout a 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:

  1. 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> --checkout
    

    This 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.md plus its machine-readable sidecar pr_review_audit_checklist.json inside <session_scratch_dir> (a directory outside the repository).

    With --out-dir it also fetches pull/<pr_number>/head and writes the review inputs there: pr.diff (base...head), pr_meta.json (base/head refs and SHAs, file list with +/- counts), and review_threads.json. --checkout checks 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 returns checked_out: false plus the exact checkout_command; it never discards local work. Commit or stash, then run that command, or review from pr.diff only. The tool runs every git command with hooks disabled (-c core.hooksPath=/dev/null), and checkout_command carries the same flag.

    --checkout moves HEAD of the worktree you run it in, so relative tools/ 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 with git -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 relative core.hooksPath such 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>/head and only checks it out in a clean worktree. When the checkout was skipped, inspect files via git show <head_sha>:<path> or a detached worktree (git -c core.hooksPath=/dev/null worktree add --detach <tmp_dir> <head_sha>) rather than running gh pr checkout in 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's head_sha. Take base/head SHAs and the diff from pr_meta.json and pr.diff; do not guess gh pr view --json field names (baseRefOid does not exist on older gh releases) or chain gh/git rev-parse calls.

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

    1. Are there specific subsystems, security boundaries, or edge cases you want the review panel to focus on?
    2. Do you have initial inline feedback or direction where you'd like me to look?
    3. 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, and review_threads.json from <session_scratch_dir>, plus the head_sha. Reviewers that only read files can review from these inputs. When pr_meta.json has threads_error, the thread fetch failed and review_threads.json is 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 at head_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:

  1. 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.Context Propagation 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 an ACTIONABLE FINDING, COMPLIANT / PASS, or - [ ] N/A — Subsystem / pattern not touched by PR with brief rationale, ensuring zero silent omissions.
  2. 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.

  3. 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 Specialist auditing ClusterQueue, 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 Specialist evaluating 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 Reviewer checking context.Context propagation, mutex boundaries, and test double fidelity (prototest.Modify).
    • Example (Python Tooling): Python CLI & Shell Injection Security Reviewer auditing standard library preferences, error handling, and argument escaping.
    • Example (UI Frontend): Modern Angular Signal & Immutability Reviewer verifying declarative template patterns and state immutability.
    • Example (Infrastructure / API): Protobuf & Helm Backward-Compatibility Reviewer verifying breaking schema or deployment changes.
Strict Directives for Subagent Prompting

All expert subagents invoked during Phase 2 MUST receive the following mandatory guidelines:

  1. Critical Thinking Required: Apply genuine engineering critical thinking. Do not output trivial mechanical formatting comments or stylistic preferences.
  2. "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."

  3. PR Description & Requirement Audit: Verify whether code modifications actually achieve what the author stated in the PR title, description, and referenced task definitions.
  4. 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.
  5. 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/) per core_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:

  1. 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).
  2. 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-principle or pr_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)
This skill’s instructions are not fully loaded. Continue to read all inherited rules and required context.

Files of this skill

This skill has no supporting files.

Browse all supporting files