home / skills / openclaw / skills / pr-review-loop

pr-review-loop skill

/skills/cemoso/pr-review-loop

This skill automates PR review loops by reading Greptile feedback, applying fixes, pushing updates, and auto-merging when score reaches 4/5.

npx playbooks add skill openclaw/skills --skill pr-review-loop

Review the files below or copy the command above to add this skill to your agents.

Files (4)
SKILL.md
2.9 KB
---
name: pr-review-loop
description: Autonomous PR review loop with Greptile. Use when an agent creates a PR and needs to autonomously handle code review feedback — reading Greptile reviews, fixing issues, pushing fixes, re-triggering review, and auto-merging when score is 4/5+. Trigger on commands like "pr review {url}", "review my PR", or when a Greptile review webhook/poll delivers feedback.
---

# PR 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:

```bash
# Run the review loop
bash scripts/pr-review-loop.sh <owner/repo> <pr-number>
```

Or invoke steps manually — see below.

## Workflow

### 1. Fetch Review

```bash
# 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)

```bash
gh pr merge <number> --merge --delete-branch --repo <owner/repo>
```

### 4. Fix Issues (score < 4)

For each Greptile comment:
1. Read the file and line referenced
2. Understand the feedback
3. Apply the fix
4. 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:
```bash
git push
gh pr comment <number> --repo <owner/repo> --body "@greptileai review"
```

### 5. Track State

Maintain `review-state.json` in workspace:
```json
{
  "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 PR
- `pr review <owner/repo#number>` — same, by reference
- `pr status` — show active review loops and their state

## References

See `references/greptile-patterns.md` for common Greptile feedback patterns and fix strategies.

Overview

This skill implements an autonomous PR review loop that reads Greptile reviews, applies fixes, re-submits changes, and auto-merges when quality thresholds are met. It runs iteratively until the PR reaches an acceptable score or predefined exit conditions trigger escalation. Use it to automate back-and-forth review cycles so agents can complete PRs without manual intervention.

How this skill works

The skill fetches Greptile review bodies and inline comments, extracts a numeric score (e.g., "Score: X/5"), and decides whether to auto-merge or apply fixes. For low scores it reads referenced files/lines, makes targeted edits, commits and pushes changes, then re-triggers Greptile for another review. It tracks state per PR (rounds, last score, same-score streak) and escalates to a human when rules are met.

When to use it

  • An agent creates a PR and needs autonomous handling of Greptile feedback.
  • You want continuous cycles of review → fix → re-review until quality improves.
  • You need automated merging when Greptile confidence is high (≥ 4/5).
  • You want consistent state tracking across review rounds for multiple PRs.
  • When webhook/poll notifications deliver Greptile review payloads to trigger the loop.

Best practices

  • Ensure Greptile review comments include clear file/line references and a score tag (Score or Confidence).
  • Keep maxRounds conservative (default 5) to avoid endless churn; escalate rather than loop forever.
  • Use descriptive commit messages that enumerate fixes and the review round for traceability.
  • Treat architectural or ambiguous feedback as escalation items—notify a human reviewer instead of auto-fixing.
  • Maintain and back up review-state.json so interrupted runs resume safely.

Example use cases

  • Agent opens a documentation or bugfix PR and asks the skill to run 'pr review owner/repo#123' to complete the loop.
  • CI receives a Greptile webhook indicating review ready; the skill fetches feedback, applies fixes, pushes, and re-comments to trigger another review.
  • A team wants auto-merge for small, high-confidence changes: the skill auto-merges when Greptile score ≥ 4/5 and deletes the branch.
  • Handling repeated low-confidence rounds: after same-score or max-round limits, the skill merges and notifies the Master with a summary.

FAQ

What if Greptile doesn't include a score?

If no score is found but comments exist, treat the review as needing fixes; if no comments exist, consider the PR mergeable and proceed with merge.

When does the skill escalate to a human?

Escalation happens for architectural/design feedback, unclear requests, max rounds reached, or repeated identical scores that indicate stagnation.