PR Review Loop
Scanned@cemoso
npx machina-cli add skill @cemoso/pr-review-loop --openclawPR Review Loop
Autonomous cycle: Greptile reviews PR → agent fixes feedback → pushes → re-triggers → repeats until score ≥ 4/5 or max rounds.
Quick Start
When triggered with a PR URL or review payload:
# Run the review loop
bash scripts/pr-review-loop.sh <owner/repo> <pr-number>
Or invoke steps manually — see below.
Workflow
1. Fetch Review
# Get latest Greptile review
gh api "/repos/{owner}/{repo}/pulls/{pr}/reviews" \
--jq '[.[] | select(.user.login == "greptile-apps[bot]")] | last'
# Get inline comments
gh api "/repos/{owner}/{repo}/pulls/{pr}/comments" \
--jq '[.[] | select(.user.login == "greptile-apps[bot]")]'
2. Parse Score
Look for confidence/quality score in review body. Greptile typically includes a score like Score: X/5 or Confidence: X/5. Extract it:
- Score ≥ 4/5 → auto-merge
- Score < 4/5 → fix issues
- No score found → treat as needing fixes if there are comments, otherwise merge
3. Auto-Merge (score ≥ 4)
gh pr merge <number> --merge --delete-branch --repo <owner/repo>
4. Fix Issues (score < 4)
For each Greptile comment:
- Read the file and line referenced
- Understand the feedback
- Apply the fix
- Stage changes
Commit with a descriptive message listing each fix:
Address Greptile review feedback (round N)
- Fix X in path/to/file.ts
- Fix Y in path/to/other.ts
- Improve Z per reviewer suggestion
Push and re-trigger:
git push
gh pr comment <number> --repo <owner/repo> --body "@greptileai review"
5. Track State
Maintain review-state.json in workspace:
{
"owner/repo#123": {
"rounds": 2,
"maxRounds": 5,
"lastScore": 3,
"sameScoreCount": 1
}
}
Update after each round. Check exit conditions:
- rounds ≥ 5 → merge anyway, notify Master
- sameScoreCount ≥ 2 (same score 2 rounds in a row) → merge anyway, notify Master
6. Escalation
- Architectural decisions (review mentions architecture, design patterns, breaking changes) → ping Master on Telegram, don't auto-fix
- Max rounds reached → merge + notify Master with summary
- Unclear feedback → ask Master
Command Interface
Agents should respond to:
pr review <url>— start review loop on a PRpr review <owner/repo#number>— same, by referencepr status— show active review loops and their state
References
See references/greptile-patterns.md for common Greptile feedback patterns and fix strategies.
Overview
An autonomous PR review loop where Greptile examines a PR, the agent fixes feedback, pushes changes, and re-triggers the review until the score reaches 4/5 or higher. It auto-merges when the score is 4/5+ and can be started by pr review commands or Greptile webhooks.
How This Skill Works
Greptile reviews are fetched (latest review and inline comments) and the score is parsed from the body (Score: X/5 or Confidence: X/5). If score >= 4/5, the agent auto-merges the PR; otherwise it applies each fix, commits with a descriptive message, pushes, and re-triggers the review by commenting to Greptile. A review-state.json in the workspace tracks rounds and max rounds to drive exit conditions.
When to Use It
- When a PR is opened and you want automated, hands-off handling of Greptile feedback.
- When Greptile returns actionable feedback with specific file/line references needing fixes.
- When fixes span multiple files and you want automated re-checks after pushes.
- When you aim to auto-merge after a high Greptile score (4/5+).
- When feedback is unclear or architectural decisions are needed, triggering escalation paths.
Quick Start
- Step 1: Run the loop: bash scripts/pr-review-loop.sh <owner/repo> <pr-number>
- Step 2: The loop fetches Greptile reviews and scores, deciding to fix or merge automatically
- Step 3: After applying fixes, push changes and re-trigger the review until score >= 4/5 or max rounds
Best Practices
- Keep PRs focused and small to minimize cross-cutting fixes.
- Write commit messages that clearly list each Greptile-identified change.
- Push frequently and re-trigger reviews promptly to keep feedback current.
- Maintain review-state.json to track rounds, last score, and max rounds.
- Escalate architectural concerns to Master when feedback mentions design changes.
Example Use Cases
- PR receives a 3/5 score; the loop applies fixes across several files, commits a summary, pushes, and re-triggers the review.
- Greptile returns a 4/5 score; the loop auto-merges the PR and deletes the branch.
- No explicit score is found but there are comments; the loop proceeds with fixes and requests another review round.
- Feedback mentions architecture changes; the loop escalates to Master rather than auto-fixing.
- A PR is triggered via a webhook and the loop kicks off with pr review <url> to start the cycle.