Skip to content

Commit 5221e73

Browse files
authored
Add step to delete previous Claude review comments
Added a step to remove prior Claude review comments before running a new review.
1 parent a028536 commit 5221e73

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

.github/workflows/claude-code-review.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,25 @@ jobs:
2020
with:
2121
ref: ${{ github.event.pull_request.head.sha }}
2222
fetch-depth: 1
23-
23+
24+
- name: Remove prior Claude review comment (so review runs again)
25+
env:
26+
GH_TOKEN: ${{ github.token }}
27+
run: |
28+
pr=${{ github.event.pull_request.number }}
29+
repo=${{ github.repository }}
30+
31+
# Find first issue comment whose body starts with "## Claude Code Review"
32+
comment_id=$(gh api repos/$repo/issues/$pr/comments \
33+
--jq '.[] | select(.body | startswith("## Claude Code Review")) | .id' | head -n 1)
34+
35+
if [ -n "$comment_id" ]; then
36+
echo "Deleting prior Claude review comment id=$comment_id"
37+
gh api -X DELETE repos/$repo/issues/comments/$comment_id
38+
else
39+
echo "No prior Claude review comment found."
40+
fi
41+
2442
- name: Run Claude Code Review
2543
id: claude-review
2644
uses: anthropics/claude-code-action@v1
@@ -59,5 +77,14 @@ jobs:
5977
If you cannot access the diff/files, say exactly what is blocked.
6078
If posting a PR comment is blocked, write the full review to the GitHub Actions job summary instead.
6179
80+
IMPORTANT:
81+
- Do NOT stop just because a previous "Claude Code Review" comment exists.
82+
- If a prior Claude review exists, post a NEW comment titled "Claude Code Review (updated)" that includes:
83+
- current head SHA: ${{ github.event.pull_request.head.sha }}
84+
- files changed count + up to 15 file paths
85+
- 3–6 bullet summary of changes
86+
- findings or at least 3 improvement opportunities with file paths
87+
Post as ONE top-level PR comment.
88+
6289
additional_permissions: |
6390
actions: read

0 commit comments

Comments
 (0)