Add step to delete previous Claude review comments#1253
Add step to delete previous Claude review comments#1253sbryngelson merged 1 commit intoMFlowCode:masterfrom
Conversation
Added a step to remove prior Claude review comments before running a new review.
|
CodeAnt AI is reviewing your PR. Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis PR modifies the Claude code review GitHub Actions workflow to automatically remove prior review comments before initiating new reviews, and updates the review prompt to generate an "updated" comment containing current metadata, file counts, change summaries, and improvement opportunities. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
CodeAnt AI finished reviewing your PR. |
There was a problem hiding this comment.
Pull request overview
Adds workflow logic to remove a prior “Claude Code Review” PR comment before re-running the Claude review action, and updates the Claude prompt to guide posting an updated review.
Changes:
- Added a GitHub CLI step to find/delete an existing “Claude Code Review” issue comment on the PR.
- Expanded the Claude instruction prompt to prefer posting a new “updated” review comment with additional metadata.
| - name: Remove prior Claude review comment (so review runs again) | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| pr=${{ github.event.pull_request.number }} | ||
| repo=${{ github.repository }} | ||
|
|
||
| # Find first issue comment whose body starts with "## Claude Code Review" | ||
| comment_id=$(gh api repos/$repo/issues/$pr/comments \ | ||
| --jq '.[] | select(.body | startswith("## Claude Code Review")) | .id' | head -n 1) | ||
|
|
||
| if [ -n "$comment_id" ]; then | ||
| echo "Deleting prior Claude review comment id=$comment_id" | ||
| gh api -X DELETE repos/$repo/issues/comments/$comment_id |
There was a problem hiding this comment.
This deletes only a single matching comment (the first one returned), but the PR title implies removing previous Claude review comments (potentially multiple). Consider deleting all matching comment IDs (iterate over the jq output) or explicitly deleting only the most recent one and updating the step/title to match that behavior.
| - name: Remove prior Claude review comment (so review runs again) | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| pr=${{ github.event.pull_request.number }} | |
| repo=${{ github.repository }} | |
| # Find first issue comment whose body starts with "## Claude Code Review" | |
| comment_id=$(gh api repos/$repo/issues/$pr/comments \ | |
| --jq '.[] | select(.body | startswith("## Claude Code Review")) | .id' | head -n 1) | |
| if [ -n "$comment_id" ]; then | |
| echo "Deleting prior Claude review comment id=$comment_id" | |
| gh api -X DELETE repos/$repo/issues/comments/$comment_id | |
| - name: Remove prior Claude review comments (so review runs again) | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| pr=${{ github.event.pull_request.number }} | |
| repo=${{ github.repository }} | |
| # Find all issue comments whose body starts with "## Claude Code Review" | |
| comment_ids=$(gh api repos/$repo/issues/$pr/comments \ | |
| --jq '.[] | select(.body | startswith("## Claude Code Review")) | .id') | |
| if [ -n "$comment_ids" ]; then | |
| echo "Deleting prior Claude review comments:" | |
| echo "$comment_ids" | while read -r comment_id; do | |
| if [ -n "$comment_id" ]; then | |
| echo " - Deleting comment id=$comment_id" | |
| gh api -X DELETE repos/$repo/issues/comments/$comment_id | |
| fi | |
| done |
| # Find first issue comment whose body starts with "## Claude Code Review" | ||
| comment_id=$(gh api repos/$repo/issues/$pr/comments \ | ||
| --jq '.[] | select(.body | startswith("## Claude Code Review")) | .id' | head -n 1) |
There was a problem hiding this comment.
The GitHub API response order for issue comments isn’t guaranteed to be the one you intend, so head -n 1 can delete an arbitrary matching comment. If the goal is to delete the latest/previous Claude comment, filter + sort by .created_at (or .updated_at) and then select the newest ID deterministically.
| # Find first issue comment whose body starts with "## Claude Code Review" | |
| comment_id=$(gh api repos/$repo/issues/$pr/comments \ | |
| --jq '.[] | select(.body | startswith("## Claude Code Review")) | .id' | head -n 1) | |
| # Find most recent issue comment whose body starts with "## Claude Code Review" | |
| comment_id=$(gh api repos/$repo/issues/$pr/comments \ | |
| --jq 'map(select(.body | startswith("## Claude Code Review"))) | sort_by(.created_at) | last? | .id // empty') |
|
|
||
| IMPORTANT: | ||
| - Do NOT stop just because a previous "Claude Code Review" comment exists. | ||
| - If a prior Claude review exists, post a NEW comment titled "Claude Code Review (updated)" that includes: |
There was a problem hiding this comment.
GitHub PR issue comments don’t support a separate 'title' field—only the body text. If you need a 'title', instruct Claude to include a first-line markdown heading (e.g., ## Claude Code Review (updated)) or a consistent prefix in the comment body, rather than referring to the comment as being 'titled'.
| - files changed count + up to 15 file paths | ||
| - 3–6 bullet summary of changes | ||
| - findings or at least 3 improvement opportunities with file paths | ||
| Post as ONE top-level PR comment. |
There was a problem hiding this comment.
GitHub PR issue comments don’t support a separate 'title' field—only the body text. If you need a 'title', instruct Claude to include a first-line markdown heading (e.g., ## Claude Code Review (updated)) or a consistent prefix in the comment body, rather than referring to the comment as being 'titled'.
CodeAnt-AI Description
Remove prior Claude review comment before running review and ensure updated review posted
What Changed
Impact
✅ Clearer updated review comments✅ Fewer duplicate review comments✅ Always-posted fresh review output💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit