Skip to content

Commit ca07626

Browse files
fix(skill): add retry guard to prevent intra-run duplicate reviews (#1322)
## Summary - Adds explicit guidance in the `review-pr` skill to verify whether a review was already posted before retrying a failed/stuck API call - Prevents intra-run duplicate reviews (distinct from cross-run dedup in #1139) Fixes #1321 ## Context Run 22784882686 posted the same review body twice on PR #1320 (4 minutes apart) because the bot thought the first API call was "stuck" and retried with `gh pr review --comment` without checking if the review had already been posted. ## Test plan - [ ] Next external PR review should not produce duplicate reviews even if the API call is slow 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 691060e commit ca07626

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

.claude/skills/review-pr/SKILL.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,16 @@ approach:
283283

284284
#### Posting
285285

286-
Submit **one formal review per run** via `gh pr review`. Note that `--comment`
287-
requires a non-empty body (`-b ""` fails) — if there's nothing to say, use the
288-
approve-with-empty-body pattern instead.
286+
Post exactly one review per run. API calls can succeed server-side while
287+
appearing to hang, so always verify before calling `gh pr review`:
288+
```bash
289+
gh api "repos/$REPO/pulls/<number>/reviews" \
290+
--jq "[.[] | select(.user.login == \"$BOT_LOGIN\" and .commit_id == \"$HEAD_SHA\")] | last | .submitted_at // empty"
291+
```
292+
If this returns a timestamp, the review is already posted — you're done.
293+
Otherwise, submit via `gh pr review`. Note that `--comment` requires a non-empty
294+
body (`-b ""` fails) — if there's nothing to say, use the approve-with-empty-body
295+
pattern instead.
289296

290297
- Always give a verdict: **approve** or **comment**. Don't use "request changes"
291298
(that implies authority to block).

0 commit comments

Comments
 (0)