
pr-patrol
by SmartOzzehir
๐ Claude Code plugins: pr-patrol (PR bot comment handler) & spec-interview (AI requirements gathering with 8-stage methodology)
SKILL.md
name: pr-patrol description: This skill should be used when the user asks to "handle bot comments", "fix PR review feedback", "address CodeRabbit/Greptile/Copilot issues", "respond to review bot suggestions", "process automated review comments", or runs "/pr-patrol". Patrols the PR for bot comments (CodeRabbit, Greptile, Codex, Copilot, Sentry) with state tracking and batch processing through a 7-gate workflow. allowed-tools: Bash, Read, Edit, Write, Grep, Glob, Task, AskUserQuestion
PR Patrol
Process automated PR review comments through a 7-gate workflow with phase-based loading.
โ ๏ธ CRITICAL REMINDERS
- READ PHASE FILE FIRST - Check status in state file, read
phases/gate-{N}.mdfor current phase - USE AGENTS FOR VALIDATION - Use
bot-comment-validatorvia Task tool, never manual - ASK ABOUT PR-REVIEW AGENTS - After checks pass, ask about
code-reviewer/silent-failure-hunter - ISSUE COMMENTS NEED @MENTION - GitHub issue comments don't support threading
- UPDATE STATE FILE - After EVERY action (use
scripts/update_state.sh) - NEVER REPLY TO COPILOT - Silent fix only, no reactions, no replies
- TRUST SCRIPT OUTPUT - When scripts return data, DO NOT make extra API calls to "verify"!
Quick Reference
| Bot | Login | Reaction | Reply |
|---|---|---|---|
| CodeRabbit | coderabbitai[bot] | โ | โ |
| Greptile | greptile-apps[bot] | ๐/๐ FIRST | โ THEN |
| Codex | chatgpt-codex-connector[bot] | ๐/๐ FIRST | โ THEN |
| Copilot | Copilot | โ NEVER | โ NEVER |
| Sentry | sentry[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
| Status | Read This Phase File |
|---|---|
| (no file) | phases/gate-0-init.md |
initialized | phases/gate-1-collect.md |
collected | phases/gate-2-validate.md |
validated | phases/gate-3-fix.md |
fixes_planned | phases/gate-3-fix.md |
fixes_applied | phases/gate-3-fix.md (run checks) |
checks_passed | phases/gate-4-commit.md |
committed | phases/gate-5-reply.md |
replies_sent | phases/gate-6-push.md |
pushed | Check 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
"$SCRIPTS/detect_thread_states.sh" # State detection
"$SCRIPTS/check_new_comments.sh" owner repo pr # New since push
"$SCRIPTS/check_reply_status.sh" owner repo pr # Reply tracking
"$SCRIPTS/update_state.sh" file field value # State updates
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
| File | Purpose | When to Read |
|---|---|---|
phases/gate-{N}.md | Phase-specific instructions | Based on status |
bot-formats.md | Bot-specific protocols | MUST READ before Gate 5 |
templates.md | Reply message templates | Gate 5 (replies) |
Critical Rules
- EVERY gate requires AskUserQuestion - Never skip user approval
- ALL comments must be validated - Severity only affects priority
- Copilot gets NO response - Silent fix only, no reactions, no replies
- NEVER commit/push without approval - Explicit consent required
- NEVER force push - Blocked completely
- Typecheck/lint are MANDATORY - Block on failure
- ALWAYS use --paginate - Default GitHub API returns only 30 comments
- Fetch BOTH endpoints - Review comments (
/pulls/{pr}/comments) AND issue comments (/issues/{pr}/comments) - Extract embedded CodeRabbit comments - Use
parse_coderabbit_embedded.shfor nitpicks, duplicates, outside-diff - Issue vs PR review comments - Different reply methods! Issue comments need @mention (no threading)
- Reaction BEFORE reply - For Greptile/Codex/Sentry, add reaction first, then reply
- Short reply format - "Fixed in commit {sha}: {description}" NOT verbose essays
- Use helper scripts -
${CLAUDE_PLUGIN_ROOT}/skills/pr-patrol/scripts/has utilities - TRUST SCRIPT OUTPUT - When scripts return data, DO NOT make verification queries
jq Escaping Warning
CRITICAL: Shell escaping corrupts jq operators. This affects:
- Direct
jqcommands gh api --jqflag- Any inline jq in bash
Forbidden Patterns
# โ WRONG - "!=" gets escaped to "\!=" โ "unexpected token" error
jq '[.[] | select(.field != null)]'
gh api ... --jq '[.[] | select(.in_reply_to_id != null)]'
# โ WRONG - Same issue with "not null"
jq 'select(.x != "value")'
Safe Alternatives
# โ
CORRECT - Use truthy check (implicit null filter)
jq '[.[] | select(.field)]'
# โ
CORRECT - Use "| not" for negation
jq '[.[] | select(.bot == "Copilot" | not)]'
# โ
CORRECT - Use external .jq file for complex queries
jq -f "$SCRIPT_DIR/filter.jq"
Rule: For any jq with != or complex logic, use the scripts in scripts/ instead of inline jq.
ในใณใข
็ทๅในใณใข
ใชใใธใใชใฎๅ่ณชๆๆจใซๅบใฅใ่ฉไพก
SKILL.mdใใกใคใซใๅซใพใใฆใใ
ใฉใคใปใณในใ่จญๅฎใใใฆใใ
100ๆๅญไปฅไธใฎ่ชฌๆใใใ
GitHub Stars 100ไปฅไธ
1ใถๆไปฅๅ ใซๆดๆฐ
10ๅไปฅไธใใฉใผใฏใใใฆใใ
ใชใผใใณIssueใ50ๆชๆบ
ใใญใฐใฉใใณใฐ่จ่ชใ่จญๅฎใใใฆใใ
1ใคไปฅไธใฎใฟใฐใ่จญๅฎใใใฆใใ
ใฌใใฅใผ
ใฌใใฅใผๆฉ่ฝใฏ่ฟๆฅๅ ฌ้ไบๅฎใงใ
