feat: Update PR reviewer mode to use todo lists and GitHub CLI (#6328)

- Add todo list initialization and tracking throughout the review workflow
- Replace all MCP GitHub server calls with gh CLI commands
- Fix duplicate step numbering issue
- Update best practices and common mistakes documentation
- Add notes about GitHub CLI limitations for inline comments
This commit is contained in:
Daniel 2025-07-28 19:56:57 -05:00 committed by GitHub
parent f90fc2fd5f
commit cd26fc493f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 251 additions and 133 deletions

View file

@ -1,100 +1,133 @@
<workflow>
<step number="1">
<name>Initialize Review Process</name>
<instructions>
Create a todo list to track the PR review workflow:
<update_todo_list>
<todos>
[ ] Fetch pull request information
[ ] Fetch associated issue (if any)
[ ] Fetch pull request diff
[ ] Fetch existing PR comments and reviews
[ ] Check out pull request locally
[ ] Verify existing comments against current code
[ ] Perform comprehensive review
[ ] Prepare review comments
[ ] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
This helps track progress through the review process and ensures all steps are completed.
</instructions>
</step>
<step number="2">
<name>Fetch Pull Request Information</name>
<instructions>
By default, use the GitHub MCP server to fetch and review pull requests from the
https://github.com/RooCodeInc/Roo-Code repository.
By default, review pull requests from the https://github.com/RooCodeInc/Roo-Code repository.
If the user provides a PR number or URL, extract the necessary information:
- Repository owner and name
- Pull request number
Use the GitHub MCP tool to fetch the PR details:
Use the GitHub CLI to fetch the PR details:
<use_mcp_tool>
<server_name>github</server_name>
<tool_name>get_pull_request</tool_name>
<arguments>
{
"owner": "[owner]",
"repo": "[repo]",
"pullNumber": [number]
}
</arguments>
</use_mcp_tool>
</instructions>
</step>
<step number="2">
<name>Fetch Associated Issue (If Any)</name>
<instructions>
Check the pull request body for a reference to a GitHub issue (e.g., "Fixes #123", "Closes #456").
If an issue is referenced, use the GitHub MCP tool to fetch its details:
<use_mcp_tool>
<server_name>github</server_name>
<tool_name>get_issue</tool_name>
<arguments>
{
"owner": "[owner]",
"repo": "[repo]",
"issue_number": [issue_number]
}
</arguments>
</use_mcp_tool>
The issue description and comments can provide valuable context for the review.
<execute_command>
<command>gh pr view [PR_NUMBER] --repo [owner]/[repo] --json number,title,body,author,state,url,headRefName,baseRefName,mergeable,isDraft,createdAt,updatedAt</command>
</execute_command>
Parse the JSON output to understand the PR's current state and metadata.
<update_todo_list>
<todos>
[x] Fetch pull request information
[ ] Fetch associated issue (if any)
[ ] Fetch pull request diff
[ ] Fetch existing PR comments and reviews
[ ] Check out pull request locally
[ ] Verify existing comments against current code
[ ] Perform comprehensive review
[ ] Prepare review comments
[ ] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="3">
<name>Fetch Pull Request Diff</name>
<name>Fetch Associated Issue (If Any)</name>
<instructions>
Get the pull request diff to understand the changes:
Check the pull request body for a reference to a GitHub issue (e.g., "Fixes #123", "Closes #456").
If an issue is referenced, use the GitHub CLI to fetch its details:
<execute_command>
<command>gh issue view [issue_number] --repo [owner]/[repo] --json number,title,body,author,state,url,createdAt,updatedAt,comments</command>
</execute_command>
The issue description and comments can provide valuable context for the review.
<use_mcp_tool>
<server_name>github</server_name>
<tool_name>get_pull_request_diff</tool_name>
<arguments>
{
"owner": "[owner]",
"repo": "[repo]",
"pullNumber": [number]
}
</arguments>
</use_mcp_tool>
<update_todo_list>
<todos>
[x] Fetch pull request information
[x] Fetch associated issue (if any)
[ ] Fetch pull request diff
[ ] Fetch existing PR comments and reviews
[ ] Check out pull request locally
[ ] Verify existing comments against current code
[ ] Perform comprehensive review
[ ] Prepare review comments
[ ] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="4">
<name>Fetch Pull Request Diff</name>
<instructions>
Get the pull request diff to understand the changes:
<execute_command>
<command>gh pr diff [PR_NUMBER] --repo [owner]/[repo]</command>
</execute_command>
This will show the complete diff of all changes in the PR.
<update_todo_list>
<todos>
[x] Fetch pull request information
[x] Fetch associated issue (if any)
[x] Fetch pull request diff
[ ] Fetch existing PR comments and reviews
[ ] Check out pull request locally
[ ] Verify existing comments against current code
[ ] Perform comprehensive review
[ ] Prepare review comments
[ ] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="5">
<name>Fetch Existing PR Comments and Reviews</name>
<instructions>
IMPORTANT: Before reviewing any code, first get all existing comments and reviews to understand what feedback has already been provided:
<use_mcp_tool>
<server_name>github</server_name>
<tool_name>get_pull_request_comments</tool_name>
<arguments>
{
"owner": "[owner]",
"repo": "[repo]",
"pullNumber": [number]
}
</arguments>
</use_mcp_tool>
Fetch all review comments:
<execute_command>
<command>gh pr view [PR_NUMBER] --repo [owner]/[repo] --comments</command>
</execute_command>
Also fetch existing reviews:
<use_mcp_tool>
<server_name>github</server_name>
<tool_name>get_pull_request_reviews</tool_name>
<arguments>
{
"owner": "[owner]",
"repo": "[repo]",
"pullNumber": [number]
}
</arguments>
</use_mcp_tool>
Also fetch review details:
<execute_command>
<command>gh pr reviews [PR_NUMBER] --repo [owner]/[repo]</command>
</execute_command>
Create a mental or written list of:
- All issues/suggestions that have been raised
@ -102,26 +135,56 @@
- Whether comments appear to be resolved or still pending
This information will guide your review to avoid duplicate feedback.
<update_todo_list>
<todos>
[x] Fetch pull request information
[x] Fetch associated issue (if any)
[x] Fetch pull request diff
[x] Fetch existing PR comments and reviews
[ ] Check out pull request locally
[ ] Verify existing comments against current code
[ ] Perform comprehensive review
[ ] Prepare review comments
[ ] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="5">
<step number="6">
<name>Check Out Pull Request Locally</name>
<instructions>
Use the GitHub CLI to check out the pull request locally:
<execute_command>
<command>gh pr checkout [PR_NUMBER]</command>
<command>gh pr checkout [PR_NUMBER] --repo [owner]/[repo]</command>
</execute_command>
This allows you to:
- Navigate the actual code structure
- Understand how changes interact with existing code
- Get better context for your review
<update_todo_list>
<todos>
[x] Fetch pull request information
[x] Fetch associated issue (if any)
[x] Fetch pull request diff
[x] Fetch existing PR comments and reviews
[x] Check out pull request locally
[ ] Verify existing comments against current code
[ ] Perform comprehensive review
[ ] Prepare review comments
[ ] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="6">
<step number="7">
<name>Verify Existing Comments Against Current Code</name>
<instructions>
Now that you have the code checked out locally and know what comments exist:
@ -142,10 +205,25 @@
- New issues not previously mentioned (these are your main focus)
This verification step is CRITICAL to avoid redundant feedback and ensures your review adds value.
<update_todo_list>
<todos>
[x] Fetch pull request information
[x] Fetch associated issue (if any)
[x] Fetch pull request diff
[x] Fetch existing PR comments and reviews
[x] Check out pull request locally
[x] Verify existing comments against current code
[ ] Perform comprehensive review
[ ] Prepare review comments
[ ] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="7">
<step number="8">
<name>Perform Comprehensive Review</name>
<instructions>
Review the pull request thoroughly:
@ -169,16 +247,31 @@
6. Security considerations
7. Internationalization (i18n) issues
8. Technical debt indicators
<update_todo_list>
<todos>
[x] Fetch pull request information
[x] Fetch associated issue (if any)
[x] Fetch pull request diff
[x] Fetch existing PR comments and reviews
[x] Check out pull request locally
[x] Verify existing comments against current code
[x] Perform comprehensive review
[ ] Prepare review comments
[ ] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="8">
<step number="9">
<name>Prepare Review Comments</name>
<instructions>
Format your review comments following these guidelines:
CRITICAL: Before adding any comment, verify it's not already addressed:
- Cross-reference with your notes from Step 6
- Cross-reference with your notes from Step 7
- Only comment on NEW issues or UNRESOLVED existing issues
- Never repeat feedback that has been addressed in the current code
@ -207,10 +300,25 @@
6. [Improvement suggestion]
Include a note about which existing comments you verified as resolved (for user awareness).
<update_todo_list>
<todos>
[x] Fetch pull request information
[x] Fetch associated issue (if any)
[x] Fetch pull request diff
[x] Fetch existing PR comments and reviews
[x] Check out pull request locally
[x] Verify existing comments against current code
[x] Perform comprehensive review
[x] Prepare review comments
[ ] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="9">
<step number="10">
<name>Preview Review with User</name>
<instructions>
Always show the user a preview of your review suggestions and comments before taking any action.
@ -245,62 +353,63 @@
<suggest>Skip submission - just wanted the analysis</suggest>
</follow_up>
</ask_followup_question>
</instructions>
</step>
<step number="10">
<name>Submit Review</name>
<instructions>
Based on user preference, submit the review as a comprehensive review:
1. First create a pending review:
<use_mcp_tool>
<server_name>github</server_name>
<tool_name>create_pending_pull_request_review</tool_name>
<arguments>
{
"owner": "[owner]",
"repo": "[repo]",
"pullNumber": [number]
}
</arguments>
</use_mcp_tool>
2. Add comments to the pending review using:
<use_mcp_tool>
<server_name>github</server_name>
<tool_name>add_pull_request_review_comment_to_pending_review</tool_name>
<arguments>
{
"owner": "[owner]",
"repo": "[repo]",
"pullNumber": [number],
"path": "[file path]",
"line": [line number],
"body": "[comment text]",
"subjectType": "LINE"
}
</arguments>
</use_mcp_tool>
3. Submit the review:
<use_mcp_tool>
<server_name>github</server_name>
<tool_name>submit_pending_pull_request_review</tool_name>
<arguments>
{
"owner": "[owner]",
"repo": "[repo]",
"pullNumber": [number],
"event": "COMMENT",
"body": "[overall review summary]"
}
</arguments>
</use_mcp_tool>
<update_todo_list>
<todos>
[x] Fetch pull request information
[x] Fetch associated issue (if any)
[x] Fetch pull request diff
[x] Fetch existing PR comments and reviews
[x] Check out pull request locally
[x] Verify existing comments against current code
[x] Perform comprehensive review
[x] Prepare review comments
[x] Preview review with user
[ ] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="11">
<name>Submit Review</name>
<instructions>
Based on user preference, submit the review using GitHub CLI:
Note: The GitHub CLI has limited support for creating reviews with inline comments.
For comprehensive reviews with line-specific comments, we'll need to:
1. Create individual comments on specific lines (if needed):
<execute_command>
<command>gh pr comment [PR_NUMBER] --repo [owner]/[repo] --body "[comment text]"</command>
</execute_command>
2. Or create a general review comment summarizing all findings:
<execute_command>
<command>gh pr review [PR_NUMBER] --repo [owner]/[repo] --comment --body "[review summary with all findings]"</command>
</execute_command>
Note: For line-specific comments, you may need to use the GitHub web interface or API directly,
as the gh CLI has limited support for inline review comments.
<update_todo_list>
<todos>
[x] Fetch pull request information
[x] Fetch associated issue (if any)
[x] Fetch pull request diff
[x] Fetch existing PR comments and reviews
[x] Check out pull request locally
[x] Verify existing comments against current code
[x] Perform comprehensive review
[x] Prepare review comments
[x] Preview review with user
[x] Submit review or create tasks
</todos>
</update_todo_list>
</instructions>
</step>
<step number="12">
<name>Create Tasks for Suggestions (Optional)</name>
<instructions>
If the user chooses to create individual tasks for each suggestion, use the new_task tool to create separate tasks:

View file

@ -1,8 +1,10 @@
<best_practices>
- ALWAYS fetch existing comments and reviews BEFORE reviewing any code (Step 4)
- ALWAYS create a todo list at the start to track the review workflow (Step 1)
- Use GitHub CLI (`gh`) commands instead of MCP tools for all GitHub operations
- ALWAYS fetch existing comments and reviews BEFORE reviewing any code (Step 5)
- Create a list of all existing feedback before starting your review
- Check out the PR locally for better context understanding
- Systematically verify each existing comment against the current code (Step 6)
- Check out the PR locally using `gh pr checkout` for better context understanding
- Systematically verify each existing comment against the current code (Step 7)
- Track which comments are resolved vs still pending
- Only provide feedback on NEW issues or UNRESOLVED existing issues
- Never duplicate feedback that has already been addressed
@ -28,4 +30,6 @@
- Offer the option to create individual tasks for each suggestion
- When creating tasks, choose the appropriate mode for each type of work
- Include specific context and file references in each task
- Update the todo list after each major step to track progress
- Note: GitHub CLI has limited support for inline review comments
</best_practices>

View file

@ -1,4 +1,6 @@
<common_mistakes_to_avoid>
- Not creating a todo list at the start to track the review workflow
- Using MCP tools instead of GitHub CLI commands for GitHub operations
- Starting to review code WITHOUT first fetching existing comments and reviews
- Failing to create a list of existing feedback before reviewing
- Not systematically checking each existing comment against the current code
@ -25,4 +27,7 @@
- Failing to offer the task creation option for addressing suggestions
- Creating tasks without specific context or file references
- Choosing inappropriate modes when creating tasks for suggestions
- Not updating the todo list after completing each step
- Forgetting that GitHub CLI has limited support for inline review comments
- Not including --repo flag when using gh commands for non-default repositories
</common_mistakes_to_avoid>