Get the FREE Ultimate OpenClaw Setup Guide →

pr-patrol

Scanned
npx machina-cli add skill SmartOzzehir/smart-plugins/pr-patrol --openclaw
Files (1)
SKILL.md
8.1 KB

PR Patrol

Process automated PR review comments through a 7-gate workflow with phase-based loading.


⚠️ CRITICAL REMINDERS

  1. READ PHASE FILE FIRST - Check status in state file, read phases/gate-{N}.md for current phase
  2. USE AGENTS FOR VALIDATION - Use bot-comment-validator via Task tool, never manual
  3. ASK ABOUT PR-REVIEW AGENTS - After checks pass, ask about code-reviewer/silent-failure-hunter
  4. ISSUE COMMENTS NEED @MENTION - GitHub issue comments don't support threading
  5. UPDATE STATE FILE - After EVERY action (use scripts/update_state.sh)
  6. NEVER REPLY TO COPILOT - Silent fix only, no reactions, no replies
  7. TRUST SCRIPT OUTPUT - When scripts return data, DO NOT make extra API calls to "verify"!

Quick Reference

BotLoginReactionReply
CodeRabbitcoderabbitai[bot]
Greptilegreptile-apps[bot]👍/👎 FIRST✅ THEN
Codexchatgpt-codex-connector[bot]👍/👎 FIRST✅ THEN
CopilotCopilot❌ NEVER❌ NEVER
Sentrysentry[bot]👍/👎 FIRST✅ THEN

Ignored: vercel[bot], dependabot[bot], renovate[bot], github-actions[bot]


Workflow Diagram

