Get the FREE Ultimate OpenClaw Setup Guide โ†’

github-pr-review

Scanned
npx machina-cli add skill fvadicamo/dev-agent-skills/github-pr-review --openclaw
Files (1)
SKILL.md
5.7 KB

GitHub PR review

Resolves Pull Request review comments with severity-based prioritization, fix application, and thread replies.

Current PR

!gh pr view --json number,title,state,milestone -q '"PR #\(.number): \(.title) (\(.state)) | Milestone: \(.milestone.title // "none")"' 2>/dev/null

Core workflow

1. Fetch and classify comments

Fetch both inline comments and PR-level reviews (needed for CodeRabbit "outside diff" comments):

REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
PR=$(gh pr view --json number -q '.number')

# Inline review comments - filter out replies (keep only originals)
gh api repos/$REPO/pulls/$PR/comments --jq '
  [.[] | select(.in_reply_to_id == null) |
   {id, path, user: .user.login, body: .body[0:200]}]
'

# PR-level reviews with non-empty body (CodeRabbit "outside diff" comments)
gh api repos/$REPO/pulls/$PR/reviews --jq '
  [.[] | select(.body | length > 0) |
   {id, user: .user.login, state, body: .body[0:200]}]
'

For PR-level reviews, parse the body for CodeRabbit <details> blocks containing "outside diff" comments - extract file path, line range, and comment text from each block.

Classify all originals by severity and process in order: CRITICAL > HIGH > MEDIUM > LOW.

SeverityIndicatorsAction
CRITICALcritical.svg, _๐Ÿ”’ Security_, _๐Ÿ”ด Critical_, "security", "vulnerability"Must fix
HIGHhigh-priority.svg, _โš ๏ธ Potential issue_, _๐Ÿ› Bug_, _๐ŸŸ  Major_, "High Severity"Should fix
MEDIUMmedium-priority.svg, _๐Ÿ’ก Suggestion_, "Medium Severity"Recommended
LOWlow-priority.svg, _๐Ÿงน Nitpick_, _๐Ÿ”ง Optional_, _๐ŸŸก Minor_, "style", "nit"Optional

See references/severity_guide.md for full detection patterns (Gemini badges, CodeRabbit emoji, Cursor comments, keyword fallback, related comments heuristics).

2. Process each comment

For each comment, in severity order:

  1. Show context: comment ID, severity, file:line, quote
  2. Read affected code and propose fix
  3. Confirm with user before applying
  4. Apply fix if approved
  5. Verify ALL issues in the comment are addressed (multi-issue comments are common)

3. Commit changes

Use git-commit skill format. Functional fixes get separate commits, cosmetic fixes are batched:

Change typeStrategy
Functional (CRITICAL/HIGH)Separate commit per fix
Cosmetic (MEDIUM/LOW)Single batch style: commit

Reference the comment ID in the commit body.

4. Reply to threads

Important: use --input - with JSON. The -f in_reply_to=... syntax does NOT work.

COMMIT=$(git rev-parse --short HEAD)
gh api repos/$REPO/pulls/$PR/comments \
  --input - <<< '{"body": "Fixed in '"$COMMIT"'. Brief explanation.", "in_reply_to": 123456789}'

Reply templates (no emojis, minimal and professional):

SituationTemplate
FixedFixed in [hash]. [brief description of fix]
Won't fixWon't fix: [reason]
By designBy design: [explanation]
DeferredDeferred to [issue/task]. Will address in future iteration.
AcknowledgedAcknowledged. [brief note]

5. Run tests and push

Run the project test suite. All tests must pass before pushing. Push all fixes together to minimize review loops.

6. Submit review (optional)

After addressing all comments, formally submit a review:

  • gh pr review $PR --approve --body "..." - all comments addressed, PR is ready
  • gh pr review $PR --request-changes --body "..." - critical issues remain
  • gh pr review $PR --comment --body "..." - progress update, no decision yet

7. Verify milestone

gh pr view $PR --json milestone -q '.milestone.title // "none"'

If the PR has no milestone, check for open milestones:

REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
gh api repos/$REPO/milestones --jq '[.[] | select(.state=="open")] | .[] | "\(.number): \(.title)"'

If open milestones exist, inform the user and suggest assigning:

gh pr edit $PR --milestone "[milestone-title]"

Do not assign automatically. This is a reminder only.

Avoiding review loops

When bots (Gemini, Codex, etc.) review every push:

  1. Batch fixes: accumulate all fixes, push once
  2. Draft PR: convert to draft during fixes
  3. Commit keywords: some bots respect [skip ci] or [skip review]

Important rules

  • ALWAYS confirm before modifying files
  • ALWAYS verify ALL issues in multi-issue comments are fixed
  • ALWAYS run tests before pushing
  • ALWAYS reply to resolved threads using standard templates
  • ALWAYS submit formal review (gh pr review) after addressing all comments
  • ALWAYS check milestone at the end and remind if missing
  • NEVER use emojis in commit messages or thread replies
  • NEVER skip HIGH/CRITICAL comments without explicit user approval
  • NEVER assign milestone automatically - suggest only
  • Functional fixes -> separate commits (one per fix)
  • Cosmetic fixes -> batch into single style: commit

References

  • references/severity_guide.md - Severity detection patterns (Gemini badges, Cursor comments, keyword fallback, related comments heuristics)

Source

git clone https://github.com/fvadicamo/dev-agent-skills/blob/main/skills/github-pr-review/SKILL.mdView on GitHub

Overview

This skill automates handling GitHub PR reviews. It fetches inline and PR-level comments via the GitHub CLI, classifies them by severity, guides fixes with user confirmation, commits changes in the proper format, and replies to threads to close feedback.

How This Skill Works

The skill uses gh to pull the current PRโ€™s comments, including inline and review threads. It classifies each original comment by severity (CRITICAL, HIGH, MEDIUM, LOW) and processes them in order, proposing code changes and awaiting user confirmation before applying. After applying fixes, it commits changes using the prescribed git-commit format (with separate commits for functional fixes and a batched style commit for cosmetics) and replies to the corresponding threads via the GitHub API.

When to Use It

  • When you need to resolve or triage PR review comments before merging.
  • When addressing reviewer feedback and applying fixes across the PR.
  • When verifying PR readiness and checking review status.
  • When replying to reviewer threads after making changes.
  • When prioritizing and organizing review feedback by severity for efficient fixes.

Quick Start

  1. Step 1: Fetch the PR comments and classify by severity using gh.
  2. Step 2: For each comment (CRITICAL/HIGH first), propose fixes, confirm, apply, and verify.
  3. Step 3: Commit fixes in the prescribed format and reply to threads with the appropriate templates.

Best Practices

  • Fetch both inline comments and PR-level reviews to get the full context of feedback.
  • Classify comments by severity (CRITICAL > HIGH > MEDIUM > LOW) before acting.
  • Ask for explicit user confirmation before applying any fix.
  • Commit functional fixes separately from cosmetic changes, and reference the comment IDs in commit messages.
  • Reply to threads using the prescribed templates and the gh api with --input - to ensure proper threading.

Example Use Cases

  • A critical security-related comment is found; the skill proposes a fix, applies it after confirmation, commits it, and replies in the thread with a summary.
  • Multiple HIGH severity issues are identified; separate commits are created for each fix, followed by thread replies explaining the changes.
  • A MEDIUM-level refactor suggestion is accepted and batched into a single cosmetic commit with a style-focused message.
  • CodeRabbit 'outside diff' comments are parsed and addressed with precise file/line updates and corresponding PR-level replies.
  • All comments are resolved, and the tool suggests submitting the final PR review with a concise summary.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers โ†—