Skip to content

Commit b7d5a96

Browse files
authored
fix: enhance PR reviewer mode to prevent duplicate comments (#5382)
- Reorganized workflow to fetch existing comments BEFORE code review (Step 4) - Added dedicated Step 6 to verify existing comments against current code - Updated best practices to emphasize checking resolved comments first - Enhanced common mistakes to highlight duplicate comment prevention - Added tracking of resolved vs pending comments in the review process
1 parent 2ecf2ce commit b7d5a96

File tree

3 files changed

+86
-25
lines changed

3 files changed

+86
-25
lines changed

.roo/rules-pr-reviewer/1_workflow.xml

Lines changed: 74 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,48 @@
6767
</step>
6868

6969
<step number="4">
70+
<name>Fetch Existing PR Comments and Reviews</name>
71+
<instructions>
72+
IMPORTANT: Before reviewing any code, first get all existing comments and reviews to understand what feedback has already been provided:
73+
74+
<use_mcp_tool>
75+
<server_name>github</server_name>
76+
<tool_name>get_pull_request_comments</tool_name>
77+
<arguments>
78+
{
79+
"owner": "[owner]",
80+
"repo": "[repo]",
81+
"pullNumber": [number]
82+
}
83+
</arguments>
84+
</use_mcp_tool>
85+
86+
Also fetch existing reviews:
87+
<use_mcp_tool>
88+
<server_name>github</server_name>
89+
<tool_name>get_pull_request_reviews</tool_name>
90+
<arguments>
91+
{
92+
"owner": "[owner]",
93+
"repo": "[repo]",
94+
"pullNumber": [number]
95+
}
96+
</arguments>
97+
</use_mcp_tool>
98+
99+
Create a mental or written list of:
100+
- All issues/suggestions that have been raised
101+
- The specific files and line numbers mentioned
102+
- Whether comments appear to be resolved or still pending
103+
104+
This information will guide your review to avoid duplicate feedback.
105+
</instructions>
106+
</step>
107+
108+
<step number="5">
70109
<name>Check Out Pull Request Locally</name>
71110
<instructions>
72-
Use the GitHub CLI (e.g. `gh pr checkout <PR_NUMBER>`) to check out the pull request locally after fetching
73-
the diff. This provides a better understanding of code context and interactions than relying solely on the diff.
111+
Use the GitHub CLI to check out the pull request locally:
74112

75113
<execute_command>
76114
<command>gh pr checkout [PR_NUMBER]</command>
@@ -83,28 +121,31 @@
83121
</instructions>
84122
</step>
85123

86-
<step number="5">
87-
<name>Fetch Existing PR Comments</name>
124+
<step number="6">
125+
<name>Verify Existing Comments Against Current Code</name>
88126
<instructions>
89-
Get existing comments to understand the current discussion state:
127+
Now that you have the code checked out locally and know what comments exist:
90128

91-
<use_mcp_tool>
92-
<server_name>github</server_name>
93-
<tool_name>get_pull_request_comments</tool_name>
94-
<arguments>
95-
{
96-
"owner": "[owner]",
97-
"repo": "[repo]",
98-
"pullNumber": [number]
99-
}
100-
</arguments>
101-
</use_mcp_tool>
129+
1. For each existing comment/review point:
130+
- Navigate to the specific file and line mentioned
131+
- Check if the issue has been addressed in the current code
132+
- Mark it as "resolved" or "still pending" in your notes
133+
134+
2. Use read_file or codebase_search to examine the specific areas mentioned in comments:
135+
- If a comment says "missing error handling on line 45", check if error handling now exists
136+
- If a review mentioned "this function needs tests", check if tests have been added
137+
- If feedback was about code structure, verify if refactoring has occurred
102138

103-
Examine existing PR comments to understand the current state of discussion. When reading the comments and reviews, you must verify which are resolved by reading the files they refer to, since they might already be resolved. This prevents you from making redundant suggestions.
139+
3. Keep track of:
140+
- Comments that have been addressed (DO NOT repeat these)
141+
- Comments that are still valid (you may reinforce these if critical)
142+
- New issues not previously mentioned (these are your main focus)
143+
144+
This verification step is CRITICAL to avoid redundant feedback and ensures your review adds value.
104145
</instructions>
105146
</step>
106147

107-
<step number="6">
148+
<step number="7">
108149
<name>Perform Comprehensive Review</name>
109150
<instructions>
110151
Review the pull request thoroughly:
@@ -129,11 +170,16 @@
129170
</instructions>
130171
</step>
131172

132-
<step number="7">
173+
<step number="8">
133174
<name>Prepare Review Comments</name>
134175
<instructions>
135176
Format your review comments following these guidelines:
136177

178+
CRITICAL: Before adding any comment, verify it's not already addressed:
179+
- Cross-reference with your notes from Step 6
180+
- Only comment on NEW issues or UNRESOLVED existing issues
181+
- Never repeat feedback that has been addressed in the current code
182+
137183
Your suggestions should:
138184
- Use a **friendly, curious tone** — prefer asking: "Is this intentional?" or "Could we approach this differently to improve X?"
139185
- Avoid assumptions or judgments; ask questions instead of declaring problems.
@@ -148,10 +194,12 @@
148194
- Critical issues (must fix)
149195
- Important suggestions (should consider)
150196
- Minor improvements (nice to have)
197+
198+
Include a note about which existing comments you verified as resolved (for user awareness).
151199
</instructions>
152200
</step>
153201

154-
<step number="8">
202+
<step number="9">
155203
<name>Preview Review with User</name>
156204
<instructions>
157205
Always show the user a preview of your review suggestions and comments before taking any action.
@@ -160,7 +208,11 @@
160208
<ask_followup_question>
161209
<question>I've completed my review of PR #[number]. Here's what I found:
162210

163-
[Summary of findings organized by priority]
211+
[If applicable: Existing comments that have been resolved:
212+
- Comment about X on file Y - now addressed
213+
- Suggestion about Z - implemented]
214+
215+
[Summary of NEW findings organized by priority]
164216

165217
Would you like me to:
166218
1. Create a comprehensive review with all comments
@@ -175,7 +227,7 @@
175227
</instructions>
176228
</step>
177229

178-
<step number="9">
230+
<step number="10">
179231
<name>Submit Review</name>
180232
<instructions>
181233
Based on user preference, submit the review as a comprehensive review:

.roo/rules-pr-reviewer/2_best_practices.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<best_practices>
2+
- ALWAYS fetch existing comments and reviews BEFORE reviewing any code (Step 4)
3+
- Create a list of all existing feedback before starting your review
4+
- Check out the PR locally for better context understanding
5+
- Systematically verify each existing comment against the current code (Step 6)
6+
- Track which comments are resolved vs still pending
7+
- Only provide feedback on NEW issues or UNRESOLVED existing issues
8+
- Never duplicate feedback that has already been addressed
29
- Always fetch and review the entire PR diff before commenting
310
- Check for and review any associated issue for context
4-
- Check out the PR locally for better context understanding
5-
- Review existing comments and verify against the current code to avoid redundant feedback on already resolved issues
611
- Focus on the changes made, not unrelated code
712
- Ensure all changes are directly related to the linked issue
813
- Use a friendly, curious tone in all comments

.roo/rules-pr-reviewer/3_common_mistakes_to_avoid.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<common_mistakes_to_avoid>
2+
- Starting to review code WITHOUT first fetching existing comments and reviews
3+
- Failing to create a list of existing feedback before reviewing
4+
- Not systematically checking each existing comment against the current code
5+
- Repeating feedback that has already been addressed in the current code
6+
- Ignoring existing PR comments or failing to verify if they have already been resolved
27
- Running tests or executing code during review
38
- Making judgmental or harsh comments
49
- Providing feedback on code outside the PR's scope
@@ -7,7 +12,6 @@
712
- Using markdown headings (###, ##, #) in review comments
813
- Using excessive markdown formatting when plain text would suffice
914
- Submitting comments without user preview/approval
10-
- Ignoring existing PR comments or failing to verify if they have already been resolved by checking the code
1115
- Forgetting to check for an associated issue for additional context
1216
- Missing critical security or performance issues
1317
- Not checking for proper i18n in UI changes

0 commit comments

Comments
 (0)