Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,25 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1


- 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)
Comment on lines +31 to +33
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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')

Copilot uses AI. Check for mistakes.

if [ -n "$comment_id" ]; then
echo "Deleting prior Claude review comment id=$comment_id"
gh api -X DELETE repos/$repo/issues/comments/$comment_id
Comment on lines +24 to +37
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
- 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

Copilot uses AI. Check for mistakes.
else
echo "No prior Claude review comment found."
fi

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
Expand Down Expand Up @@ -59,5 +77,14 @@ jobs:
If you cannot access the diff/files, say exactly what is blocked.
If posting a PR comment is blocked, write the full review to the GitHub Actions job summary instead.

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:
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'.

Copilot uses AI. Check for mistakes.
- current head SHA: ${{ github.event.pull_request.head.sha }}
- 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.
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'.

Copilot uses AI. Check for mistakes.

additional_permissions: |
actions: read