GitHub Pull Request Review Assistant
Review the Pull Request at the provided URL and analyze unresolved review comments to provide comprehensive code review feedback.
PR Information
PR URL: $1
Fetch the PR details using GitHub CLI:
- •PR metadata: !
gh pr view "$1" --json number,title,author,state,isDraft,files
Task Instructions
- •
Fetch PR Details
- •Use
gh pr viewto get basic PR information - •Use
gh api graphqlwith query to fetch review threads - •GraphQL query includes
isResolvedfield for each thread - •Only process threads where
isResolved: false - •Ignore all resolved threads (user intentionally closed them)
- •Use
- •
Analyze Code Changes
- •Parse GraphQL response to extract unresolved threads (
isResolved: false) - •For each unresolved thread, read the referenced file using Read tool
- •Verify if the issue mentioned in the comment still exists
- •Skip threads where issue was already fixed
- •Focus only on legitimate remaining issues
- •Parse GraphQL response to extract unresolved threads (
- •
Review Criteria
Apply appropriate coding guidelines based on the project's language and framework.
Focus on:
- •Coding Style: Consistency, readability, naming conventions
- •Architecture: Design patterns, separation of concerns, modularity
- •Side Effects: Unintended consequences, race conditions, state mutations
- •Potential Bugs: Edge cases, error handling, null/undefined checks
- •
Provide Review Feedback & Apply Fixes
For each comment that points to a real issue:
- •Comment Context: Quote the original review comment
- •File & Location:
filepath:line_number - •Code Analysis: Examine the relevant code section
- •Assessment:
- •Is the concern valid?
- •What are the implications?
- •What's the recommended solution?
- •Decision:
- •If the concern is valid and the fix is straightforward: IMMEDIATELY APPLY THE FIX using Edit/Write tools
- •If the concern requires discussion or design decisions: ASK USER for clarification before making changes
- •Alternative Approaches: If applicable, suggest better implementations
- •Guideline References: Cite relevant coding guidelines when explaining fixes
- •
Summary
Provide an overall assessment:
- •Total number of review threads
- •Number of resolved threads (skipped)
- •Number of unresolved threads processed
- •Number of issues automatically fixed
- •Issues requiring user discussion (if any)
- •Overall PR quality assessment
GraphQL Query for Review Threads
graphql
query ($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
reviewThreads(first: 100) {
nodes {
isResolved
isOutdated
comments(first: 10) {
nodes {
path
position
body
author {
login
}
id
databaseId
}
}
}
}
}
}
}
Output Format
markdown
# PR Review: [PR Title] **PR**: [PR URL] **Status**: [open/draft/closed] **Files Changed**: [count] ## Review Threads Analysis & Fixes ### 1. [File Path]:[Line] **Thread Status**: Unresolved **Comment by @[username]**: > [quoted comment] **Current Code Status**: - ✅ **Already fixed** - [explanation of how it was addressed] - OR - ⚠️ **Issue still present** - proceeding with fix **Analysis** (if issue still present): [Your detailed analysis based on review criteria] **Action Taken**: - ✅ **Fixed automatically**: [description of fix applied] - OR - ⏸️ **Requires discussion**: [reason why user input is needed] --- ## Overall Assessment - **Total Review Threads**: [count] - **Resolved Threads (Skipped)**: [count] - **Unresolved Threads Processed**: [count] - **Issues Fixed Automatically**: [count] - **Issues Requiring Discussion**: [count] - **Overall Status**: [All issues resolved / Partial / Awaiting user input]
Important Notes
- •Private Repositories: Works with
ghCLI authentication - •Resolution Filtering: Uses GraphQL
isResolvedfield to skip resolved threads - •Smart Filtering: Also verifies if issues still exist in current code
- •Focus: Only review and fix unresolved threads with real, existing issues
- •Auto-Fix: Automatically apply fixes for straightforward issues without asking
- •User Consultation: Only ask user when the fix involves:
- •Architectural or design decisions
- •Multiple valid approaches
- •Potential breaking changes
- •Ambiguous requirements
Example Usage
bash
/review-pr https://github.com/owner/repo/pull/123