| name | pr-review-automation |
| description | Use when Gemini bot completes PR review with priority labels (๐ด๐ก๐ขโช) - MANDATORY loop until meaningfulUnprocessedCount=0, then automatically processes new feedback by priority with 3-minute polling, state tracking for resumable processing, and @superpowers:executing-plans integration |
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-plans for 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
gh auth login
gh --version
-
Node.js and npm: For running TypeScript scripts
-
jq (optional): For parsing JSON output from npm run pr-state
Common jq usage examples:
npm run pr-state -- --pr 9 | jq .meaningfulUnprocessedCount
npm run pr-state -- --pr 9 | jq '.comments[] | select(.processed == false and .priority != "NONE")'
npm run pr-state -- --pr 9 | jq '.comments[] | select(.createdAt >= "2025-10-30T04:50:00Z" and .priority != "NONE")'
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-loop or npm run pr-auto for 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 = 0 AND
- 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!)
while true; do
npm run pr-state -- --pr <PR_NUMBER>
done
MANDATORY loop until meaningful feedback = 0:
- MUST process ALL meaningful feedback before requesting new reviews
- Check
meaningfulUnprocessedCount in 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:
console.log('=== STEP 0: Processing ALL existing feedback ===');
let existingFeedbackLoop = 0;
const MAX_FEEDBACK_LOOPS = 10;
while (existingFeedbackLoop < MAX_FEEDBACK_LOOPS) {
existingFeedbackLoop++;
console.log(`\n--- Existing Feedback Loop ${existingFeedbackLoop} ---`);
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...');
const meaningful = state.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) {
console.log(`Processing ${priority}: ${item.file}:${item.line}`);
await processFeedbackWithSuperpower(item);
await markCommentProcessed(prNumber, item.id);
}
}
await commitAndPush(`fix: address existing Gemini feedback - loop ${existingFeedbackLoop}`);
console.log('๐ Checking for remaining feedback...');
}
console.log('โ
All existing feedback processed - now proceeding with workflow');
1. Check for Unreviewed Commits
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)
git push origin feature-branch
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 review before polling
- If bot errors during manual review: Re-run
/gemini review in PR comments
- If no feedback found during polling: Loop continues checking (no automatic re-review)
3. Fetch PR Comments with State Tracking
/pr-comments
/pr-comments <PR_NUMBER>
npm run pr-state -- --pr <PR_NUMBER>
State tracking integration:
/pr-comments (built-in) returns all review comments
npm run pr-state loads .pr-review-state-<PR>.json to 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)
let iteration = 0;
const MAX_ITERATIONS = 10;
while (iteration < MAX_ITERATIONS) {
iteration++;
console.log(`\n=== Review Cycle ${iteration} ===`);
const state = loadState(prNumber);
const comments = await fetchPRComments(prNumber);
const parsed = parseComments(comments, state);
const unprocessed = parsed.filter(c => !c.processed);
const meaningful = unprocessed.filter(isMeaningfulFeedback);
if (meaningful.length === 0) {
console.log('โ
No meaningful feedback remaining - DONE!');
break;
}
console.log(`Found ${meaningful.length} meaningful feedback items to process`);
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) {
await processFeedbackWithSuperpower(item);
await markCommentProcessed(prNumber, item.id);
}
}
await commitAndPush(`fix: address Gemini review feedback - cycle ${iteration}`);
console.log('Waiting 3 minutes for Gemini bot review...');
await sleep(3 * 60 * 1000);
}
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:
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} ===`);
const reviewResult = await dispatchCodeReviewer();
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...`);
for (const issue of meaningfulIssues) {
await fixIssue(issue);
}
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();
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)
git add .
git commit -m "fix: address Gemini review feedback - cycle 1"
git push origin feature-branch
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:
import { checkForMeaningfulFeedback, hasUnreviewedCommits, requestGeminiReview } from './pr-review-loop';
let cycle = 0;
const MAX_CYCLES = 10;
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...');
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);
}
}
await commitAndPush('fix: address existing Gemini review feedback');
console.log('โ
Existing feedback processed - now proceeding with workflow');
}
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++;
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 ===`);
const meaningful = 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);
}
}
await commitAndPush(`fix: address Gemini review feedback - cycle ${cycle}`);
console.log('Waiting 3 minutes for Gemini review...');
await sleep(180000);
}
Quick Reference
Auto Mode = Ralph-Loop (DEFAULT)
/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-comments command 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
meaningfulUnprocessedCount repeatedly โ 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>.json to avoid duplicates
- โ
Use
@superpowers:executing-plans for systematic fixes
- โ
Retry with
/gemini review on 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:
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
gh pr comment <PR_NUMBER> --body "/gemini review"
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:
npm run pr-loop -- --wait
Implementation Checklist
Step 0: Process ALL existing feedback (LOOP until count = 0):
Step 1: Check for unreviewed commits (only after Step 0 complete):
Each review cycle (automated):
During processing (each cycle):
Local Code Review Loop (MANDATORY after ANY code change):
After each cycle (automated):
Loop termination:
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-plans ensures 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