一键导入
iterate-pr
Iterate on a PR until CI passes. Optionally merge or merge and publish a release of the repo. Automates the feedback-fix-push-wait cycle.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Iterate on a PR until CI passes. Optionally merge or merge and publish a release of the repo. Automates the feedback-fix-push-wait cycle.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | iterate-pr |
| description | Iterate on a PR until CI passes. Optionally merge or merge and publish a release of the repo. Automates the feedback-fix-push-wait cycle. |
| argument-hint | [--full] [--release] |
| metadata | {"author":"leecalcote","version":"2.3.0"} |
Continuously iterate on the current branch until all CI checks pass and review feedback is addressed.
Requires: GitHub CLI (gh) authenticated.
Requires: Python 3.9+.
Important: Run scripts from the repository root directory (where .git is located).
Every script below accepts either runner - they only use the standard library, so no dependency installation is needed either way:
uv - uv run <script>. Faster startup, isolated from system Python.python3 <script> - used automatically when uv is not on PATH.Before running any script command shown in this skill, check for uv first and prefer it;
fall back to python3 only if uv is unavailable:
if command -v uv >/dev/null 2>&1; then
uv run .claude/skills/iterate-pr/scripts/<script>.py [args]
else
python3 .claude/skills/iterate-pr/scripts/<script>.py [args]
fi
The rest of this document shows invocations in the shorter python3 <script> form for
readability - substitute uv run per the rule above whenever uv is available.
Invoke as:
/iterate-pr/iterate-pr --full/iterate-pr --release/iterate-pr --full --releaseIn Claude Desktop, arguments are hints, not strict CLI parsing. Treat whatever follows /iterate-pr as a mode hint string.
Use this deterministic precedence:
--release or terms like release, publish, ship → run release mode.--full or terms like full, autonomous, merge → run full mode.Do not fail because hints are missing or unrecognized; default safely.
| Mode | Behavior |
|---|---|
Default (/iterate-pr) | Iterates on CI + high/medium feedback, asks user about low-priority items, then exits without merging. |
--full | Fully autonomous: handles every non-resolved feedback item, replies to every item, re-requests review (Gemini or Copilot) after each push, iterates until no new feedback and CI is green, then administratively merges the PR without waiting for a required-approval status. |
--release | Does everything in --full, then cuts/publishes a release for the repository. |
scripts/fetch_pr_checks.pyFetches CI check status and extracts failure snippets from logs.
python3 .claude/skills/iterate-pr/scripts/fetch_pr_checks.py [--pr NUMBER]
Returns JSON:
{
"pr": {"number": 123, "branch": "feat/foo"},
"summary": {"total": 5, "passed": 3, "failed": 2, "pending": 0},
"checks": [
{"name": "tests", "status": "fail", "log_snippet": "...", "run_id": 123},
{"name": "lint", "status": "pass"}
]
}
scripts/fetch_pr_feedback.pyFetches and categorizes PR review feedback using the LOGAF scale.
python3 .claude/skills/iterate-pr/scripts/fetch_pr_feedback.py [--pr NUMBER]
Returns JSON with feedback categorized as:
high - Must address before merge (h:, blocker, changes requested)medium - Should address (m:, standard feedback)low - Optional (l:, nit, style, suggestion)bot - Informational automated comments (Codecov, Dependabot, etc.)resolved - Already resolved threadsReview bot feedback (from Sentry, Warden, Cursor, Bugbot, CodeQL, etc.) appears in high/medium/low with review_bot: true — it is NOT placed in the bot bucket.
Each feedback item may also include:
thread_id - GraphQL node ID for inline review comments (used for replies via reply_to_thread.py)scripts/reply_to_thread.pyReplies to PR review threads. Batches multiple replies into a single GraphQL call.
python3 .claude/skills/iterate-pr/scripts/reply_to_thread.py THREAD_ID "body" [THREAD_ID "body" ...]
Arguments are alternating (thread_id, body) pairs. The script sends the reply body without adding signatures, attribution, or sign-off text. Example:
python3 .claude/skills/iterate-pr/scripts/reply_to_thread.py \
PRRT_abc "Fixed the null check." \
PRRT_def "Replaced with path-segment counting."
gh pr view --json number,url,headRefName
Stop if no PR exists for the current branch.
Run python3 .claude/skills/iterate-pr/scripts/fetch_pr_feedback.py to get categorized feedback already posted on the PR.
Determine mode from invocation (/iterate-pr, /iterate-pr --full, /iterate-pr --release).
/iterate-pr)Auto-fix (no prompt):
high - must address (blockers, security, changes requested)medium - should address (standard feedback)Prompt user for selection:
low - present numbered list and ask which to address: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 would you like to address? (e.g., "1,3" or "all" or "none")
Skip silently:
resolved threadsbot comments (informational only — Codecov, Dependabot, etc.)/iterate-pr --full, /iterate-pr --full --release)Operate autonomously. Process every non-resolved feedback item returned by fetch_pr_feedback.py (high, medium, low, and bot).
For each item:
When fixing feedback (all modes):
This includes review bot feedback (items with review_bot: true). Treat it the same as human feedback:
After processing feedback, reply to PR comments/threads to acknowledge the action taken.
Scope by mode:
high/medium; reply to low only when fixed or declined by the userHow to reply:
thread_id exists (inline review thread), use python3 .claude/skills/iterate-pr/scripts/reply_to_thread.pythread_id exists, post a PR comment with gh pr comment <PR_NUMBER> --body "..."Batch inline replies for a round into a single call:
python3 .claude/skills/iterate-pr/scripts/reply_to_thread.py \
PRRT_abc "Fixed — description of change." \
PRRT_def "Not applicable — reason."
Reply format:
Run python3 .claude/skills/iterate-pr/scripts/fetch_pr_checks.py to get structured failure data.
Wait if pending: If review bot checks (sentry, warden, cursor, bugbot, seer, codeql) are still running, wait before proceeding—they post actionable feedback that must be evaluated. Informational bots (codecov) are not worth waiting for.
For each failure in the script output:
log_snippet and trace backwards from the error to understand WHY it failed — not just what failedDo NOT assume what failed based on check name alone—always read the logs. Do NOT "quick fix and hope" — understand the failure thoroughly before changing code.
Before committing, verify your fixes locally:
If local verification fails, fix before proceeding — do not push known-broken code.
git add <files>
gh auth status -a
git commit --signoff -m "fix: <descriptive message>"
git push
Always add exactly one sign-off to each commit for the active authenticated GitHub user. Check gh auth status -a before committing to confirm the active account, use git commit --signoff, and do not add any other trailers, signatures, or tool attribution to commits or PR comments.
Poll CI status and review feedback in a loop instead of blocking:
python3 .claude/skills/iterate-pr/scripts/fetch_pr_checks.py to get current CI statuspython3 .claude/skills/iterate-pr/scripts/fetch_pr_feedback.py for new review feedback
b. Address feedback based on mode:
high/mediumhigh/medium/low/bot) and reply to each item
c. If changes were needed, commit and push (this restarts CI)
d. In full modes, after each push, explicitly re-request review:/gemini review) when available@copilot review on the PR
e. Sleep 30 seconds (don't increase on subsequent iterations), then repeat from sub-step 1sleep 10, then run python3 .claude/skills/iterate-pr/scripts/fetch_pr_feedback.py.
high/medium feedback; if changes are needed, return to step 6If step 7 required code changes (from new feedback after CI passed), return to step 2 for a fresh cycle. CI failures during monitoring are already handled within step 7's polling loop.
In full modes, continue looping until both conditions are true:
full: once CI is green and no new feedback remains, merge administratively - do not wait for a required-approval status to clear:gh pr merge <PR_NUMBER> --admin --delete-branch
--admin uses the authenticated account's admin/maintainer permissions to bypass the
required-approving-review branch-protection rule; it does not bypass or skip the CI-green
and feedback-resolved checks this skill already enforces in steps 4-7, and it never fabricates
or requests an approving review from another account. If the command fails (e.g. the
authenticated account lacks admin/maintainer rights on the repo, or a check can't be
bypassed), stop and surface the gh error to the user - do not retry under a different
identity and do not fall back silently.
--release: complete --full mode merge, then cut a release:
gh release list --repo layer5io/meshery-cloud --json tagName,isDraft --jq '.[] | select(.isDraft) | .tagName'
gh release view vX.Y.Z --repo layer5io/meshery-cloud
gh release edit vX.Y.Z --repo layer5io/meshery-cloud --draft=false --latest
Success (default): All checks pass, post-CI feedback re-check is clean (no new unaddressed high/medium feedback including review bot findings), user has decided on low-priority items.
Success (full): All checks pass, no new non-resolved feedback remains after the latest review request, every feedback item has a reply, and the PR is administratively merged (no wait on a required-approval status).
Success (--release): --full success criteria are met and the draft GitHub release has been published.
Ask for help: Same failure after 2 attempts, feedback needs clarification, infrastructure issues, or gh pr merge --admin fails (insufficient permissions or an unbypassable check) - surface the error rather than retrying under a different identity or falling back silently.
Stop: No PR exists, branch needs rebase.
If scripts fail, use gh CLI directly:
gh pr checks --json name,state,bucket,linkgh run view <run-id> --log-failedgh api repos/{owner}/{repo}/pulls/{number}/comments