@olegkoval/agent-skills 1.51.1 → 1.51.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/.github/prompts/coderabbitloop.prompt.md +72 -23
  2. package/.github/prompts/codexloop.prompt.md +87 -92
  3. package/.github/prompts/copilotloop.prompt.md +84 -88
  4. package/.github/prompts/geminiloop.prompt.md +85 -85
  5. package/.github/prompts/qodoloop.prompt.md +78 -20
  6. package/.kiro/steering/coderabbitloop.md +72 -23
  7. package/.kiro/steering/codexloop.md +87 -92
  8. package/.kiro/steering/copilotloop.md +84 -88
  9. package/.kiro/steering/geminiloop.md +85 -85
  10. package/.kiro/steering/qodoloop.md +78 -20
  11. package/.windsurf/rules/coderabbitloop.md +72 -23
  12. package/.windsurf/rules/codexloop.md +87 -92
  13. package/.windsurf/rules/copilotloop.md +84 -88
  14. package/.windsurf/rules/geminiloop.md +85 -85
  15. package/.windsurf/rules/qodoloop.md +78 -20
  16. package/adapters/claude/olko-github-pr/skills/coderabbitloop/SKILL.md +73 -24
  17. package/adapters/claude/olko-github-pr/skills/coderabbitloop/scripts/pr-review-state.sh +163 -0
  18. package/adapters/claude/olko-github-pr/skills/codexloop/SKILL.md +90 -95
  19. package/adapters/claude/olko-github-pr/skills/codexloop/scripts/pr-review-state.sh +163 -0
  20. package/adapters/claude/olko-github-pr/skills/copilotloop/SKILL.md +85 -89
  21. package/adapters/claude/olko-github-pr/skills/copilotloop/scripts/pr-review-state.sh +163 -0
  22. package/adapters/claude/olko-github-pr/skills/geminiloop/SKILL.md +87 -87
  23. package/adapters/claude/olko-github-pr/skills/geminiloop/scripts/pr-review-state.sh +163 -0
  24. package/adapters/claude/olko-github-pr/skills/lekker-review/SKILL.md +11 -3
  25. package/adapters/claude/olko-github-pr/skills/lekker-review/references/github-post.md +4 -3
  26. package/adapters/claude/olko-github-pr/skills/qodoloop/SKILL.md +79 -21
  27. package/adapters/claude/olko-github-pr/skills/qodoloop/scripts/pr-review-state.sh +163 -0
  28. package/adapters/cursor/olko-github-pr/skills/coderabbitloop/SKILL.md +73 -24
  29. package/adapters/cursor/olko-github-pr/skills/coderabbitloop/scripts/pr-review-state.sh +163 -0
  30. package/adapters/cursor/olko-github-pr/skills/codexloop/SKILL.md +90 -95
  31. package/adapters/cursor/olko-github-pr/skills/codexloop/scripts/pr-review-state.sh +163 -0
  32. package/adapters/cursor/olko-github-pr/skills/copilotloop/SKILL.md +85 -89
  33. package/adapters/cursor/olko-github-pr/skills/copilotloop/scripts/pr-review-state.sh +163 -0
  34. package/adapters/cursor/olko-github-pr/skills/geminiloop/SKILL.md +87 -87
  35. package/adapters/cursor/olko-github-pr/skills/geminiloop/scripts/pr-review-state.sh +163 -0
  36. package/adapters/cursor/olko-github-pr/skills/qodoloop/SKILL.md +79 -21
  37. package/adapters/cursor/olko-github-pr/skills/qodoloop/scripts/pr-review-state.sh +163 -0
  38. package/adapters/grok/olko-github-pr/skills/coderabbitloop/SKILL.md +73 -24
  39. package/adapters/grok/olko-github-pr/skills/coderabbitloop/scripts/pr-review-state.sh +163 -0
  40. package/adapters/grok/olko-github-pr/skills/codexloop/SKILL.md +90 -95
  41. package/adapters/grok/olko-github-pr/skills/codexloop/scripts/pr-review-state.sh +163 -0
  42. package/adapters/grok/olko-github-pr/skills/copilotloop/SKILL.md +85 -89
  43. package/adapters/grok/olko-github-pr/skills/copilotloop/scripts/pr-review-state.sh +163 -0
  44. package/adapters/grok/olko-github-pr/skills/geminiloop/SKILL.md +87 -87
  45. package/adapters/grok/olko-github-pr/skills/geminiloop/scripts/pr-review-state.sh +163 -0
  46. package/adapters/grok/olko-github-pr/skills/qodoloop/SKILL.md +79 -21
  47. package/adapters/grok/olko-github-pr/skills/qodoloop/scripts/pr-review-state.sh +163 -0
  48. package/package.json +1 -1
  49. package/plugins/olko-apple-kit/.claude-plugin/plugin.json +1 -1
  50. package/plugins/olko-creative/.claude-plugin/plugin.json +1 -1
  51. package/plugins/olko-garmin-kit/.claude-plugin/plugin.json +1 -1
  52. package/plugins/olko-git-tools/.claude-plugin/plugin.json +1 -1
  53. package/plugins/olko-github-pr/.claude-plugin/plugin.json +1 -1
  54. package/plugins/olko-github-pr/skills/coderabbitloop/SKILL.md +73 -24
  55. package/plugins/olko-github-pr/skills/coderabbitloop/scripts/pr-review-state.sh +163 -0
  56. package/plugins/olko-github-pr/skills/codexloop/SKILL.md +90 -95
  57. package/plugins/olko-github-pr/skills/codexloop/scripts/pr-review-state.sh +163 -0
  58. package/plugins/olko-github-pr/skills/copilotloop/SKILL.md +85 -89
  59. package/plugins/olko-github-pr/skills/copilotloop/scripts/pr-review-state.sh +163 -0
  60. package/plugins/olko-github-pr/skills/geminiloop/SKILL.md +87 -87
  61. package/plugins/olko-github-pr/skills/geminiloop/scripts/pr-review-state.sh +163 -0
  62. package/plugins/olko-github-pr/skills/lekker-review/SKILL.md +11 -3
  63. package/plugins/olko-github-pr/skills/lekker-review/references/github-post.md +4 -3
  64. package/plugins/olko-github-pr/skills/qodoloop/SKILL.md +79 -21
  65. package/plugins/olko-github-pr/skills/qodoloop/scripts/pr-review-state.sh +163 -0
  66. package/plugins/olko-obsidian/.claude-plugin/plugin.json +1 -1
  67. package/plugins/olko-product/.claude-plugin/plugin.json +1 -1
  68. package/plugins/olko-reflection/.claude-plugin/plugin.json +1 -1
  69. package/plugins/olko-release/.claude-plugin/plugin.json +1 -1
  70. package/plugins/olko-skill-meta/.claude-plugin/plugin.json +1 -1
  71. package/plugins/olko-web-ops/.claude-plugin/plugin.json +1 -1
