PR Review Automation
Overview
Systematic workflow for processing Gemini bot PR review feedback with priority-based filtering, state tracking for resumable processing, and superpower skill integration. MANDATORY: Loop until meaningfulUnprocessedCount = 0 before ANY other action. Automatically continues until no meaningful feedback remains.
Ralph Loop is DEFAULT: When "auto" mode is detected, Ralph-loop is automatically used for fully autonomous PR review processing. No manual intervention needed!
Core principles:
- LOOP until meaningful feedback = 0: Process ALL existing feedback before ANY other action (CRITICAL!)
- Never skip existing feedback: Check and process until
meaningfulUnprocessedCount = 0 - Check unreviewed commits: Only after ALL existing feedback is processed
- Loop until done: Continuously process new feedback until no meaningful items remain
- Ralph-powered automation (DEFAULT): "auto" mode triggers Ralph-loop automatically
- Process feedback systematically using GitHub API and priority filtering
- Track state to avoid duplicate processing
- Use
@superpowers:executing-plansfor high-quality fixes - Poll every 3 minutes for faster feedback cycles
- Resume from last processed feedback if interrupted
- Automatically detect meaningful feedback (CRITICAL, IMPORTANT, and impactful NICE-TO-HAVE)
Workflow Overview
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PR Review Automation (Ralph-Loop) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. Check if Gemini review exists on PR β
β ββ YES β Go to step 4 β
β ββ NO β Continue to step 2 β
β β
β 2. Post "/gemini review" comment β
β gh pr comment <PR> --body "/gemini review" β
β ββ Error? β Retry (max 3 times) β
β ββ Success β Continue β
β β
β 3. β³ WAIT 3 MINUTES for Gemini to respond β
β ββ Still no response? β Retry step 2 (max 2 times) β
β β
β 4. Check meaningfulUnprocessedCount β
β npm run pr-state -- --pr <PR> β
β ββ = 0 AND no unreviewed commits β
β β β EXIT: Output <promise>DONE</promise> β
β ββ > 0 β Continue to step 5 β
β β
β 5. Process feedback by priority (CRITICAL β IMPORTANT) β
β Use @superpowers:executing-plans for each fix β
β β
β 6. β
LOCAL CODE REVIEW LOOP β
β
β while (Critical/Important issues exist): β
β β Run superpowers:code-reviewer β
β β Fix issues (fix = code change = review again!) β
β β
β 7. Commit and push β
β git add -A && git commit && git push β
β β
β 8. Loop back to step 1 (Ralph auto-feeds same prompt) β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Prerequisites
Required tools:
GitHub CLI (
gh): MUST be installed and authenticated# Install gh CLI # macOS: brew install gh # Linux: See https://github.com/cli/cli/blob/trunk/docs/install_linux.md # Windows: See https://github.com/cli/cli#windows # Authenticate gh auth login # Verify gh --versionNode.js and npm: For running TypeScript scripts
jq (optional): For parsing JSON output from
npm run pr-state
Common jq usage examples:
# Check meaningfulUnprocessedCount only
npm run pr-state -- --pr 9 | jq .meaningfulUnprocessedCount
# Get all unprocessed meaningful feedback
npm run pr-state -- --pr 9 | jq '.comments[] | select(.processed == false and .priority != "NONE")'
# Get feedback created after a specific time
npm run pr-state -- --pr 9 | jq '.comments[] | select(.createdAt >= "2025-10-30T04:50:00Z" and .priority != "NONE")'
# Summary with first 100 chars of body
npm run pr-state -- --pr 9 | jq '{
meaningfulUnprocessedCount,
latestReview: [
.comments[]
| select(.createdAt >= "2025-10-30T04:50:00Z" and .priority != "NONE")
| {id, priority, createdAt, body: .body[0:100]}
]
}'
Important jq notes:
- Use single quotes to avoid shell escaping issues
!=not\!=for not-equal operator.body[0:100]not.body[:100]for substring- Wrap filter in
{ }for object output,[ ]for array output
When to Use
- Gemini bot posted review comment on PR
- Multiple feedback items with priority labels
- Need to filter false positives and nitpicks
- Want automated, repeatable processing
- AUTO MODE (DEFAULT = Ralph-loop): User requests "auto" mode β Ralph-loop executes automatically
- MANUAL MODE: Explicit
/ralph-loopornpm run pr-autofor fine-grained control
Workflow
Operating Modes
IMPORTANT: All npm commands must be executed from the plugin directory (devnogari-claude-plugins). Always navigate to the plugin directory with cd before running npm commands.
RALPH MODE (DEFAULT - Fully Autonomous):
- Trigger: User says "auto" β Ralph-loop executes automatically
- Behavior: Ralph handles the entire loop - Claude iterates autonomously until done
- No manual intervention: Ralph's stop hook feeds the same prompt back automatically
- Loop: Continues until completion promise is TRUE (meaningfulUnprocessedCount = 0)
- This is the DEFAULT when "auto" is detected
Ralph Mode Invocation (executed when "auto" detected):
Use the Skill tool to invoke ralph-loop:
Skill: ralph-loop
Args: Process Gemini PR review for PR #<NUMBER> --completion-promise DONE --max-iterations 20
Step-by-Step Iteration Guide (EACH Ralph iteration):
ITERATION START
β
ββ Step 1: Check if Gemini review exists
β gh pr view <PR> --json comments --jq '.comments[] | select(.author.login | contains("gemini"))'
β ββ EXISTS β Skip to Step 4
β ββ NOT EXISTS β Continue to Step 2
β
ββ Step 2: Post "/gemini review" comment
β gh pr comment <PR> --body "/gemini review"
β ββ Error? β Retry (max 3 times)
β ββ Success β Continue to Step 3
β
ββ Step 3: Wait for Gemini response
β β³ sleep 180 (3 minutes)
β Check if Gemini responded:
β ββ YES β Continue to Step 4
β ββ NO β Retry Step 2 (max 2 retries total)
β
ββ Step 4: Check feedback status
β cd <plugin-dir> && npm run pr-state -- --pr <PR>
β
β meaningfulUnprocessedCount = 0 AND no unreviewed commits?
β ββ YES β Output: <promise>DONE</promise>
β β β
EXIT LOOP β
β ββ NO β Continue to Step 5
β
ββ Step 5: Process feedback by priority
β CRITICAL β IMPORTANT β NICE-TO-HAVE
β Use @superpowers:executing-plans for each fix
β
ββ Step 6: Local Code Review Loop
β while (Critical/Important issues exist):
β Run superpowers:code-reviewer
β Fix issues
β (Fix = code change = must review again!)
β
ββ Step 7: Commit and push
β git add -A && git commit -m "fix: address Gemini feedback"
β git push
β
ββ Step 8: Ralph auto-feeds same prompt β Back to Step 1
CRITICAL EXIT CONDITION:
- ONLY output
<promise>DONE</promise>when:meaningfulUnprocessedCount = 0AND- No unreviewed commits exist
- Do NOT lie to exit the loop!
SCRIPT MODE (Legacy - Optional):
- Command:
cd /path/to/devnogari-claude-plugins && npm run pr-auto - Behavior: Orchestrates the full loop - checks feedback and exits with code 2 when found
- Claude Code Integration: When exit code 2, process feedback, commit, push, then re-run script
- Loop: Continues until meaningfulUnprocessedCount = 0
- Use when: Ralph-loop unavailable or need script-based control
MANUAL MODE (Single Check):
- Command:
npm run pr-loop -- --wait - Behavior: Checks once for feedback and reports status
- Claude Code Integration: Claude manually implements the loop based on exit code
- Use when: Need single status check or manual control
For AUTO mode, the /devnogari:pr-review auto command will automatically execute Ralph-loop.
0. Process ALL Existing Feedback FIRST (PRIORITY!)
# CRITICAL: Loop until meaningful feedback reaches 0
# Do NOT proceed to next steps while meaningful feedback exists
while true; do
npm run pr-state -- --pr <PR_NUMBER>
# Check meaningfulUnprocessedCount in output
# If 0 -> break and proceed to next step
# If > 0 -> process all feedback, commit, push, repeat
done
MANDATORY loop until meaningful feedback = 0:
- MUST process ALL meaningful feedback before requesting new reviews
- Check
meaningfulUnprocessedCountin the output - If > 0 β Process feedback, commit, push, check again
- Repeat until meaningfulUnprocessedCount = 0
- Only then proceed to Step 1 (check unreviewed commits)
Critical importance:
- ALL existing feedback MUST be processed before moving forward
- Do NOT stop after processing once - continue until count = 0
- Processing existing feedback first maintains review quality
- Prevents overwhelming reviewers with repeated review requests
- Ensures all feedback is systematically addressed
Complete loop example:
// Step 0: LOOP until all existing feedback is processed
console.log('=== STEP 0: Processing ALL existing feedback ===');
let existingFeedbackLoop = 0;
const MAX_FEEDBACK_LOOPS = 10; // Safety limit
while (existingFeedbackLoop < MAX_FEEDBACK_LOOPS) {
existingFeedbackLoop++;
console.log(`\n--- Existing Feedback Loop ${existingFeedbackLoop} ---`);
// Check for existing feedback
const state = await checkForMeaningfulFeedback(prNumber);
if (state.data.meaningfulUnprocessedCount === 0) {
console.log('β
No more existing feedback - proceeding to next step');
break;
}
console.log(`β οΈ Found ${state.data.meaningfulUnprocessedCount} unprocessed feedback items`);
console.log('π Processing all feedback in this loop...');
// Filter meaningful unprocessed feedback
const meaningful = state.data.comments.filter(c =>
!c.processed && isMeaningfulFeedback(c)
);
// Process by priority
for (const priority of ['CRITICAL', 'IMPORTANT', 'NICE-TO-HAVE']) {
const items = meaningful.filter(c => c.priority === priority);
for (const item of items) {
console.log(`Processing ${priority}: ${item.file}:${item.line}`);
// Use @superpowers:executing-plans for each feedback item
await processFeedbackWithSuperpower(item);
// Mark as processed immediately
await markCommentProcessed(prNumber, item.id);
}
}
// Commit and push
await commitAndPush(`fix: address existing Gemini feedback - loop ${existingFeedbackLoop}`);
console.log('π Checking for remaining feedback...');
// Loop continues - will check again
}
console.log('β
All existing feedback processed - now proceeding with workflow');
1. Check for Unreviewed Commits
# After processing existing feedback, check if there are commits that haven't been reviewed
# If unreviewed commits exist, request Gemini review
npm run pr-loop -- --wait
Automatic unreviewed commit detection:
- Compare latest commit timestamp with last Gemini bot review time
- If commits exist after last review β automatically request
/gemini review - The script then enters the main polling loop to wait for and process feedback
This ensures:
- No commits are left unreviewed
- All feedback is based on latest code
- Automated review request without manual intervention
2. Wait for Gemini Review (3 minutes)
# After PR push, wait 3 minutes for Gemini bot
git push origin feature-branch
# β Check for unreviewed commits (automatic)
# β Request review if needed (automatic)
# β Initial 3-minute wait for Gemini to respond
# β Poll for Gemini comment every 3 minutes
Polling behavior:
- After requesting review, waits 3 minutes before first check
- Check every 3 minutes for new review comments
- Track processed feedback to avoid duplication
- Resume from last processed feedback if re-triggered
Error handling:
- If unreviewed commits detected at start: Automatically requests
/gemini reviewbefore polling - If bot errors during manual review: Re-run
/gemini reviewin PR comments - If no feedback found during polling: Loop continues checking (no automatic re-review)
3. Fetch PR Comments with State Tracking
# Use built-in /pr-comments command to get latest Gemini feedback
/pr-comments
# Or for specific PR number
/pr-comments <PR_NUMBER>
# Load state to track processed feedback
npm run pr-state -- --pr <PR_NUMBER>
State tracking integration:
/pr-comments(built-in) returns all review commentsnpm run pr-stateloads.pr-review-state-<PR>.jsonto identify processed feedback- Automatically filters out already-processed items
- Enables safe re-runs without duplicate fixes
State file format (.pr-review-state-123.json):
{
"prNumber": 123,
"processedIds": ["comment-abc123"],
"lastCheckTime": 1698765432000,
"lastCommitSha": "abc123def"
}
4. Parse Priority Levels
| Priority | Label | Action |
|---|---|---|
| π΄ CRITICAL | HIGH | Always fix - blocking issues |
| π‘ IMPORTANT | MEDIUM | Always fix - stability/quality |
| π’ NICE-TO-HAVE | LOW | Fix if meaningful - readability only |
| βͺ NITPICK | VERY_LOW | Skip - documentation polish |
| β FALSE POSITIVE | IGNORE | Skip - bot error |
5. Filter Meaningful Feedback
Include:
- π΄ Critical (security, data loss, crashes)
- π‘ Important (error handling, edge cases)
- π’ Nice-to-have ONLY IF impacts maintainability (not just style)
Exclude:
- βͺ Nitpicks (documentation examples, comment style)
- β False positives (unused imports actually used as types)
6. Process by Priority with State Tracking (Loop Until Done)
// LOOP: Continue until no meaningful feedback remains
let iteration = 0;
const MAX_ITERATIONS = 10; // Safety limit
while (iteration < MAX_ITERATIONS) {
iteration++;
console.log(`\n=== Review Cycle ${iteration} ===`);
// Load state to resume from last processed feedback
const state = loadState(prNumber);
// Fetch and filter feedback
const comments = await fetchPRComments(prNumber);
const parsed = parseComments(comments, state);
const unprocessed = parsed.filter(c => !c.processed);
const meaningful = unprocessed.filter(isMeaningfulFeedback); // NEW: Auto-filter
// Check if we're done
if (meaningful.length === 0) {
console.log('β
No meaningful feedback remaining - DONE!');
break;
}
console.log(`Found ${meaningful.length} meaningful feedback items to process`);
// Process in order by priority
const priorities = ['CRITICAL', 'IMPORTANT', 'NICE-TO-HAVE'];
for (const priority of priorities) {
const items = meaningful.filter(f => f.priority === priority);
for (const item of items) {
// Use superpower skill for processing feedback
await processFeedbackWithSuperpower(item);
// Mark as processed immediately
await markCommentProcessed(prNumber, item.id);
}
}
// Commit and push changes
await commitAndPush(`fix: address Gemini review feedback - cycle ${iteration}`);
// Wait for Gemini to review (3 minutes)
console.log('Waiting 3 minutes for Gemini bot review...');
await sleep(3 * 60 * 1000);
// Loop continues to check for new feedback
}
Loop features:
- Automatic continuation: No manual intervention needed
- Meaningful feedback detection: Filters CRITICAL, IMPORTANT, and impactful NICE-TO-HAVE
- Safe termination: Stops when no meaningful feedback remains
- State tracking: Prevents duplicate processing across cycles
- Safety limit: Maximum 10 iterations to prevent infinite loops
Meaningful feedback criteria:
- β CRITICAL: Always meaningful (security, data loss, crashes)
- β IMPORTANT: Always meaningful (error handling, edge cases)
- β NICE-TO-HAVE: Meaningful if contains keywords like "error", "bug", "performance", "maintainability"
- β NITPICK: Never meaningful (documentation, style)
- β NONE: Never meaningful (uncategorized)
6.5. Local Code Review Loop (MANDATORY after ANY code change)
ν΅μ¬ μμΉ: λ‘컬 λ³κ²½ μ¬νμ΄ μμΌλ©΄ β νμ local code review β meaningful issue μμ λκΉμ§ λ°λ³΅
CRITICAL: Fixλ μ½λ λ³κ²½μ΄λ―λ‘, fix νμλ λ€μ review νμ!
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LOCAL CODE REVIEW LOOP β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Code changed? (Gemini fix, local fix, ANY edit) β
β β β
β Run @superpowers:code-reviewer β
β β β
β Meaningful issues (Critical/Important)? β
β ββ YES β Fix issues β LOOP BACK (fix = code change!) β
β ββ NO β β
Ready to commit β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Process:
// MANDATORY: Run after ANY code change
async function runLocalCodeReviewLoop(maxIterations = 5): Promise<void> {
let iteration = 0;
let hasChanges = true;
while (hasChanges && iteration < maxIterations) {
iteration++;
console.log(`\n=== Local Code Review Loop ${iteration}/${maxIterations} ===`);
// 1. Run superpowers:code-reviewer via Task agent
const reviewResult = await dispatchCodeReviewer();
// 2. Check for meaningful issues (Critical or Important only)
const meaningfulIssues = reviewResult.issues.filter(
issue => issue.severity === 'Critical' || issue.severity === 'Important'
);
if (meaningfulIssues.length === 0) {
console.log('β
No meaningful issues - local review complete');
hasChanges = false;
break;
}
console.log(`β οΈ Found ${meaningfulIssues.length} meaningful issues - fixing...`);
// 3. Fix ALL meaningful issues
for (const issue of meaningfulIssues) {
await fixIssue(issue);
}
// 4. Loop back for re-review (fix = code change!)
console.log('π Code changed by fixes - will review again...');
}
if (iteration >= maxIterations) {
console.warn('β οΈ Max iterations reached - review manually');
}
}
Integration Point:
for (const item of meaningfulFeedback) {
await processFeedbackWithSuperpower(item);
await runLocalCodeReviewLoop(); // MANDATORY after code change
await markCommentProcessed(prNumber, item.id);
}
await commitAndPush(`fix: address Gemini feedback - cycle ${cycle}`);
Why Loop Back After Fix:
- Fix = Code Change = Must Review Again
- Issue A fix might introduce Issue B
- Only exit when NO meaningful issues remain
7. Commit and Push (Automated in Loop)
# Automatic commits per cycle
git add .
git commit -m "fix: address Gemini review feedback - cycle 1"
git push origin feature-branch
# β Wait 3 minutes automatically
# β Check for new feedback
# β Repeat until no meaningful feedback
# β State tracking ensures no duplicate processing
Superpower skill integration:
Uses @superpowers:executing-plans for systematic feedback processing:
- Analyzes each feedback item individually
- Generates targeted fixes with proper context
- Validates changes before committing
- Maintains code quality throughout
- Tracks progress in state file after each fix
Complete workflow example with loop:
// NEW: Use pr-review-loop for automatic continuous processing
import { checkForMeaningfulFeedback, hasUnreviewedCommits, requestGeminiReview } from './pr-review-loop';
let cycle = 0;
const MAX_CYCLES = 10;
// 0. Check for existing feedback FIRST (CRITICAL!)
console.log('=== STEP 0: Checking for existing feedback ===');
const existingFeedback = await checkForMeaningfulFeedback(prNumber);
if (existingFeedback.data.meaningfulUnprocessedCount > 0) {
console.log(`β οΈ Found ${existingFeedback.data.meaningfulUnprocessedCount} unprocessed feedback items`);
console.log('π Processing existing feedback before requesting new review...');
// Process existing feedback by priority
const meaningful = existingFeedback.data.comments.filter(c => !c.processed && isMeaningfulFeedback(c));
for (const priority of ['CRITICAL', 'IMPORTANT', 'NICE-TO-HAVE']) {
const items = meaningful.filter(c => c.priority === priority);
for (const item of items) {
await processFeedbackWithSuperpower(item);
await markCommentProcessed(prNumber, item.id);
}
}
// Commit and push existing feedback fixes
await commitAndPush('fix: address existing Gemini review feedback');
console.log('β
Existing feedback processed - now proceeding with workflow');
}
// 1. Check for unreviewed commits
console.log('=== STEP 1: Checking for unreviewed commits ===');
const needsReview = hasUnreviewedCommits(prNumber);
if (needsReview) {
console.log('β οΈ Unreviewed commits detected - requesting Gemini review');
const reviewRequested = requestGeminiReview(prNumber);
if (!reviewRequested) {
console.error('Failed to request Gemini review - continuing anyway');
}
}
while (cycle < MAX_CYCLES) {
cycle++;
// 1. Check for meaningful feedback
const { hasMeaningfulFeedback, data } = await checkForMeaningfulFeedback(prNumber);
if (!hasMeaningfulFeedback) {
console.log('β
Review complete - no meaningful feedback remaining');
break;
}
console.log(`\n=== Cycle ${cycle}: Processing ${data.meaningfulUnprocessedCount} items ===`);
// 2. Filter meaningful unprocessed comments
const meaningful = data.comments.filter(c =>
!c.processed && isMeaningfulFeedback(c)
);
// 3. Process by priority with superpower
for (const priority of ['CRITICAL', 'IMPORTANT', 'NICE-TO-HAVE']) {
const items = meaningful.filter(c => c.priority === priority);
for (const item of items) {
await processFeedbackWithSuperpower(item); // Uses @superpowers:executing-plans
await markCommentProcessed(prNumber, item.id);
}
}
// 4. Commit and push
await commitAndPush(`fix: address Gemini review feedback - cycle ${cycle}`);
// 5. Wait for Gemini (3 minutes)
console.log('Waiting 3 minutes for Gemini review...');
await sleep(180000);
// Loop automatically continues
}
Quick Reference
Auto Mode = Ralph-Loop (DEFAULT)
# When user says "auto", this executes automatically:
/ralph-loop "Process Gemini PR #<NUMBER> feedback. Check npm run pr-state, fix by priority, commit, push, repeat. Output <promise>DONE</promise> when meaningfulUnprocessedCount=0" --completion-promise "DONE" --max-iterations 20
Operating Mode Selection
Which mode to use?
ββ User says "auto"? β RALPH MODE (DEFAULT - auto-executed)
β ββ /ralph-loop with completion promise
ββ Need script-based control? β SCRIPT MODE (legacy)
β ββ npm run pr-auto
ββ Need single check? β MANUAL MODE
ββ npm run pr-loop -- --wait
Priority Decision Tree
Is it π΄ CRITICAL or π‘ IMPORTANT?
ββ Yes β Fix immediately
ββ No β Is it π’ NICE-TO-HAVE?
ββ Yes β Does it impact maintainability? (not just style)
β ββ Yes β Fix
β ββ No β Skip
ββ No β Skip (βͺ NITPICK or β FALSE POSITIVE)
Local Code Review Quick Reference
When: After fixing each Gemini feedback item, BEFORE committing
Command: Use Task tool with superpowers:code-reviewer agent
Loop Condition: Continue until no Critical or Important issues
Max Iterations: 5 (safety limit)
Issue Severity Mapping:
| Code Reviewer | Action |
|---|---|
| Critical | Must fix immediately |
| Important | Must fix before commit |
| Minor | Note for later |
Meaningful vs Nitpick Examples
| Feedback | Priority | Action | Reasoning |
|---|---|---|---|
| Missing error handling | π‘ IMPORTANT | β Fix | Prevents crashes |
Variable data β userData |
π’ NICE-TO-HAVE | β οΈ Maybe | Only if used widely |
| Add README example | βͺ NITPICK | β Skip | Documentation polish |
| "Unused import" (actually used) | β FALSE POSITIVE | β Skip | Bot error |
Common Mistakes (RED FLAGS)
β DON'T:
- β Stop after processing feedback once β LOOP until meaningfulUnprocessedCount = 0! (CRITICAL!)
- β Request new review with existing feedback β Process ALL existing feedback first! (CRITICAL!)
- β Assume one pass is enough β ALWAYS check again after processing
- β Stop after one cycle β Use loop to continue until done
- β Manually check for new feedback β Let automation loop
- β "Time pressure" β Skip important fixes (π‘ is never optional)
- β "Perfect is enemy of good" β Ignore critical issues (π΄ must be fixed)
- β "Follow-up PR acceptable" β Defer security fixes (blocking issues never deferred)
- β Process nitpicks (βͺ) β Wastes time on non-issues
- β Manually read comments β Use
/pr-commentscommand instead - β Skip false positives check β Wastes time on bot errors
- β Process same feedback twice β Use state tracking
β DO:
- β LOOP until meaningfulUnprocessedCount = 0 β Never skip this check! (CRITICAL!)
- β Check feedback after EVERY processing cycle β Process, commit, check again
- β Use while loop pattern β Continue until count reaches 0
- β
Check
meaningfulUnprocessedCountrepeatedly β Don't trust one check - β Always fix π΄ CRITICAL + π‘ IMPORTANT (non-negotiable)
- β
Use
/pr-comments(built-in) to fetch review comments - β Wait 3 minutes for Gemini response after push (faster cycle)
- β
Track state with
.pr-review-state-<PR>.jsonto avoid duplicates - β
Use
@superpowers:executing-plansfor systematic fixes - β
Retry with
/gemini reviewon bot errors - β Filter false positives before processing
- β Commit per cycle (not batch)
- β Resume from last processed feedback if interrupted
Common Mistakes - Local Code Review Loop
β DON'T:
- β Fix ν review μ ν¨ β Fixλ μ½λ λ³κ²½! λ°λμ λ€μ review!
- β ν λ²λ§ review β meaningful issue μμ λκΉμ§ λ°λ³΅ν΄μΌ ν¨
- β Commit λ¨Όμ β Local review loop μλ£ μ μ commit κΈμ§
- β Minor issue fix β Critical/Importantλ§ fix (Minorλ 무μ)
- β 무ν λ°λ³΅ β max 5 iterations, κ·Έ μ΄μμ μλ κ²ν
β DO:
- β μ½λ λ³κ²½ β review (Gemini fix, local fix, ANY change)
- β Fix β λ€μ review (fixλ μ½λ λ³κ²½μ΄λ―λ‘)
- β Loop until no issues (meaningful issue 0μ΄ λ λκΉμ§)
- β Only then commit (loop μλ£ νμλ§ commit)
Loop Flow:
Code Change β Review β Issues? β YES β Fix β Review β Issues? β YES β Fix β Review β NO β β
Commit
Error Handling
GitHub CLI Not Found
Error: /bin/sh: 1: gh: not found
β Cause: GitHub CLI is not installed or not in PATH
β Action: Install and authenticate GitHub CLI (see Prerequisites section)
β Verify: gh --version
β Authenticate: gh auth login
Common installation issues:
- macOS:
brew install gh(requires Homebrew) - Linux (Debian/Ubuntu):
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null sudo apt update sudo apt install gh - Windows: Download from https://cli.github.com
jq Syntax Errors
Error: jq: error: syntax error, unexpected INVALID_CHARACTER
β Cause: Incorrect jq syntax or shell escaping issues
β Action: Use examples from Prerequisites section
β Common fixes:
- Use `!=` not `\!=` for not-equal
- Use `.body[0:100]` not `.body[:100]` for substring
- Wrap entire jq filter in single quotes
No Gemini Comment After 3 Minutes
# Manually trigger review
gh pr comment <PR_NUMBER> --body "/gemini review"
# Wait another 3 minutes
# Check again with: /pr-comments <PR_NUMBER>
Gemini Bot Error
Error: Gemini bot failed to complete review
β Action: Re-run `/gemini review` in PR comments
β Wait 5 minutes
β Continue workflow
/pr-comments Command Failure
Error: Command failed or no PR context
β Action: Ensure you're in a PR context or specify PR number explicitly
β Try: /pr-comments <PR_NUMBER>
β Fallback: Use `gh pr view <PR_NUMBER> --json comments`
State File Corruption
Error: Invalid state file format
β Action: The script automatically handles this by backing up the corrupted file
β Automatic behavior:
1. Corrupted file backed up to .pr-review-state-<PR>.json.backup
2. Fresh state file created automatically
3. Processing continues from clean slate
β Manual reset (if needed):
npm run pr-state -- --clear-state 123
β Result: Automation continues without manual file operations
Multiple Review Cycles (Automated Loop)
π AUTOMATIC LOOP (no manual intervention needed):
Cycle 1: Check feedback β 5 meaningful items found
β Fix CRITICAL + IMPORTANT β mark processed β push β wait 3 min
Cycle 2: Check feedback β 2 meaningful items found
β Fix new items β mark processed β push β wait 3 min
Cycle 3: Check feedback β 1 meaningful item found
β Fix item β mark processed β push β wait 3 min
Cycle 4: Check feedback β 0 meaningful items found
β β
DONE! Exit loop
β
State tracking prevents duplicate processing across cycles
β
Meaningful feedback detection filters nitpicks automatically
β
Loop terminates when no meaningful feedback remains
NEW: Using pr-review-loop script:
# Start automated loop (reports feedback, doesn't process)
npm run pr-loop -- --wait
# Exit codes:
# 0 = No meaningful feedback (done)
# 2 = Meaningful feedback found (needs processing)
# 1 = Error
Implementation Checklist
Step 0: Process ALL existing feedback (LOOP until count = 0):
- Start existing feedback loop
- Run
npm run pr-state -- --pr <PR_NUMBER> - Check
meaningfulUnprocessedCountin output - If count > 0:
- Process ALL meaningful feedback (CRITICAL, IMPORTANT, meaningful NICE-TO-HAVE)
- Use
@superpowers:executing-plansfor each item - Mark each item as processed immediately
- Commit and push changes
- π LOOP BACK: Run
npm run pr-stateagain
- If count = 0:
- β Proceed to Step 1
- NEVER proceed to Step 1 while count > 0
Step 1: Check for unreviewed commits (only after Step 0 complete):
- PR pushed successfully
- Confirm meaningfulUnprocessedCount = 0 from Step 0
- Check for unreviewed commits
- Request
/gemini reviewif unreviewed commits exist - Start polling loop with feedback check
- Load state to track processed items
Each review cycle (automated):
- Check for meaningful feedback with
npm run pr-state - If
meaningfulUnprocessedCount === 0β β DONE, exit loop - If meaningful feedback found β continue processing
During processing (each cycle):
- Process π΄ CRITICAL first (with
@superpowers:executing-plans) - Process π‘ IMPORTANT second (with
@superpowers:executing-plans) - Evaluate π’ NICE-TO-HAVE for meaningfulness (auto-filtered)
- Skip βͺ NITPICK items (auto-filtered)
- Skip β FALSE POSITIVE items (manual check)
- Mark each item as processed immediately
Local Code Review Loop (MANDATORY after ANY code change):
- Code changed? (Gemini fix, local fix, any edit)
- Run
@superpowers:code-reviewer - Check for Critical/Important issues
- If issues found:
- Fix all meaningful issues
- π LOOP BACK - fixλ μ½λ λ³κ²½μ΄λ―λ‘ λ€μ review!
- If no issues:
- β Ready to commit
- Only commit when NO meaningful issues remain
After each cycle (automated):
- Commit changes with cycle number
- Push to PR branch
- Wait 3 minutes for Gemini review
- Loop back to check for new feedback
Loop termination:
- No meaningful feedback remaining
- Or maximum iterations reached (safety limit)
- Final state file updated
- All changes pushed
Real-World Impact
π With Ralph Loop (ν΅μ¬: μμ μμ¨ μ²λ¦¬):
- Human intervention: 100% β 0% (fully autonomous)
- Context switching: Eliminated (Ralph handles everything)
- Overnight processing: Possible (walk away, come back to approved PR)
- Consistency: Perfect (same process every time)
- Error recovery: Automatic (Ralph retries on failure)
With Local Code Review Loop (ν΅μ¬: μ½λ λ³κ²½ β review λ°λ³΅):
- Review rounds reduced: 3-4 β 1-2 (50% reduction)
- Time per PR: 20-25 min β 15-20 min
- First-fix quality: 70% β 95%
- Gemini re-review triggers: Reduced by 80%
- Cascading issues caught: 90% (fixκ° μ issue λ§λλ κ²½μ°)
ν΅μ¬ μμΉ μ μ© ν¨κ³Ό:
BEFORE (No local loop): AFTER (Local review loop):
Gemini fix β Commit β Push Gemini fix β Local Review
β Gemini finds new issue β Issue found β Fix
β Fix β Commit β Push β Local Review (fixλ λ³κ²½!)
β Gemini finds another issue β Issue found β Fix
β Fix β Commit β Push β Local Review
β Done (4 rounds) β No issues β Commit β Push
β Gemini finds nothing β Done β
Rounds: 4 Rounds: 1
Wait time: 12 min (3min Γ 4) Wait time: 3 min (3min Γ 1)
Total: 25 min Total: 10 min
Why This Works:
- Fixλ μ½λ λ³κ²½ β λ€μ review β cascading issue μ¬μ λ°κ²¬
- Geminiκ° λ³Ό λλ μ΄λ―Έ cleanν μ½λ
- 3λΆ λκΈ° μκ° μ΅μν (1νλ§ λκΈ°)
NEW: Mandatory feedback loop benefits:
- Zero skipped feedback: Guarantees ALL meaningful feedback is processed
- Prevention of review spam: No new review requests while feedback exists
- Complete cleanup: Ensures meaningful feedback count reaches 0 before moving on
- Better review quality: Reviewers never see repeated unaddressed issues
- Reduced back-and-forth: Average 2-3 review rounds vs 5-6 without loop
Loop automation benefits:
- Fully automated: Zero manual intervention from push to approval
- Time saved: 30-60 min per PR (no manual re-checking needed)
- Faster completion: Average 3-4 cycles vs 6-8 manual cycles
- Error reduction: 90% fewer wasted fixes with meaningful feedback detection
Existing benefits:
- Faster cycles: 3-minute polling (down from 5 minutes) = 40% faster feedback
- Time saved per cycle: 15-20 min (no manual comment parsing)
- Error reduction: 80% fewer wasted fixes on nitpicks/false positives
- Resumability: State tracking enables safe interruption and resumption
- Quality:
@superpowers:executing-plansensures systematic, high-quality fixes - Consistency: Same filtering logic across team members
- Automation: GitHub API integration enables CI/CD workflows
- Efficiency: No duplicate work when re-running automation
Comparison:
BEFORE (Manual): AFTER (Loop until count = 0):
Push β Wait β Check β Process Push β Loop existing feedback until 0
β Push β Wait β Check β Process β Check unreviewed β Request review
β Push β Wait β Check β Process β Loop new feedback (automatic) β Done β
β ... (repeat 6-8 times)
β Often miss some feedback Time: 20-25 min
Time: 90-120 min Review rounds: 2-3
Review rounds: 5-6 Intervention: 0
Intervention: Every cycle Skipped feedback: 0 β
Skipped feedback: 20-30% Auto review request: Yes β
Ralph Mode is DEFAULT:
SCRIPT MODE (legacy): RALPH MODE (DEFAULT):
Human monitors loop Ralph handles loop autonomously
Script exits, human re-runs Stop hook feeds prompt back automatically
Context switches between runs Single continuous session
Manual error handling Automatic retry on failure
Time: 20-25 min (attended) Time: Same, but UNATTENDED
Intervention: After each script Intervention: 0 (truly hands-free)
When user says "auto" β Ralph-loop executes automatically
Converted and distributed by TomeVault β claim your Tome and manage your conversions.