/pr-patrol [PR#]
       │
       ▼
┌─ GATE 0: Init ──────────────────────┐
│ [AskUserQuestion] Mode, scope       │ → phases/gate-0-init.md
└─────────────────────────────────────┘
       │
       ▼
┌─ GATE 1: Collect ───────────────────┐
│ [AskUserQuestion] Proceed?          │ → phases/gate-1-collect.md
└─────────────────────────────────────┘
       │
       ▼
┌─ GATE 2: Validate ──────────────────┐
│ [Task: bot-comment-validator]       │ → phases/gate-2-validate.md
│ [AskUserQuestion] Which to fix?     │
└─────────────────────────────────────┘
       │
       ▼
┌─ GATE 3: Fix & Check ───────────────┐
│ Apply fixes → typecheck → lint      │ → phases/gate-3-fix.md
│ [AskUserQuestion] Run pr-review?    │ ← Gate 3.5!
└─────────────────────────────────────┘
       │
       ▼
┌─ GATE 4: Commit ────────────────────┐
│ [AskUserQuestion] Review & commit?  │ → phases/gate-4-commit.md
└─────────────────────────────────────┘
       │
       ▼
┌─ GATE 5: Reply ─────────────────────┐
│ [AskUserQuestion] Post replies?     │ → phases/gate-5-reply.md
│ Also read: bot-formats.md           │
└─────────────────────────────────────┘
       │
       ▼
┌─ GATE 6: Push ──────────────────────┐
│ [AskUserQuestion] Push? Cycle 2?    │ → phases/gate-6-push.md
└─────────────────────────────────────┘

Phase Routing (FOLLOW THIS!)

Step 1: Check State File

STATE_FILE=".claude/bot-reviews/PR-{N}.md"

Step 2: Read Current Phase

StatusRead This Phase File
(no file)phases/gate-0-init.md
initializedphases/gate-1-collect.md
collectedphases/gate-2-validate.md
validatedCheck next_gate field: if 5phases/gate-5-reply.md, else phases/gate-3-fix.md
fixes_plannedphases/gate-3-fix.md
fixes_appliedphases/gate-3-fix.md (run checks)
checks_passedphases/gate-4-commit.md
committedphases/gate-5-reply.md
replies_sentphases/gate-6-push.md
pushedCheck for new comments → Cycle 2?

Step 3: Follow Phase Instructions

Each phase file contains:

  • Detailed step-by-step actions
  • MANDATORY AskUserQuestion prompts
  • Edge cases and error handling
  • State file update commands

Scripts Location

SCRIPTS="${CLAUDE_PLUGIN_ROOT}/skills/pr-patrol/scripts"

# Core scripts
"$SCRIPTS/fetch_pr_comments.sh" owner repo pr              # Parallel API fetch + normalize
cat normalized.json | "$SCRIPTS/detect_thread_states.sh"   # State detection (reads stdin)
"$SCRIPTS/check_new_comments.sh" owner repo pr [since]     # New since push
"$SCRIPTS/check_reply_status.sh" owner repo pr             # Reply tracking
"$SCRIPTS/update_state.sh" file field value                # State updates
"$SCRIPTS/update_billboard.sh" file status gate action     # Billboard + frontmatter update
"$SCRIPTS/build_greptile_summary.sh" file cycle            # Greptile summary comment
"$SCRIPTS/parse_coderabbit_embedded.sh" [file]             # Extract embedded comments (stdin or file)

# jq libraries (used by scripts above, not called directly)
# bot-detection.jq        — shared bot detection functions
# normalize_comments.jq   — transform raw API → normalized structure
# severity_detection.jq   — add severity to comments
# detect_states.jq        — thread state detection (NEW/PENDING/RESOLVED/REJECTED)

Reference Files Location

SKILL_ROOT="${CLAUDE_PLUGIN_ROOT}/skills/pr-patrol"

# Read these files with their FULL paths:
"$SKILL_ROOT/phases/gate-{N}.md"    # Phase instructions
"$SKILL_ROOT/bot-formats.md"        # Bot protocols (CRITICAL for Gate 5!)
"$SKILL_ROOT/templates.md"          # Reply templates
FilePurposeWhen to Read
phases/gate-{N}.mdPhase-specific instructionsBased on status
bot-formats.mdBot-specific protocolsMUST READ before Gate 5
templates.mdReply message templatesGate 5 (replies)
examples/sample-*.mdState file examples at each stageWhen unsure about state file format
examples/sample-*.jsonScript output shapesWhen working with script output

Critical Rules

  1. EVERY gate requires AskUserQuestion - Never skip user approval
  2. ALL comments must be validated - Severity only affects priority
  3. Copilot gets NO response - Silent fix only, no reactions, no replies
  4. NEVER commit/push without approval - Explicit consent required
  5. NEVER force push - Blocked completely
  6. Typecheck/lint are MANDATORY - Block on failure
  7. ALWAYS use --paginate - Default GitHub API returns only 30 comments
  8. Fetch BOTH endpoints - Review comments (/pulls/{pr}/comments) AND issue comments (/issues/{pr}/comments)
  9. Extract embedded CodeRabbit comments - Use "$SCRIPTS/parse_coderabbit_embedded.sh" for nitpicks, duplicates, outside-diff
  10. Issue vs PR review comments - Different reply methods! Issue comments need @mention (no threading)
  11. Reaction BEFORE reply - For Greptile/Codex/Sentry, add reaction first, then reply
  12. Short reply format - "Fixed in commit {sha}: {description}" NOT verbose essays
  13. Use helper scripts - ${CLAUDE_PLUGIN_ROOT}/skills/pr-patrol/scripts/ has utilities
  14. TRUST SCRIPT OUTPUT - When scripts return data, DO NOT make verification queries

jq Escaping Warning

Shell escaping corrupts jq != operators. For any jq with != or complex logic, use the .jq files in scripts/ instead of inline jq. For negation, use | not (e.g., select(.bot == "Copilot" | not)).

Source

git clone https://github.com/SmartOzzehir/smart-plugins/blob/main/pr-patrol/skills/pr-patrol/SKILL.mdView on GitHub

Overview

pr-patrol processes automated PR review comments using a phase-driven 7-gate workflow. It tracks PR review state, validates bot comments from CodeRabbit, Greptile, Codex, Copilot, and Sentry, and batches fixes for consistent feedback handling. This makes PR reviews auditable and reduces manual back-and-forth.

How This Skill Works

It reads a state file at .claude/bot-reviews/PR-{N}.md, loads the current phase from phases/gate-*.md, and uses the bot-comment-validator via the Task tool to validate bot comments. The workflow progresses through gates Init, Collect, Validate, Fix, Commit, Reply, and Push, with state updates after every action via scripts/update_state.sh. Copilot fixes are silent (no replies) and no extra API calls are made beyond script outputs.

When to Use It

  • You need to handle bot comments on a PR (CodeRabbit, Greptile, Codex, Copilot, Sentry) in a batch, not individually.
  • A PR has automated review comments and you want to validate and apply fixes through the 7-gate workflow.
  • You want to run /pr-patrol to supervise PR review comments and guide actions phase-by-phase.
  • You must read and follow gate-specific instructions from phases/gate-*.md before acting.
  • You require auditable state tracking where every action updates the state file with scripts/update_state.sh.

Quick Start

  1. Step 1: Run /pr-patrol <PR#> to start patrol on the target pull request.
  2. Step 2: The agent reads the state file .claude/bot-reviews/PR-{N}.md and loads the current phase from phases/gate-*.md.
  3. Step 3: Follow gate prompts, use bot-comment-validator for validation, apply fixes, commit, reply (when not Copilot), push, and update the state after each action using scripts/update_state.sh.

Best Practices

  • Always validate bot comments with the bot-comment-validator via the Task tool before applying fixes.
  • Read the current phase from phases/gate-*.md and start from the correct gate.
  • Update the state file after every action using scripts/update_state.sh.
  • Follow the 7-gate sequence (Init to Push) without skipping gates.
  • Never reply to Copilot comments; perform silent fixes only and avoid extra API calls.

Example Use Cases

  • A PR contains mixed bot comments from CodeRabbit and Greptile; pr-patrol starts at gate 0, validates comments at gate 2, applies fixes at gate 3, and pushes updates after gate 6.
  • Validator passes for a set of review suggestions; fixes are committed and checks run before moving to the reply phase.
  • Several bot comments require aggregated responses; pr-patrol compiles a single summarized reply and posts it after gate 5.
  • Copilot-generated issues require silent fixes; no replies are made and the state advances to the next push.
  • New bot comments appear mid-cycle; the process restarts at gate 0 or cycles to gate 2 based on next_gate logic, ensuring continuous gating.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers