| name | pr-review |
| description | Review, validate, test, approve, and merge Pull Requests in this repository. Use when asked to review a PR, wait for CI builds/checks to pass, verify compliance with repository policies (AGENTS.md, security guardrails, coding standards), approve safe PRs, merge them, or provide actionable feedback comments on failing/unsafe PRs. |
Pull Request Review & Merge Skill
This skill guides the agent through inspecting, monitoring, validating, approving, merging, or commenting on Pull Requests in the Dataflow Solution Guides repository.
1. Core Principles & Golden Rules
- Parallel Agent Isolation & Workspace Safety:
- Remote-First by Default: Inspection, diff analysis, CI monitoring, review comments, and merging (
gh pr view, gh pr diff, gh pr checks, gh pr review, gh pr merge) are strictly remote API operations that do not mutate the local working tree and can safely run concurrently across multiple agents.
- No Shared Working Tree Mutex: Never run
gh pr checkout in a shared workspace (i.e. default Workspace: 'inherit'). Checking out branches concurrently will switch the working branch under other agents, causing file corruption and broken builds.
- Mandatory Isolation for Local Builds: If local compilation or testing is required (Section 4), agents must use isolated git worktrees (
git worktree add) or subagents spawned with Workspace: "branch" or Workspace: "share".
- No Busy-Waiting: Avoid tight polling loops against GitHub APIs. Use event-driven scheduling (the
schedule tool) for periodic status checks.
- Never Merge In-Progress or Failing Builds:
- Always wait until all required GitHub Actions jobs and CI checks complete with
success.
- Never merge if any check is
in_progress, failed, or cancelled.
- Strict Security Guardrails:
- Dataflow Worker Private IPs: Verify workers have public IPs disabled (
--no_use_public_ip in Python, --usePublicIps=false in Java).
- Dedicated Service Accounts: Workers must run with custom least-privilege service accounts, never the Compute Engine default service account.
- VPC Subnets: Must have
enable_private_access = true.
- Worker Firewalls: Ensure ingress and egress on TCP ports
12345 and 12346 for the dataflow target tag.
- Consistent Code Formatting & Linting:
- Java: Enforce Google Java Style via Spotless (
./gradlew spotlessApply).
- Python: Enforce Google style via Yapf (
yapf -i -r --style yapf .) and shared PyLint (pylint --rcfile ../pylintrc .).
- Terraform: Enforce
terraform fmt -check and terraform validate.
- Terraform to Pipeline Linkage:
- Every Terraform module must define
resource "local_file" "variables_script" to generate environment variables for pipelines.
- Generated scripts must not be manually modified; changes must be made via Terraform.
2. PR Review Checklist by Category
Before approving or merging, identify the PR type and apply the corresponding checklist:
A. Dependency Updates (Renovate / Dependabot)
B. Java Pipeline Changes (pipelines/*_java/)
C. Python Pipeline Changes (pipelines/*/)
D. Terraform Infrastructure Changes (terraform/*/)
E. Agent Guidelines & Documentation (AGENTS.md, use_cases/*.md, .agents/skills/)
3. End-to-End Review & Merge Workflow
flowchart TD
A["Phase 1: Inspect PR & Diff (Remote)"] --> B["Phase 2: Monitor CI Status (Remote)"]
B --> C{"CI Checks Passing?"}
C -- "No / In Progress" --> D["Wait (schedule) or Inspect Failure Logs"]
D --> E["Post Actionable Comment / Request Changes"]
C -- "Yes" --> F["Phase 3: Policy & Security Audit"]
F --> G{"Compliant with Policies?"}
G -- "No" --> E
G -- "Yes" --> H["Phase 4: Submit Approving Review"]
H --> I["Squash & Merge PR"]
I --> J{"Merge Successful?"}
J -- "Yes" --> K["Phase 5: Verify & Report"]
J -- "Base Branch Out of Date" --> L["Update PR Branch & Re-verify CI"]
L --> B
Phase 1: Inspect PR & Identify Scope (Safe for Parallel Execution)
Inspect the PR title, body, author, branch, and file changes via GitHub CLI without modifying local disk:
gh pr view <PR_NUMBER> -R GoogleCloudPlatform/dataflow-solution-guides
gh pr diff <PR_NUMBER> -R GoogleCloudPlatform/dataflow-solution-guides
gh pr view <PR_NUMBER> -R GoogleCloudPlatform/dataflow-solution-guides --json files
Phase 2: Monitor CI Status & Builds (Safe for Parallel Execution)
Check the status of GitHub Actions workflows:
gh pr checks <PR_NUMBER> -R GoogleCloudPlatform/dataflow-solution-guides
gh run list --workflow=pull_request.yml -R GoogleCloudPlatform/dataflow-solution-guides --limit 5
gh run view <RUN_ID> -R GoogleCloudPlatform/dataflow-solution-guides
Wait until all checks finish. If any job fails, inspect failure logs:
gh run view <RUN_ID> --log-failed -R GoogleCloudPlatform/dataflow-solution-guides
Phase 3: Policy, Security & Architecture Audit
Cross-reference the diff against:
- Root AGENTS.md
- Subdirectory guidelines (pipelines/AGENTS.md, terraform/AGENTS.md)
- Section 2 Checklist above.
Phase 4: Decision & Execution
Scenario A: All Checks Pass & Changes Are Safe
- Submit Approving Review:
gh pr review <PR_NUMBER> -R GoogleCloudPlatform/dataflow-solution-guides \
--approve \
--body "LGTM. Changes pass all CI build, linting, and validation checks and comply with repository security and architectural policies."
- Merge the Pull Request:
gh pr merge <PR_NUMBER> -R GoogleCloudPlatform/dataflow-solution-guides --squash --delete-branch
- Handling Parallel Merge Races:
If another PR was merged to
main right before this merge, gh pr merge may report that the branch is out of date or needs re-testing:
gh pr update-branch <PR_NUMBER> -R GoogleCloudPlatform/dataflow-solution-guides
After updating, wait for CI checks to re-verify success before re-issuing gh pr merge.
Scenario B: Checks Fail or Violations Detected
- Do NOT merge.
- Submit a Detailed Comment / Request Changes:
gh pr review <PR_NUMBER> -R GoogleCloudPlatform/dataflow-solution-guides \
--comment \
--body "<DETAILED_EXPLANATION>"
Comment Structure:
- Issue Summary: Clear statement of what failed or violated policy.
- CI Log Snippet: Exact error messages from the failed build/lint step.
- Actionable Remedy: Step-by-step instructions or code snippets showing how to fix the issue.
4. Concurrency-Safe Local Validation (Optional / Deep Verification)
[!CAUTION]
Never run gh pr checkout in a shared workspace when running multiple review agents in parallel.
Doing so modifies the shared working tree and corrupts parallel agent executions.
When deep local verification (e.g. running gradle builds, custom container builds, or reproducer scripts) is required, follow one of the two concurrency-safe isolation patterns:
Pattern A: Subagent Workspace Isolation (Recommended for Agent Workflows)
Spawn a dedicated subagent with isolated workspace branching:
- Set
Workspace: "branch" (full isolated clone/branch) or Workspace: "share" (shared underlying object database with isolated worktree).
Pattern B: Ephemeral Git Worktree
Run validation inside an isolated git worktree:
git fetch origin pull/<PR_NUMBER>/head:pr-<PR_NUMBER>
git worktree add .worktrees/pr-<PR_NUMBER> pr-<PR_NUMBER>
cd .worktrees/pr-<PR_NUMBER>
cd pipelines/<use_case>_java && ./gradlew build && ./gradlew spotlessCheck
cd pipelines/<use_case> && pylint --rcfile ../pylintrc .
cd terraform/<use_case> && terraform init && terraform validate
cd /home/ihr/github/dataflow-solution-guides
git worktree remove .worktrees/pr-<PR_NUMBER> --force
git branch -D pr-<PR_NUMBER>