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.

Git & PRsPack: Sentry skills145 linesiterate-pr
Author
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 as ALL_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 pick iterate-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.

Claude Code — macOS, Linux
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
Codex, Cursor — macOS, Linux
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
Claude Code — Windows PowerShell
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 }
Codex, Cursor — Windows PowerShell
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

Raw

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_PASSED
  • CHECKS_DONE_WITH_FAILURES
  • NO_CHECKS_REGISTERED
  • DRAFT_PR_WITH_NO_CHECKS
  • CHECKS_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:

  1. read full log: gh run view <run-id> --log-failed
  2. trace from assertion/exception/lint rule to source
  3. state the cause before editing: "fails because X, affected by Y"
  4. search related call sites/patterns
  5. fix root cause, not symptom
  6. 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:

  1. run uv run scripts/fetch_pr_checks.py
  2. handle table in step 3
  3. while actionable_pending > 0, run uv run scripts/fetch_pr_feedback.py
  4. fix new high/medium feedback immediately
  5. if changed, verify, commit, push, restart loop
  6. otherwise sleep 30 seconds and repeat
  7. after checks pass, wait 10 seconds, fetch feedback once more
  8. 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,reviewDecision
  • gh pr checks --json name,state,bucket,description,link
  • gh run view <run-id> --log-failed
  • gh 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.

More from the pack Sentry skills

AGENTS.md and CLAUDE.md writer

Writes or trims a repository's AGENTS.md to under 60 lines of commands, conventions and pointers to existing docs, checks every path, and makes CLAUDE.md a symlink to it. Use when a repo needs agent instructions or its current file has grown long or stale.

Claude Code settings audit

Detects a repository's stack and proposes a Claude Code settings.json allow list of read-only commands for the tools it actually uses, plus docs domains and Sentry or Linear MCP entries. Use when setting up Claude Code permissions or auditing existing ones.

Code review, Sentry practices

Reviews a change by Sentry's guidelines: runtime errors, performance and N+1 queries, side effects, compatibility, security, design and tests, with a polite tone and approval once only minor issues remain. Use when reviewing a pull request or branch.

Code simplifier

Simplifies recently changed code without changing behaviour: less nesting, no nested ternaries, clearer names, no redundant abstractions, while following CLAUDE.md conventions. Use when code works but reads heavier than it should and needs a cleanup pass.

Conventional commit messages

Commits in Sentry's Conventional Commits style: a feature branch instead of main, a typed capitalised subject up to 70 characters, Fixes or Refs footers, no personal data. Use when asked to commit changes or draft a commit message.

Django access control review

Audits Django and DRF code for IDOR and broken access control by learning the app's authorization model and tracing each endpoint from ID to query, reporting only confirmed gaps with enforcing fixes. Use when reviewing views, viewsets or tenant isolation.

Find bugs in branch changes

Reviews the commits on the current branch for security holes, bugs and quality issues with an eleven-item checklist and reports verified findings with file, line, severity and fix, without editing code. Use when you want a security-first pass before a PR.

GitHub Actions security review

Audits GitHub Actions workflows for attacks an outsider without write access can run: pwn requests, expression injection, comment commands, token theft, poisoned agent configs, unpinned actions. Use when reviewing CI security or changing workflows.

PR title and description writer

Writes or refreshes a PR title in Sentry's conventional format and a short reviewer-facing description without template headings or test logs, then opens a draft or updates the PR. Use when opening a PR or after commits change its scope.

Prompt optimizer

Writes, repairs or ports system and agent prompts against a small eval set, comparing candidate rewrites on the same cases and checking the winner on held-out ones. Use when a prompt is unreliable, moves to another model family or needs evals.

Secret leaks through serialization

Finds secrets that leak when a credential field on a dataclass, pydantic model or JS object meets code that logs or traces whole objects, searching the whole repository for the other half. Use when a change adds such a field or a wholesale sink.

SECURITY_MODEL.md for review tools

Writes and maintains SECURITY_MODEL.md, telling security review tools a repository's exposure, invariants, reportable finding classes and owner-confirmed exclusions, with a script that flags stale references. Use when preparing a repo for automated review.

Agent skill security scanner

Audits an agent skill before installation: a static scan for prompt injection, hidden Unicode, secrets, risky scripts and structural traps, then a review of intent and permissions ending in a verdict. Use when a skill comes from an outside source.

Skill writer by the Agent Skills spec

Creates and improves agent skills by Sentry's workflow: sources with provenance, the simplest execution shape, SPEC.md and SOURCES.md, precision passes after each change and a structural validator. Use when building a skill that a team will maintain.

Security review, Sentry

Reviews a file, diff or component for exploitable vulnerabilities with OWASP-based references, researches the codebase before flagging and reports only findings reached by attacker-controlled input. Use when a change needs a low-noise security review.

Django performance review

Reviews Django and DRF code for N+1 queries, unbounded querysets, missing indexes and write loops, validating table size and hot paths before reporting. Use when a Django view or endpoint is slow or a change touches large tables.