iterate-pr
/iterate-pr
Fix CI failures and address review feedback on the current branch's PR. Use when CI is failing, review comments need addressing, or you need to push fixes for an open PR. Supports --dry-run to preview without changes.
- Author
- dimagi ↗
- Repository
- dimagi-claude-workflows ↗
- Licence
- MIT
- Last repository change
- 06.10.2026
Assessment and security
- Files in this package
- 4
- Scripts
- 3
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 06.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- 3 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/fetch_pr_checks.py, scripts/fetch_pr_feedback.py, scripts/reply_to_thread.py
What it does and when to use it
Fix CI failures and address review feedback on the current branch's PR. Use when CI is failing, review comments need addressing, or you need to push fixes for an open PR. Supports --dry-run to preview without changes.
Original author description
Fix CI failures and address review feedback on the current branch's PR. Use when CI is failing, review comments need addressing, or you need to push fixes for an open PR. Supports --dry-run to preview without changes.
How it works
- Bundled Scripts
- Workflow
- Fallback
SKILL.md preview
---
name: iterate-pr
description: Fix CI failures and address review feedback on the current branch's PR. Use when CI is failing, review comments need addressing, or you need to push fixes for an open PR. Supports --dry-run to preview without changes.
---
# Iterate on PR
One-shot workflow: gather review feedback, fix CI failures, verify locally, commit, push, and reply to all threads.
**Requires**: GitHub CLI (`gh`) authenticated.
**Important**: All scripts must be run from the repository root directory (where `.git` is located), not from the skill directory. Use the full path to the script via `${CLAUDE_SKILL_DIR}`.
If `--dry-run` is in $ARGUMENTS, print the plan but make no changes (no commits, no pushes, no replies).
## Bundled Scripts
### `scripts/fetch_pr_checks.py`
Fetches CI check status and extracts failure snippets from logs.
```bash
uv run ${CLAUDE_SKILL_DIR}/scripts/fetch_pr_checks.py [--pr NUMBER]
```
Returns JSON:
```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.py`
Fetches and categorizes PR review feedback using the LOGAF scale.
```bash
uv run ${CLAUDE_SKILL_DIR}/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 threads
Review bot feedback (from Copilot, Claude, CodeQL, etc.) appears in `high`/`medium`/`low` with `review_bot: true` — it is NOT placed in the `bot` bucket.
Each feedback item may include:
- `thread_id` - GraphQL node ID for inline review comments (used for replies)
### `scripts/reply_to_thread.py`
Replies to PR review threads. Batches multiple replies into a single GraphQL call.
```bash
uv run ${CLAUDE_SKILL_DIR}/scripts/reply_to_thread.py THREAD_ID "body" [THREAD_ID "body" ...]
```
## Workflow
### 1. Identify PR
```bash
gh pr view --json number,url,headRefName
gh repo view --json owner,name -q '"\\(.owner.login)/\\(.name)"'
```
Store PR number and `{owner}/{repo}` for use in later steps. Stop if no PR exists for the current branch.
### 2. Gather and Address Review Feedback
Run `uv run ${CLAUDE_SKILL_DIR}/scripts/fetch_pr_feedback.py` to get categorized feedback.
**Auto-fix (no prompt):**
- `high` - must address (blockers, security, changes requested)
- `medium` - should address (standard feedback)
When fixing feedback:
- Understand the root cause, not just the surface symptom
- Check for similar issues in nearby code or related files
- Fix all instances, not just the one mentioned
This includes review bot feedback (items with `review_bot: true`). Treat it the same as human feedback:
- Real issue found → fix it
- False positive → skip, but note why (will be included in reply)
- Never silently ignore review bot feedback — always verify the finding
**Prompt user for selection (using `AskUserQuestion` tool):**
- `low` - use the `AskUserQuestion` tool to present options. Build the question text with a numbered list of all low-priority items, then offer these options:
- "All" — address every low-priority item
- "None" — decline all
- "Pick…" — let the user specify which numbers in the "Other" text field (e.g., "1,3")
Example question text:
```
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?
```
**Skip silently:**
- `resolved` threads
- `bot` comments (informational only)
Track every thread's disposition (fixed, declined, false-positive, skipped) for the reply step.
If `--dry-run`: print the classification table (including the low-priority numbered list for preview, but do NOT prompt the user for selection). Skip to the Summary step.
### 3. Check CI and Fix Failures
Run `uv run ${CLAUDE_SKILL_DIR}/scripts/fetch_pr_checks.py` to get structured failure data.
For each failure:
1. Read the `log_snippet` and trace backwards from the error to understand WHY it failed
2. **Run the failing test(s) locally first.** Derive test names from the failure output. If they pass locally, do NOT attempt to fix the code — the failure is likely environmental. Investigate: cache not cleared between tests, `transaction.on_commit()` callbacks in rolled-back test transactions, test ordering dependencies, or shared mutable state. Report findings to the user.
3. If tests fail locally too, read the relevant code and check for related issues
4. Fix the root cause with minimal, targeted changes
Do NOT assume what failed based on check name alone — always read the logs.
### 4. Verify Locally
Before committing, verify fixes locally:
- If you fixed a test failure: re-run that specific test
- If you fixed a lint/type error: re-run the linter or type checker on affected files
- For any code fix: run existing tests covering the changed code
Detect the test runner from manifest files (`pyproject.toml`/`setup.py` → Python, `package.json` → Node/TS). Check `.github/workflows/` for CI commands first.
If local verification fails, fix before proceeding — do not push known-broken code.
### 5. Commit and Push
Commit the fixes as a series of logical commits, not one catch-all "address feedback and CI" commit. Group by concern: a CI fix is its own commit, and each distinct piece of review feedback (or each cluster of closely-related comments) is its own commit. This keeps each commit reviewable on its own, and it lets you cite the *exact* SHA that resolved a given thread when you reply in step 6 — a reviewer can click straight to the fix.
Stage deliberately so unrelated fixes stay apart — `git add <files for this concern>`, or `git add -p` when one file holds fixes for different threads — rather than `git add -A`.
```bash
git add <files for this concern>
git commit -m "fix: <what this specific concern was>"
# repeat for each logical group, then:
git push
```
Keep messages minimal — a concise subject, a body only when the *why* isn't obvious. If every fix genuinely belongs to one concern, a single commit is fine.
Record which commit SHA addresses which thread/CI failure — the replies in step 6 reference these per-thread.
### 6. Reply to All Threads
**Inline review threads** (items with `thread_id`): reply using the batch script.
**Issue-level comments** (items without `thread_id`): reply via REST API:
```bash
gh api -X POST repos/{owner}/{repo}/issues/{pr_number}/comments -f body="$REPLY_BODY"
```
Use `${CLAUDE_SKILL_DIR}/scripts/reply_to_thread.py` for inline threads. Batch all replies into a single call:
```bash
uv run ${CLAUDE_SKILL_DIR}/scripts/reply_to_thread.py \
PRRT_abc $'Fixed — description of change.\n\n*— Claude Code*' \
PRRT_def $'Not applicable — reason.\n\n*— Claude Code*'
```
**Reply format by disposition:**
- **Fixed**: `"Fixed in <SHA>. <description of change>.\n\n*— Claude Code*"`
- **Declined (low)**: `"Noted — declined by author. <brief reason if given>.\n\n*— Claude Code*"`
- **False positive**: `"Not applicable — <reason>.\n\n*— Claude Code*"`
**Guards:**
- Before replying, check if the thread already has a reply ending with `*— Claude Code*` to avoid duplicates
- End every reply with `\n\n*— Claude Code*`
- If the script fails, log and continue — do not block the workflow
### 7. Summary
Print a final table:
| # | File | Comment (truncated) | Action | Commit / Note |
|---|------|---------------------|--------|---------------|
| 1 | src/foo.py:42 | "Use `Optional` instead..." | Fixed | abc1234 |
| 2 | README.md | "Typo in heading" | Fixed | abc1234 |
| 3 | src/bar.py:10 | "Consider splitting..." | Declined | Low priority, user chose "none" |
| 4 | CI: tests | pytest failure in test_api | Fixed | abc1234 |
## Fallback
If scripts fail, use `gh` CLI directly:
- `gh pr checks --json name,state,bucket,link`
- `gh run view <run-id> --log-failed`
- `gh api repos/{owner}/{repo}/pulls/{number}/comments`
Files in this package (4)
- SKILL.md 8 KB
- scripts/fetch_pr_checks.py 7 KB
- scripts/fetch_pr_feedback.py 14 KB
- scripts/reply_to_thread.py 5 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · dimagi/dimagi-claude-workflows | 100 | MIT |
| FrancoStino/opencode-skills-collection | 100 | MIT |
| rootcastleco/rei-skills | 100 | MIT |
| davila7/claude-code-templates | 100 | MIT |
| sickn33/agentic-awesome-skills | 100 | MIT |
| getsentry/skills | 100 | Apache-2.0 |
| LiHongwei-cn/lihongwei-cn | 100 | MIT |
| agent-skills-hub/agent-skills-hub | 100 | MIT |
| reviewstage/stage-cli | 100 | MIT |
Database snapshot: 13.11.2026 · package version 7fa848c575f6 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Similar skills
- 100fix-pr
Fixes CI failures and review comments on the current branch's pull request by dispatching a fixer subagent, verifying with the validator, and pushing the fix. Use when the user says "fix pr", "fix CI failures", "address review comments", or invokes "codagent:fix-pr". - 90addressing-pr-review
Fix or answer every unresolved finding on the current branch's PR, then push the fixes. Use when the current branch's PR has unresolved review threads, or the user asks to address its review. - 100pr-fix
Fix the review feedback on a GitHub pull request. Collects every open review thread, review-body item, PR comment and failing check, verifies each one, applies the fixes in an isolated worktree following the repository's own skills and conventions, runs its checks, and after… - 90push-my-prs
Use this workflow skill to iterate through multiple open PRs authored by the current user, address feedback and CI issues, and push follow-up fixes across the set. - 90pr-feedback
Works through review comments and failing CI on an open pull request, triaging each comment, fixing with tests, replying on every thread, and looping until CI is green. Use when asked to address review comments, fix CI, or handle PR feedback. - 100pr-respond
Use when reviewing PR comments, responding to code review feedback, or addressing reviewer suggestions on the current branch or the PRs stacked with it. Triggered by "respond to PR comments", "address review feedback", or /pr-respond.