Skip to content

Commit 1fccdc3

Browse files
authored
Merge pull request #663 from apollographql/update-ai-review-comment-in-place
ci: update AI review summary comment in place
2 parents c530f41 + 3584215 commit 1fccdc3

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

.claude/skills/review/SKILL.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,14 @@ gh api repos/{owner}/{repo}/pulls/{pr_number}/comments \
171171
-f subject_type="line" \
172172
-F line=42
173173

174-
# For general PR comments (summary, test coverage assessment):
175-
gh pr comment {pr_number} --body "## Review Summary\n\n...\n\n---\n_Reviewed by Claude Code {model}_"
174+
# For the summary comment, always update an existing one if present (instead of creating a new one):
175+
COMMENT_ID=$(gh api repos/{owner}/{repo}/issues/{pr_number}/comments --jq '.[] | select(.body | contains("Reviewed by Claude Code")) | .id' | tail -1)
176+
BODY="## Review Summary\n\n...\n\n---\n_Reviewed by Claude Code {model}_"
177+
if [ -n "$COMMENT_ID" ]; then
178+
gh api repos/{owner}/{repo}/issues/comments/$COMMENT_ID -X PATCH -f body="$BODY"
179+
else
180+
gh pr comment {pr_number} --body "$BODY"
181+
fi
176182
```
177183

178184
Each inline comment should:
@@ -191,13 +197,7 @@ After posting inline comments, add a summary comment with:
191197
- Final recommendation (Approve / Approve with suggestions / Request changes)
192198
- Sign-off line at the end: `_Reviewed by Claude Code {model}_` where `{model}` is the current model name (e.g., "Opus 4.5")
193199

194-
If you have already posted a summary comment on this PR previously, any follow up summary comments should be concise and focused on what changed:
195-
196-
- Overall assessment (summary of the changes, keep this to a couple of sentences maximum)
197-
- Any new findings (if any, if none do not include this section)
198-
- Changes to test coverage assessment (if any, if none do not include this section)
199-
- Final recommendation
200-
- Sign-off line at the end: `_Reviewed by Claude Code {model}_` where `{model}` is the current model name (e.g., "Opus 4.5")
200+
**Important:** Always update the existing summary comment rather than creating a new one. Use the find-and-update pattern shown above.
201201

202202
## Guidelines for High-Signal Reviews
203203

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,26 @@ jobs:
9292
uses: actions/github-script@v7
9393
with:
9494
script: |
95-
github.rest.issues.createComment({
95+
const body = '⚠️ Claude Code Review failed to complete. This could be due to API issues, rate limits, or insufficient credits. The PR can still be merged - manual review recommended.';
96+
const marker = 'Claude Code Review';
97+
const { data: comments } = await github.rest.issues.listComments({
9698
issue_number: context.issue.number,
9799
owner: context.repo.owner,
98100
repo: context.repo.repo,
99-
body: '⚠️ Claude Code Review failed to complete. This could be due to API issues, rate limits, or insufficient credits. The PR can still be merged - manual review recommended.'
100-
})
101+
});
102+
const existing = comments.reverse().find(c => c.body?.includes(marker) && c.user?.login === 'github-actions[bot]');
103+
if (existing) {
104+
await github.rest.issues.updateComment({
105+
owner: context.repo.owner,
106+
repo: context.repo.repo,
107+
comment_id: existing.id,
108+
body,
109+
});
110+
} else {
111+
await github.rest.issues.createComment({
112+
issue_number: context.issue.number,
113+
owner: context.repo.owner,
114+
repo: context.repo.repo,
115+
body,
116+
});
117+
}

0 commit comments

Comments
 (0)