Skip to content

Commit d49a574

Browse files
fix(skills): flip PR to ready before waiting on CodeRabbit to avoid a draft deadlock
CodeRabbit never reviews a draft PR. The pull-request skill's monitor loop could enter (or continue) the CodeRabbit/threads wait while the PR was still draft, deadlocking silently — observed 2026-07-16: a converging PR sat in draft with CI green and the CodeRabbit check pending indefinitely, until manually un-drafted. - SKILL.md §5: emphasize the ordering invariant — `gh pr ready` MUST run as soon as draft CI is green, before section 6 starts waiting on any review signal. - SKILL.md §6 / monitor-loop.md: add a belt-and-braces draft guard at the top of every poll pass — if `isDraft: true` and CI is green, flip to ready immediately. Covers a loop started before the flip, or a rebase/force-push that reverted the PR back to draft. Closes #3956 Claude-Session: https://claude.ai/code/session_01WfNC8bt1TgL4AsiYgCEGup
1 parent 319a675 commit d49a574

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

.claude/skills/pull-request/SKILL.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ PR title must follow `type(scope): description` (conventional commits). Link the
9797
- Checkbox sections (Validation, Guardrails): check each box that applies (`- [x]`), leave unchecked only what genuinely does not apply
9898
- Follow any instructions in the template (e.g. "Delete this section if not applicable")
9999

100-
Once **draft CI passes** and the PR is ready for human review, convert to ready:
100+
**Ordering invariant — as soon as draft CI is green, flip to ready before doing anything else:**
101101

102102
```bash
103103
gh pr ready <number>
104104
```
105105

106-
> Some bots (e.g. CodeRabbit) trigger on ready, not on CI completion. After converting, do a **preliminary review pass** before entering the main loop:
106+
CodeRabbit (and some other review bots) never review a draft PR — they trigger on ready, not on CI completion. Entering or continuing the CodeRabbit/threads wait while the PR is still draft is a guaranteed silent deadlock (observed 2026-07-16: a converging PR sat in draft, CI green, CodeRabbit check pending indefinitely, until manually un-drafted). `gh pr ready` MUST run before section 6 starts waiting on any review signal — never after.
107+
108+
> After converting, do a **preliminary review pass** before entering the main loop:
107109
>
108110
> ```bash
109111
> sleep 180
@@ -126,6 +128,10 @@ PR=<number>
126128
```
127129
128130
Per pass:
131+
0. Draft guard — if `isDraft: true` AND CI green, `gh pr ready` immediately,
132+
then continue the pass. CodeRabbit never reviews a draft; this catches a
133+
loop that started before the flip, or a rebase/force-push that reverted
134+
the PR to draft.
129135
1. Wait CI → fix + /verify + commit + push if red, else continue
130136
2. Check mergeable — `CONFLICTING` stops, `UNKNOWN` retries
131137
3. Grace `sleep 180` + adaptive recheck of pending review checks

.claude/skills/pull-request/references/monitor-loop.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ After `gh pr ready`, run this loop yourself — do not wait for the user.
1919
consecutive_zero = 0
2020
2121
REPEAT:
22+
0. Draft guard → if PR is still draft AND CI is green, flip to ready now (see 6-guard)
2223
1. Wait for CI → sleep 30 then gh pr checks $PR --watch
2324
2. If CI fails → fix, /verify, commit, push, consecutive_zero=0, GOTO 1
2425
2b. Check mergeable status → STATUS=$(gh pr view $PR --json mergeable --jq .mergeable)
@@ -34,6 +35,25 @@ REPEAT:
3435
else GOTO 3
3536
```
3637

38+
## 6-guard. Draft ordering guard (belt-and-braces)
39+
40+
CodeRabbit never reviews a draft PR. Section 5 already flips the PR to ready
41+
before this loop starts, but run this check at the top of **every** pass
42+
anyway — it covers a loop entered before that flip, or a rebase/force-push
43+
that reverted the PR back to draft:
44+
45+
```bash
46+
STATUS=$(gh pr view "$PR" --json isDraft,statusCheckRollup)
47+
IS_DRAFT=$(echo "$STATUS" | jq -r '.isDraft')
48+
CI_GREEN=$(echo "$STATUS" | jq -r '[.statusCheckRollup[] | (.conclusion // .state)] | all(. == "SUCCESS")')
49+
50+
if [ "$IS_DRAFT" = "true" ] && [ "$CI_GREEN" = "true" ]; then
51+
gh pr ready "$PR"
52+
fi
53+
```
54+
55+
If still draft with CI red, do nothing — wait for CI to go green first (step 1), then this check flips it on the next pass.
56+
3757
## 6a. Wait for CI
3858

3959
After any push, wait 30s then watch:

0 commit comments

Comments
 (0)