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