@olegkoval/agent-skills 1.51.0 → 1.51.2

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