@@ -30,6 +30,27 @@ CodeRabbit has slash commands (official, `docs.coderabbit.ai/reference/review-co
30
30
 
31
31
  **Rate limit is a real terminal state, not a bug.** A comment reading "you've reached your PR review limit" (confirmed live wording) means CodeRabbit will not review again this cycle: stop and report it, don't loop waiting for something that isn't coming.
32
32
 
33
+ ## Review state comes from the PR, not from memory
34
+
35
+ `scripts/pr-review-state.sh` reads the PR and prints one JSON object: the current head, whether
36
+ CodeRabbit has acted on that head (a review of it, or any comment after it was pushed), and every
37
+ unresolved review thread with its author. Every "is there work / are we done" decision in this
38
+ loop comes from its exit code, never from what you remember resolving. The script lives in this
39
+ skill's directory, `SKILL_ROOT`: the directory holding this `SKILL.md` (Claude Code prints it as the
40
+ skill's base directory when the skill loads; in Codex, derive it from the selected `SKILL.md` path).
41
+
42
+ | Exit | `verdict` | Meaning | Do |
43
+ |------|------------|---------------------------------------------------------------------|--------------------------------------|
44
+ | 0 | `clean` | CodeRabbit acted on the current head and no bot thread is unresolved | exit check: done |
45
+ | 10 | `findings` | unresolved threads from CodeRabbit **or any other review bot** | run an iteration |
46
+ | 20 | `pending` | CodeRabbit has not acted on the current head yet | trigger if needed, then wait |
47
+ | 30 | `limited` | a rate-limit or paused notice from CodeRabbit after the current head | stop, report `blocked: rate-limited` |
48
+
49
+ Resolving the last thread does not make a PR clean: CodeRabbit has not reviewed your push yet. Earlier
50
+ versions of this loop exited at exactly that moment, while the next round of comments was still on
51
+ its way. Human threads are listed in `.unresolved` (`is_bot: false`) and counted in `.counts.humans`;
52
+ they never block `clean`, and this loop never resolves them.
53
+
33
54
  ## Instructions
34
55
 
35
56
  ### 1. Identify the PR
@@ -54,38 +75,50 @@ gets those edits swept into the fix commit right along with it.
54
75
  Keep an explicit iteration counter and stop at 5: the cap is a real bound to enforce, not a figure
55
76
  of speech. Each pass through A–F is one iteration; on hitting the cap, go straight to the report.
56
77
 
57
- #### A. Wait for a review of the current head
58
-
59
- On **iteration 1**, if there is nothing to push yet (you haven't fixed anything in this loop), don't
60
- wait for a brand-new review: use whatever CodeRabbit has already posted as your starting point and
61
- go straight to step B. Otherwise:
62
-
63
- ```bash
64
- SINCE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
65
- git push
66
- ```
78
+ #### A. Read the PR state; wait for CodeRabbit's review of the current head
67
79
 
68
- If this repo doesn't auto-review on push, nudge it:
80
+ One read answers both "is there work?" and "has CodeRabbit seen my last push?". `SINCE` is the
81
+ timestamp you took right before your last push (step E); leave it empty on iteration 1. Right
82
+ after a push, add `--wait 600` straight away: the wait ends only once the bot has acted on the new
83
+ head, so threads left open on purpose cannot make the push look reviewed.
69
84
 
70
85
  ```bash
71
- gh pr comment <PR_NUMBER> --body "@coderabbitai review"
86
+ "$SKILL_ROOT/scripts/pr-review-state.sh" --repo OWNER/REPO --pr <PR> --bot coderabbitai --since "$SINCE"
72
87
  ```
73
88
 
74
- Poll (every ~10s, timeout ~5min) for CodeRabbit's next formal review to land: a new entry in
75
- `gh api --paginate repos/{owner}/{repo}/pulls/<PR_NUMBER>/reviews` from `coderabbitai[bot]`
76
- (REST spelling carries the `[bot]` suffix) created after `$SINCE`. Follow pagination so a review
77
- that lands on page two is not missed. If you instead see a rate-limit comment ("review limit"),
78
- **stop the loop now** and go to Report with `blocked: rate-limited`. If no review arrives within
79
- the timeout after one retry, stop and report the timeout honestly; do not claim success.
89
+ - Exit `10` (`findings`): go to B. On iteration 1 this is whatever CodeRabbit (or another bot)
90
+ already posted.
91
+ - Exit `20` (`pending`): post `@coderabbitai review` if this repo does not review pushes automatically (`gh pr comment <PR_NUMBER> --body "@coderabbitai review"`). Then wait with the same command plus `--wait 600`. Run the
92
+ wait in the background where the host allows it (Claude Code: Bash `run_in_background`; you are
93
+ re-invoked when it exits) so ten minutes of polling never sits in the conversation. Still `20`
94
+ after the wait: say so out loud, post `@coderabbitai review` once more, and wait once more. Still `20` after that: stop and
95
+ report the timeout honestly; never claim success.
96
+ - Exit `0` (`clean`): go to the exit check. A `--wait` call returns `clean` only after a settle
97
+ re-read 60 seconds later, so a comment landing right behind the review is still caught. A bare
98
+ read (no `--wait`) that says `clean` is good enough only when you have not pushed since CodeRabbit's
99
+ last review.
100
+ - Exit `30` (`limited`): stop now and report `blocked: rate-limited`; nothing more is coming.
101
+ - Exit `1`: the read itself failed (often a transient GitHub 502). Retry once; if it fails again,
102
+ stop and report it. An unknown state is not a clean one.
80
103
 
81
104
  #### B. Fetch unresolved findings
82
105
 
83
- Run the `unresolvedQodoThreads`-shaped query in `references/graphql-queries.md` (filter `author.login`
84
- on GraphQL's bare `coderabbitai`, **not** REST's `coderabbitai[bot]`: see the reference's login-spelling
85
- note, and follow `pageInfo.hasNextPage`/`endCursor` until exhausted). For each unresolved thread,
86
- parse the finding text, its `databaseId`, and the **Prompt for AI Agents** block (heading text is
106
+ The working set is every unresolved thread in the state JSON with `is_bot: true`: CodeRabbit's
107
+ own (`is_target: true`) **and any other review bot's** (Greptile, for example). A
108
+ fix for one bot often draws a comment from another, and leaving those open is how a "finished" loop
109
+ leaves a PR that is not clean. Never act on a human's thread (`is_bot: false`); list it in the report.
110
+
111
+ CodeRabbit's threads are `.unresolved[] | select(.is_target)` in step A's state JSON (the script
112
+ already follows pagination). For each, read the full comment
113
+ (`gh api repos/{owner}/{repo}/pulls/comments/<comment_id>`) and parse the finding text and the
114
+ **Prompt for AI Agents** block (heading text is
87
115
  `🤖 Prompt for AI Agents`, not `Agent Prompt`: match case/emoji-insensitively).
88
116
 
117
+ Threads from other bots come from the state JSON (`.unresolved[] | select(.is_bot and (.is_target | not))`).
118
+ They carry no ready-made fix prompt: read the full comment
119
+ (`gh api repos/{owner}/{repo}/pulls/comments/<comment_id>`), verify its claim against the real
120
+ code, and handle it like any CodeRabbit finding: fix it, or reply with the evidence for not fixing it.
121
+
89
122
  Mark each thread as seen with an 👀 reaction on its first comment (`databaseId` from the query), so
90
123
  the bot and a watching human can tell it is being worked:
91
124
 
@@ -95,7 +128,9 @@ gh api --method POST repos/{owner}/{repo}/pulls/comments/<DATABASE_ID>/reactions
95
128
 
96
129
  #### C. Check exit conditions
97
130
 
98
- Stop if there are zero unresolved CodeRabbit threads, or max iterations reached.
131
+ Stop when step A's read exited `0` (`clean`) after your last push (a `--wait` read, which settles),
132
+ or exited `30` (`limited`), or the iteration cap is reached. An empty working set on its own is not
133
+ done: with no review of the current head yet, it only means CodeRabbit has not answered your push.
99
134
 
100
135
  #### D. Fix each finding
101
136
 
@@ -115,6 +150,7 @@ If step D changed code:
115
150
  git status --short # look before you stage
116
151
  git add <path> [<path>...] # the files named in the findings you fixed
117
152
  git commit -m "address CodeRabbit review feedback (coderabbitloop iteration N)"
153
+ SINCE=$(date -u +%Y-%m-%dT%H:%M:%SZ) # step A reads bot activity after this
118
154
  git push
119
155
  ```
120
156
 
@@ -163,6 +199,18 @@ the reply, and a resolved thread with no reply loses the reasoning.
163
199
 
164
200
  Go back to step A.
165
201
 
202
+ ### Keep the context small; resume instead of restarting
203
+
204
+ - Carry only three things between iterations: the iteration counter, the latest state JSON, and a
205
+ ledger of each thread you handled (fixed with its commit, rebutted, or blocked). Re-read files
206
+ fresh each iteration; do not re-paste earlier rounds' comment bodies.
207
+ - All loop state lives on the PR, so the loop is resumable. If the session has grown long or slow,
208
+ or a bot commented after the loop ended, run this skill again in a fresh session: step A picks up
209
+ from the PR as it is now. Starting fresh is cheaper than dragging a long session through more
210
+ rounds.
211
+ - After reporting done, if the host can schedule a follow-up (Claude Code: `/loop` or a scheduled
212
+ wakeup), offer one re-check about 20 minutes later for bots that comment late.
213
+
166
214
  ### 3. Report
167
215
 
168
216
  | Field | Value |
@@ -171,6 +219,7 @@ Go back to step A.
171
219
  | Findings resolved | N |
172
220
  | Findings skipped | N (with reasons) |
173
221
  | Remaining | N (if any) |
222
+ | Human threads | N (open, listed; never resolved by this loop) |
174
223
  | Blocked | rate-limited / timeout / max-iterations / none |
175
224
 
176
225
  ```
@@ -16,7 +16,8 @@ suggestion applied is worse than the comment itself.
16
16
 
17
17
  - **No check-run, no score.** Codex does not publish an `X/5` confidence or a named check. It posts
18
18
  a **PR review** (state `COMMENTED`) plus inline review comments. Detection is by polling the
19
- *reviews* endpoint. "Satisfied" = zero unresolved comments (each either fixed or rebutted).
19
+ *reviews* endpoint. "Satisfied" = Codex has reviewed the latest push and no bot comment is left unresolved (each
20
+ either fixed or rebutted).
20
21
  - **Trigger phrase is `@codex review`.** Codex reviews automatically when a PR opens or gets new
21
22
  commits if auto-review is enabled on the repo; the mention forces a fresh pass. Other useful
22
23
  mentions: `@codex review focus on <area>` for a scoped re-review.
@@ -48,11 +49,32 @@ Pick the login matching `*codex*` (commonly `chatgpt-codex-connector[bot]`, some
48
49
 
49
50
  **Finding nothing here is NOT a stop condition.** On a PR Codex has never reviewed there is no bot
50
51
  login to find yet: that is the normal starting state, not a missing app. When the probe comes back
51
- empty, fall through to step 2A, post `@codex review`, and re-run this probe once a review lands;
52
+ empty, fall through to step A, post `@codex review`, and re-run this probe once a review lands;
52
53
  until then match any login containing `codex` when polling. Only conclude the app is absent after
53
- step 2A's bounded wait has expired with no review and no codex-like login anywhere on the PR, and
54
+ step A's bounded wait has expired with no review and no codex-like login anywhere on the PR, and
54
55
  then say so and stop, rather than looping against nothing.
55
56
 
57
+ ## Review state comes from the PR, not from memory
58
+
59
+ `scripts/pr-review-state.sh` reads the PR and prints one JSON object: the current head, whether
60
+ Codex has acted on that head (a review of it, or any comment after it was pushed), and every
61
+ unresolved review thread with its author. Every "is there work / are we done" decision in this
62
+ loop comes from its exit code, never from what you remember resolving. The script lives in this
63
+ skill's directory, `SKILL_ROOT`: the directory holding this `SKILL.md` (Claude Code prints it as the
64
+ skill's base directory when the skill loads; in Codex, derive it from the selected `SKILL.md` path).
65
+
66
+ | Exit | `verdict` | Meaning | Do |
67
+ |------|------------|---------------------------------------------------------------------|--------------------------------------|
68
+ | 0 | `clean` | Codex acted on the current head and no bot thread is unresolved | exit check: done |
69
+ | 10 | `findings` | unresolved threads from Codex **or any other review bot** | run an iteration |
70
+ | 20 | `pending` | Codex has not acted on the current head yet | trigger if needed, then wait |
71
+ | 30 | `limited` | a rate-limit or paused notice from Codex after the current head | stop, report `blocked: rate-limited` |
72
+
73
+ Resolving the last thread does not make a PR clean: Codex has not reviewed your push yet. Earlier
74
+ versions of this loop exited at exactly that moment, while the next round of comments was still on
75
+ its way. Human threads are listed in `.unresolved` (`is_bot: false`) and counted in `.counts.humans`;
76
+ they never block `clean`, and this loop never resolves them.
77
+
56
78
  ## 1. Identify the PR
57
79
 
58
80
  ```bash
@@ -73,66 +95,50 @@ Keep an explicit iteration counter and stop at 5: the cap is a real bound to enf
73
95
  figure of speech. Each pass through A–G is one iteration; on hitting the cap, go straight to the
74
96
  report and list what is still unresolved rather than starting a sixth.
75
97
 
76
- ### A. Ensure a fresh Codex review on the current head
77
-
78
- ```bash
79
- HEAD_SHA=$(gh pr view <PR> --json headRefOid -q .headRefOid)
80
- # Only trigger if no Codex review already exists for this exact SHA.
81
- # gh cannot combine --slurp with --jq, so pipe to `jq -s`: it folds every page
82
- # into one array. Without it the filter runs once per page and HAVE becomes a
83
- # multi-line count that never equals "0", silently skipping the trigger.
84
- HAVE=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate |
85
- jq -s --arg bot "$BOT" --arg head "$HEAD_SHA" \
86
- '[.[][] | select(.user.login==$bot and .commit_id==$head)] | length')
87
- if [ "$HAVE" = "0" ]; then gh pr comment <PR> --body "@codex review"; fi
88
- ```
98
+ ### A. Read the PR state; wait for Codex's review of the current head
89
99
 
90
- Poll for the review of THIS head to land. No check-run exists, so poll the reviews endpoint, and
91
- poll it on a **deadline**, never `while true`: a review that never arrives must end the skill with
92
- an honest timeout, not hang it.
100
+ One read answers both "is there work?" and "has Codex seen my last push?". `SINCE` is the
101
+ timestamp you took right before your last push (step E); leave it empty on iteration 1. Right
102
+ after a push, add `--wait 600` straight away: the wait ends only once the bot has acted on the new
103
+ head, so threads left open on purpose cannot make the push look reviewed.
93
104
 
94
105
  ```bash
95
- # 10-minute deadline, one retry, then give up. DEADLINE/RETRIES are the
96
- # enforcement of the bounds this skill claims: do not drop them.
97
- wait_for_review() { # $1 = attempt label
98
- local deadline=$(( SECONDS + 600 ))
99
- while [ "$SECONDS" -lt "$deadline" ]; do
100
- R=$(gh api repos/{owner}/{repo}/pulls/<PR>/reviews --paginate |
101
- jq -s --arg bot "$BOT" --arg head "$HEAD_SHA" \
102
- '[.[][] | select(.user.login==$bot and .commit_id==$head)] | sort_by(.submitted_at, .id) | last')
103
- if [ -n "$R" ] && [ "$R" != "null" ]; then return 0; fi
104
- echo "waiting for Codex review of $HEAD_SHA ($1)..."; sleep 15
105
- done
106
- return 1
107
- }
108
-
109
- if ! wait_for_review "first wait"; then
110
- echo "no Codex review after 10m, retrying once" # say the retry out loud
111
- gh pr comment <PR> --body "@codex review"
112
- if ! wait_for_review "after retry"; then
113
- echo "Codex did not review $HEAD_SHA after a retry; stopping and reporting."
114
- exit 1 # honest timeout, never a success claim
115
- fi
116
- fi
106
+ "$SKILL_ROOT/scripts/pr-review-state.sh" --repo OWNER/REPO --pr <PR> --bot codex --since "$SINCE"
117
107
  ```
118
108
 
119
- Codex can take several minutes on a large diff, which is why the deadline is generous. Report the
120
- retry in the final summary; two silent timeouts are the failure mode this guard exists to prevent.
109
+ - Exit `10` (`findings`): go to B. On iteration 1 this is whatever Codex (or another bot)
110
+ already posted.
111
+ - Exit `20` (`pending`): post `@codex review` (`gh pr comment <PR> --body "@codex review"`). Then wait with the same command plus `--wait 600`. Run the
112
+ wait in the background where the host allows it (Claude Code: Bash `run_in_background`; you are
113
+ re-invoked when it exits) so ten minutes of polling never sits in the conversation. Still `20`
114
+ after the wait: say so out loud, post `@codex review` once more, and wait once more. Still `20` after that: stop and
115
+ report the timeout honestly; never claim success.
116
+ - Exit `0` (`clean`): go to the exit check. A `--wait` call returns `clean` only after a settle
117
+ re-read 60 seconds later, so a comment landing right behind the review is still caught. A bare
118
+ read (no `--wait`) that says `clean` is good enough only when you have not pushed since Codex's
119
+ last review.
120
+ - Exit `30` (`limited`): stop now and report `blocked: rate-limited`; nothing more is coming.
121
+ - Exit `1`: the read itself failed (often a transient GitHub 502). Retry once; if it fails again,
122
+ stop and report it. An unknown state is not a clean one.
121
123
 
122
124
  ### B. Fetch the findings
123
125
 
124
- - **Summary**: the review `.body` from the object above: read the overall take and the priority
126
+ The working set is every unresolved thread in the state JSON with `is_bot: true`: Codex's
127
+ own (`is_target: true`) **and any other review bot's** (Greptile, for example). A
128
+ fix for one bot often draws a comment from another, and leaving those open is how a "finished" loop
129
+ leaves a PR that is not clean. Treat another bot's thread with exactly the same verify-first rules
130
+ below. Never act on a human's thread (`is_bot: false`); list it in the report.
131
+
132
+ - **Summary**: the latest review `.body` from this bot (`gh pr view <PR> --json reviews`): read the overall take and the priority
125
133
  spread.
126
- - **Unresolved inline comments** on the current head:
134
+ - **Unresolved inline comments**: `.unresolved[] | select(.is_bot)` in step A's state JSON lists
135
+ each thread's `thread_id`, `comment_id`, `path`, `line` and a short excerpt, across every page of
136
+ threads. Read the full comment before judging it:
127
137
 
128
138
  ```bash
129
- gh api repos/{owner}/{repo}/pulls/<PR>/comments --paginate \
130
- --jq ".[] | select(.user.login==\"$BOT\") | {id, path, line, body}"
139
+ gh api repos/{owner}/{repo}/pulls/comments/<COMMENT_ID> --jq '{user: .user.login, path, line, body}'
131
140
  ```
132
141
 
133
- Also pull the review threads + their resolved state via GraphQL (see step F) so you only act on
134
- unresolved ones.
135
-
136
142
  Mark each unresolved comment as seen, so the bot and a watching human can tell it is being handled.
137
143
  GitHub's reaction set is fixed; `eyes` is the only "looking at it" value:
138
144
 
@@ -189,6 +195,7 @@ If step D changed code:
189
195
  git status --short # look before you stage
190
196
  git add <path> [<path>...] # the files named in the findings you fixed
191
197
  git commit -m "address codex review feedback (codexloop iteration N)"
198
+ SINCE=$(date -u +%Y-%m-%dT%H:%M:%SZ) # step A reads bot activity after this
192
199
  git push
193
200
  ```
194
201
 
@@ -208,38 +215,8 @@ to and resolved without a push.
208
215
 
209
216
  ### F. Reply to and resolve every addressed thread
210
217
 
211
- Only now, with the fixes pushed, reply and resolve. Fetch unresolved threads, **following
212
- pagination**: a PR with more than 100 threads will otherwise look clean while unresolved findings
213
- sit on page two:
214
-
215
- ```bash
216
- # Loop until hasNextPage is false, passing endCursor back in as $cursor.
217
- CURSOR=null
218
- while : ; do
219
- PAGE=$(gh api graphql -F cursor="$CURSOR" -f query='
220
- query($cursor: String) {
221
- repository(owner: "OWNER", name: "REPO") {
222
- pullRequest(number: PR_NUMBER) {
223
- reviewThreads(first: 100, after: $cursor) {
224
- pageInfo { hasNextPage endCursor }
225
- nodes { id isResolved comments(first: 1) { nodes { databaseId author { login } path body } } }
226
- }
227
- }
228
- }
229
- }')
230
- echo "$PAGE" # collect nodes from every page before deciding the PR is clean
231
- # GitHub GraphQL returns transient 502/504s (no .data). An empty page reads as
232
- # "no next page", so retry it a bounded number of times instead of treating it as clean.
233
- if ! echo "$PAGE" | jq -e '.data' >/dev/null 2>&1; then
234
- RETRIES=$(( ${RETRIES:-0} + 1 ))
235
- [ "$RETRIES" -le 3 ] || { echo "GraphQL still failing after 3 retries; threads unknown, not clean"; exit 1; }
236
- sleep 5; continue
237
- fi
238
- PI='.data.repository.pullRequest.reviewThreads.pageInfo'
239
- [ "$(echo "$PAGE" | jq -r "$PI.hasNextPage")" = "true" ] || break
240
- CURSOR=$(echo "$PAGE" | jq -r "$PI.endCursor")
241
- done
242
- ```
218
+ Only now, with the fixes pushed, reply and resolve. Take thread and comment ids from step A's state
219
+ JSON (`.unresolved[]`): the script already follows pagination, so do not hand-roll a threads query.
243
220
 
244
221
  Reply on a thread's comment via `gh api repos/{owner}/{repo}/pulls/<PR>/comments -f body="..." -F in_reply_to=<comment_id>`,
245
222
  then resolve:
@@ -263,7 +240,8 @@ gh api --method POST repos/{owner}/{repo}/pulls/comments/<COMMENT_ID>/reactions
263
240
  Reply first, then react, then resolve: the reaction is not a substitute for the reply, and a
264
241
  resolved thread with no reply loses the reasoning.
265
242
 
266
- Resolve a thread only for comments authored by `$BOT` that you have fixed or rebutted: never
243
+ Resolve a thread only for a bot comment in your working set (this bot's or another
244
+ review bot's) that you have fixed or rebutted: never
267
245
  blanket-resolve, and never resolve a human reviewer's thread. For each fixed comment, verify the
268
246
  push first, reply with the change made, then resolve the thread and verify `isResolved: true`.
269
247
  For each rebutted comment, reply with the evidence and verify resolution. Do not report a comment
@@ -272,19 +250,34 @@ as fixed or rebutted until its thread is confirmed resolved.
272
250
  Threads you are **rebutting** need no push, so they may be replied to and resolved regardless of
273
251
  whether step D changed code.
274
252
 
275
- ### G. Re-review
253
+ ### G. Back to A
276
254
 
277
- Pushing re-triggers Codex when auto-review is on; otherwise post `@codex review`. Go back to **A**
278
- with the new head SHA. If step D changed nothing (all comments were rebutted), skip the push,
279
- ensure all threads are resolved, and exit.
255
+ Go back to **A**. After a push, A waits for Codex's review of the new head (pushing re-triggers
256
+ it when auto-review is on; otherwise A triggers it). If this iteration changed no code (every finding
257
+ rebutted), there is no new head to wait for: A's fresh read says `clean` or shows what is still open.
280
258
 
281
259
  ## 3. Exit conditions
282
260
 
261
+ Decide from a fresh state read, never from what you remember resolving.
262
+
283
263
  Stop when **any** is true:
284
- - Zero unresolved `$BOT` comments remain, and every comment this round was fixed or
285
- rebutted+resolved. (There is no score to hit: this is "done".)
286
- - Max iterations (5) reached: report what remains.
287
- - Codex never responded after one retry: report the timeout honestly; do not claim success.
264
+ - **Done**: the latest `pr-review-state.sh --wait 600` call, made after your last push, exited `0`
265
+ (`clean`); with no push since the bot's last review, a bare read that exits `0` is enough. Open human threads do not block this; list them in the report.
266
+ - **Max iterations (5)** reached: report what remains.
267
+ - **Timeout**: still `pending` after the retry in step A. Report it honestly; do not claim success.
268
+ - **Rate limited**: exit `30`. Report `blocked: rate-limited`.
269
+
270
+ ## Keep the context small; resume instead of restarting
271
+
272
+ - Carry only three things between iterations: the iteration counter, the latest state JSON, and a
273
+ ledger of each thread you handled (fixed with its commit, rebutted, or blocked). Re-read files
274
+ fresh each iteration; do not re-paste earlier rounds' comment bodies.
275
+ - All loop state lives on the PR, so the loop is resumable. If the session has grown long or slow,
276
+ or a bot commented after the loop ended, run this skill again in a fresh session: step A picks up
277
+ from the PR as it is now. Starting fresh is cheaper than dragging a long session through more
278
+ rounds.
279
+ - After reporting done, if the host can schedule a follow-up (Claude Code: `/loop` or a scheduled
280
+ wakeup), offer one re-check about 20 minutes later for bots that comment late.
288
281
 
289
282
  ## 4. Report
290
283
 
@@ -295,7 +288,9 @@ Codexloop complete.
295
288
  Iterations: N
296
289
  Comments fixed: N (genuinely-correct findings)
297
290
  Comments rebutted: N (false positives / nits, resolved with rationale)
298
- Remaining: 0
291
+ Remaining: N (bot threads still open)
292
+ Human threads: N (open, listed below; this loop never resolves them)
293
+ Final state: clean | timeout | rate-limited | iteration cap
299
294
  ```
300
295
 
301
296
  If it stopped at max iterations, list the remaining threads with your current assessment