Iterate a PR until CI is green
Drives an open PR to green: fixes failing CI and high and medium review comments, verifies locally, commits, pushes and repeats, stopping at human approval or draft gates. Use when a PR is red or has review feedback to work through.
iterate-pr- Author
- Sentry
- Source
- getsentry/skills/skills/iterate-pr @ a582c51
- License
- Apache-2.0 · Copyright 2025 Functional Software, Inc. dba Sentry
About this skill
What it does
The skill takes an existing PR and loops until the checks the agent can act on are green and high and medium review feedback is fixed. Each round it reads new comments and failed logs, names the cause, fixes it, reruns the affected check locally, commits, pushes and looks again. It stops at gates code cannot open: human approval, draft status, merge readiness.
Four Python scripts, run with uv run, talk to GitHub through gh:
fetch_pr_checks.py: check states as JSON with counts of failed, pending and human-gated checks and log snippets of failures.fetch_pr_feedback.py: comments sorted into high, medium, low, bot and resolved, by Sentry's LOGAF markers (h:,m:,l:) and then by wording; unmarked means medium. Review bots like Bugbot or CodeQL count as reviewers, Codecov and Dependabot are skipped.monitor_pr_checks.py: polls every 30 seconds until an end marker such asALL_CHECKS_PASSED; Claude Code can run it in the background.reply_to_thread.py: replies to review threads in one GraphQL call.
You choose which low-priority suggestions to take. A failure that survives two attempts comes back to you; no PR, no checks or a needed rebase ends the run. SPEC.md holds the maintainers' contract, agents/openai.yaml the Codex display name and default prompt.
When to use it, and when not
Use it when a PR is red or buried in review comments and the agent should work through them unattended.
It commits and pushes to the PR branch itself, so agree on that before using it on a shared branch. It does not open PRs, merge, rebase or mark drafts ready unless asked. It needs an authenticated gh and uv, run from the repository root.
How to run it
The install command below puts the folder in place, scripts included. The agent picks the skill up by its description; to call it yourself:
- Claude Code:
/iterate-pr, or ask for the skill by name. - Codex:
$iterate-pr. - Cursor: type
/in the Agent chat and pickiterate-pr.
Example: /iterate-pr PR 1042 fails lint and two tests; fix them and address the review comments.
How it differs from similar skills
Fix failing GitHub Actions checks from the OpenAI pack summarises failing logs and edits only after you approve a plan; iterate-pr fixes, pushes and repeats by itself and handles comments too. Address GitHub PR comments fixes the comments you pick. Responding to review feedback from our catalog checks each claim against the code and drafts replies, but does not watch CI.
Install
Run one command — it saves SKILL.md and the files it uses into your agent's skills folder. Claude Code and Codex pick up a new skill without a restart; if it does not show up, restart the agent.
curl -fsSL --create-dirs -o ~/.claude/skills/iterate-pr/SKILL.md https://anymodel.org/en/skills/sentry/iterate-pr/SKILL.md -o ~/.claude/skills/iterate-pr/LICENSE https://anymodel.org/en/skills/sentry/iterate-pr/LICENSE -o ~/.claude/skills/iterate-pr/SPEC.md https://anymodel.org/en/skills/sentry/iterate-pr/SPEC.md -o ~/.claude/skills/iterate-pr/agents/openai.yaml https://anymodel.org/en/skills/sentry/iterate-pr/agents/openai.yaml -o ~/.claude/skills/iterate-pr/scripts/fetch_pr_checks.py https://anymodel.org/en/skills/sentry/iterate-pr/scripts/fetch_pr_checks.py -o ~/.claude/skills/iterate-pr/scripts/fetch_pr_feedback.py https://anymodel.org/en/skills/sentry/iterate-pr/scripts/fetch_pr_feedback.py -o ~/.claude/skills/iterate-pr/scripts/monitor_pr_checks.py https://anymodel.org/en/skills/sentry/iterate-pr/scripts/monitor_pr_checks.py -o ~/.claude/skills/iterate-pr/scripts/reply_to_thread.py https://anymodel.org/en/skills/sentry/iterate-pr/scripts/reply_to_thread.py && chmod +x ~/.claude/skills/iterate-pr/scripts/fetch_pr_checks.py ~/.claude/skills/iterate-pr/scripts/fetch_pr_feedback.py
curl -fsSL --create-dirs -o ~/.agents/skills/iterate-pr/SKILL.md https://anymodel.org/en/skills/sentry/iterate-pr/SKILL.md -o ~/.agents/skills/iterate-pr/LICENSE https://anymodel.org/en/skills/sentry/iterate-pr/LICENSE -o ~/.agents/skills/iterate-pr/SPEC.md https://anymodel.org/en/skills/sentry/iterate-pr/SPEC.md -o ~/.agents/skills/iterate-pr/agents/openai.yaml https://anymodel.org/en/skills/sentry/iterate-pr/agents/openai.yaml -o ~/.agents/skills/iterate-pr/scripts/fetch_pr_checks.py https://anymodel.org/en/skills/sentry/iterate-pr/scripts/fetch_pr_checks.py -o ~/.agents/skills/iterate-pr/scripts/fetch_pr_feedback.py https://anymodel.org/en/skills/sentry/iterate-pr/scripts/fetch_pr_feedback.py -o ~/.agents/skills/iterate-pr/scripts/monitor_pr_checks.py https://anymodel.org/en/skills/sentry/iterate-pr/scripts/monitor_pr_checks.py -o ~/.agents/skills/iterate-pr/scripts/reply_to_thread.py https://anymodel.org/en/skills/sentry/iterate-pr/scripts/reply_to_thread.py && chmod +x ~/.agents/skills/iterate-pr/scripts/fetch_pr_checks.py ~/.agents/skills/iterate-pr/scripts/fetch_pr_feedback.py
foreach ($f in 'SKILL.md','LICENSE','SPEC.md','agents/openai.yaml','scripts/fetch_pr_checks.py','scripts/fetch_pr_feedback.py','scripts/monitor_pr_checks.py','scripts/reply_to_thread.py') { $p = Join-Path "$HOME\.claude\skills\iterate-pr" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/sentry/iterate-pr/$f" -UseBasicParsing -OutFile $p }foreach ($f in 'SKILL.md','LICENSE','SPEC.md','agents/openai.yaml','scripts/fetch_pr_checks.py','scripts/fetch_pr_feedback.py','scripts/monitor_pr_checks.py','scripts/reply_to_thread.py') { $p = Join-Path "$HOME\.agents\skills\iterate-pr" $f; New-Item -ItemType Directory -Force (Split-Path $p) | Out-Null; Invoke-WebRequest "https://anymodel.org/en/skills/sentry/iterate-pr/$f" -UseBasicParsing -OutFile $p }Any other agent: save the file into its skills folder, or give it the link to the file: https://anymodel.org/en/skills/sentry/iterate-pr/SKILL.md
SKILL.md
Iterate on PR Until CI Passes
Goal: fix actionable CI failures and high/medium review feedback. Stop and report human approval, draft-readiness, and merge-readiness gates.
Requires:
- authenticated
gh uv- target repository root as cwd
- skill-root-relative script paths, for example
scripts/fetch_pr_checks.py
Bundled Scripts
| Script | Run | Output |
|---|---|---|
scripts/fetch_pr_checks.py |
uv run scripts/fetch_pr_checks.py [--pr NUMBER] |
JSON: pr, summary, checks, failure snippets |
scripts/fetch_pr_feedback.py |
uv run scripts/fetch_pr_feedback.py [--pr NUMBER] |
JSON buckets: high, medium, low, bot, resolved |
scripts/monitor_pr_checks.py |
uv run scripts/monitor_pr_checks.py [--pr NUMBER] |
terminal marker plus tab-separated checks |
scripts/reply_to_thread.py |
uv run scripts/reply_to_thread.py THREAD_ID BODY [...] |
JSON reply results |
Check summary fields include failed, pending, actionable_pending, and human_gate_pending.
Monitor markers:
ALL_CHECKS_PASSEDCHECKS_DONE_WITH_FAILURESNO_CHECKS_REGISTEREDDRAFT_PR_WITH_NO_CHECKSCHECKS_BLOCKED_BY_REVIEW_GATE
Workflow
1. Identify PR
Run:
gh pr view --json number,url,headRefName,isDraft,reviewDecision
Stop when:
- no PR exists
- draft PR has no checks after monitor grace period: report
DRAFT_PR_WITH_NO_CHECKS
Draft rule: inspect existing checks/feedback only. Do not mark ready for review unless asked.
2. Handle Feedback
Run uv run scripts/fetch_pr_feedback.py [--pr NUMBER].
| Bucket | Action |
|---|---|
high |
fix |
medium |
fix |
low |
ask user which to address |
bot |
skip informational comments |
resolved |
skip |
Feedback fix checklist:
- verify root cause
- search related code
- fix all instances
- for
review_bot: true: fix real issues, explain false positives
Low-priority prompt format:
Found 3 low-priority suggestions:
1. [l] "Consider renaming this variable" - @reviewer in api.py:42
2. [nit] "Could use a list comprehension" - @reviewer in utils.py:18
3. [style] "Add a docstring" - @reviewer in models.py:55
Which should I address? ("1,3", "all", or "none")
3. Check CI Status
Run uv run scripts/fetch_pr_checks.py [--pr NUMBER].
| State | Action |
|---|---|
failed > 0 and actionable_pending == 0 |
fix failures |
actionable_pending > 0 |
wait; poll feedback while waiting |
pending > 0 and actionable_pending == 0 |
report CHECKS_BLOCKED_BY_REVIEW_GATE |
| no checks after grace period | report NO_CHECKS_REGISTERED or DRAFT_PR_WITH_NO_CHECKS |
| all actionable checks passed | run post-CI feedback check |
Wait for actionable review bots: sentry, warden, cursor, bugbot, seer, codeql.
Do not wait for approval, isDraft, REVIEW_REQUIRED, Codecov, or informational bots.
4. Fix CI Failures
For each failure:
- read full log:
gh run view <run-id> --log-failed - trace from assertion/exception/lint rule to source
- state the cause before editing: "fails because X, affected by Y"
- search related call sites/patterns
- fix root cause, not symptom
- add focused test coverage when needed
5. Verify Locally, Then Commit and Push
Before commit:
- test fix: rerun specific test
- lint/type fix: rerun affected checker
- code fix: rerun covering tests
- local failure: fix before pushing
git add <files>
git commit -m "fix: <descriptive message>"
git push
6. Monitor CI and Address Feedback
Loop:
- run
uv run scripts/fetch_pr_checks.py - handle table in step 3
- while
actionable_pending > 0, runuv run scripts/fetch_pr_feedback.py - fix new high/medium feedback immediately
- if changed, verify, commit, push, restart loop
- otherwise sleep 30 seconds and repeat
- after checks pass, wait 10 seconds, fetch feedback once more
- if new high/medium feedback exists, return to step 4
Claude Code optional: run uv run scripts/monitor_pr_checks.py through MonitorTool with persistent: false; set timeout to normal repo CI duration. Restart the monitor after every push.
Exit Conditions
| Exit | Conditions |
|---|---|
| Success | actionable CI passed; post-CI feedback clean; low-priority choice handled |
| Ask user | same failure after 2 attempts; feedback unclear; infrastructure issue |
| Stop | no PR; branch needs rebase; no checks; draft no-checks; only human gates remain |
Fallback
If scripts fail, use gh CLI directly:
gh pr view --json number,url,headRefName,isDraft,reviewDecisiongh pr checks --json name,state,bucket,description,linkgh run view <run-id> --log-failedgh api repos/{owner}/{repo}/pulls/{number}/comments
Connect through AnyModel API
This skill runs on whatever model your agent uses. Point Claude Code, Codex or Cursor at AnyModel to run it on Claude, GPT, Gemini and more with one key — pay per token, no subscription.
AnyModel