Skip to content

Add CI watch script, API budget rules and /code-review note for agents - #1164

Merged
Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
agents/ci-monitor-code-review
Oct 10, 2026
Merged

Mikola Lysenko (mikolalysenko) merged 3 commits into
mainfrom
agents/ci-monitor-code-review

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • scripts/ci-watch.sh: a quiet event stream of a PR's CI, for Claude Code's Monitor tool (it also works in a terminal). It prints a start summary, fail: <check> for each failed check, progress: counts, queue: position changes, and a final DONE ... line. Exit status is 0 for pass/merged and 1 for fail/closed/dequeued. --merge follows the PR through the merge queue.
    • Cheap to run: each poll (every 2 minutes) is one small GraphQL query for the PR's rollup state. The full check list, several pages for a PR here, is fetched only when that state changes or every 5th poll. A rate-limited poll pauses 10 minutes.
  • AGENTS.md:
    • Wait on CI by running the script under Monitor, not with sleep + gh pr checks loops or /loop.
    • Run /code-review high (and --fix) before a PR leaves draft or enters the merge queue. Use --comment when reviewing someone else's PR.
    • New section, Share the GitHub API budget: check x-ratelimit-remaining before bulk reads, cap pagination and parallelism, stop on rate-limit errors, and keep at most one re-check reminder per PR.

Why

Every agent and routine calls GitHub as one account and shares one 5,000/hour budget. On 2026-10-08 a bulk Actions fetch by the new CI profiler, plus ~18 concurrent agent sessions, ran that budget to zero twice in one evening, and every agent stalled. The cloud routines' prompts got the same budget rules separately; this PR puts them where every agent reading this repo will see them.

Testing

🤖 Generated with Claude Code


Note

Low Risk
Documentation and a local gh helper script only; no changes to application runtime, auth, or data paths.

Overview
Adds scripts/ci-watch.sh, a quiet CI/merge-queue event stream for Monitor (or a terminal): rollup-gated GraphQL polls, full gh pr checks only when status changes or every 5th poll, fail:/progress:/queue: lines, 10-minute pause on rate limits, and exit codes for pass/fail/merged/dequeued.

AGENTS.md now tells agents to use that script instead of sleep/gh pr checks loops, run /code-review high (and --fix / --comment) before leaving draft or entering the merge queue, and follow shared GitHub API budget rules (check x-ratelimit-remaining, cap pagination/parallelism, stop on 403/429, one re-check reminder per PR).

Reviewed by Cursor Bugbot for commit fd1987d. Configure here.

scripts/ci-watch.sh turns a PR's CI into a quiet event stream meant for
Claude Code's Monitor tool: a start summary, one line per failed check,
progress counts, merge-queue position, and a final DONE line with an exit
status (0 pass/merged, 1 fail/closed/dequeued). It reads checks through
`gh pr checks`, which pages past the ~400-550 checks a PR here runs, and
reports passes as counts so a monitor isn't flooded.

AGENTS.md now tells agents to wait on CI with that script under Monitor
rather than sleep/gh polling loops, and to run /code-review high (with
--fix) before a PR leaves draft or enters the merge queue.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ci-watch.sh now reads only the PR's rollup state each poll (one small
GraphQL query, every 2 minutes) and fetches the full check list, which
is several pages for a PR here, only when that state changes or every
5th poll. A rate-limited poll pauses 10 minutes instead of retrying.

AGENTS.md gains a "Share the GitHub API budget" section. Every agent and
routine calls GitHub as one account, and on 2026-10-08 a bulk Actions
fetch plus ~18 concurrent sessions ran the shared 5,000/hour quota to
zero twice in one evening.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mikolalysenko Mikola Lysenko (mikolalysenko) changed the title Add CI watch script and agent notes for Monitor and /code-review Add CI watch script, API budget rules and /code-review note for agents Oct 8, 2026
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review October 10, 2026 13:13

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Watch script can exit too early
    • Added check for terminal statusCheckRollup.state (SUCCESS/FAILURE/ERROR) before exiting to prevent premature exit when checks are expected but not yet created or when draft jobs are skipped.

Create PR

Or push these changes by commenting:

@cursor push cd1fb43bf9
Preview (cd1fb43bf9)
diff --git a/scripts/ci-watch.sh b/scripts/ci-watch.sh
--- a/scripts/ci-watch.sh
+++ b/scripts/ci-watch.sh
@@ -101,8 +101,12 @@
 
   if [ "$merge" = 0 ]; then
     if [ "$total" -gt 0 ] && [ "$pending" = 0 ]; then
-      if [ "$fail" = 0 ]; then echo "DONE checks pass ($total checks)"; exit 0; fi
-      echo "DONE checks fail ($fail of $total failed)"; exit 1
+      case "$rollup" in
+        SUCCESS|FAILURE|ERROR)
+          if [ "$fail" = 0 ]; then echo "DONE checks pass ($total checks)"; exit 0; fi
+          echo "DONE checks fail ($fail of $total failed)"; exit 1
+          ;;
+      esac
     fi
   fi
   sleep "$interval"

You can send follow-ups to the cloud agent here.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit fd1987d. Configure here.

Comment thread scripts/ci-watch.sh
Comment thread scripts/ci-watch.sh Outdated
Only report DONE when the statusCheckRollup is SUCCESS/FAILURE/ERROR as
well as the gh pr checks list having no pending entries, so expected or
not-yet-created checks keep the watch running. A failed gh pr checks
call now keeps the previous counts, retries on the next poll, and pauses
10 minutes when its stderr shows a rate limit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Oct 10, 2026
Merged via the queue into main with commit 5d6efbc Oct 10, 2026
53 checks passed
@mikolalysenko
Mikola Lysenko (mikolalysenko) deleted the agents/ci-monitor-code-review branch October 10, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants