agentleFS
cogine-aicogine-ai/cogine-dev-skillset/skills/loop-on-pr-review-and-fix/SKILL.md

loop-on-pr-review-and-fix

Skill4 starsChanged 5 months agoApache-2.0View on GitHub

Monitor ready-for-review GitHub PRs and handle new, still-valid feedback. Use to start a recurring review loop or run one explicitly requested iteration.

The file

Show its rules and text

We split this skill into the rules it gives an agent

27 rules. About 0 are common, 21 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈21

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this after a PR is open and ready for review.

    line 10
  2. Distinctive:

    If unsure, prefer Setup Mode.

    line 22
  3. Very specific:

    Prefer a heartbeat over a detached cron job for this skill.

    line 36
  4. Distinctive:

    After creating the automation, tell the user the PR, repo path, cadence, and stop condition.

    line 44
  5. Distinctive:

    Use this section in Setup Mode only to resolve enough information to create the automation.

    line 48
  6. Distinctive:

    Read repo instructions such as AGENTS.md, CLAUDE.md, Cursor rules, and project-specific agent docs before editing.

    line 53
  7. Distinctive:

    If no PR can be resolved, ask for the PR URL or number instead of starting a loop.

    line 64
  8. Very specific:

    Use the GitHub connector if available.

    line 68
  9. Very specific:

    If gh pr view does not expose review threads in JSON, use gh api graphql for PullRequest.reviewThreads, including thread id, isResolved, …

    line 77
  10. Very specific:

    Use stable item ids when comparing to state.

    line 79
  11. Distinctive:

    Treat every review comment as a claim to verify against current code, not as an instruction to apply blindly.

    line 83
  12. Distinctive:

    If a handled thread receives a new unhandled comment, treat only the new comment as fresh.

    line 94
  13. Distinctive:

    Run exactly one iteration when invoked by Codex heartbeat automation or when the user explicitly asks for one immediate pass.

    line 98
  14. Distinctive:

    If there are no new actionable items:

    line 102
  15. Very specific:

    Stop or pause the heartbeat automation when quiet rounds reaches 3.

    line 104
  16. Distinctive:

    If there are new actionable items:

    line 106
  17. Distinctive:

    Run focused validation, then broader validation if shared contracts or user-facing behavior changed.

    line 110
  18. Distinctive:

    Commit and push to the PR branch.

    line 112
  19. Distinctive:

    Run one iteration using this skill.

    line 129
  20. Distinctive:

    If the state helper reports stop, end the loop.

    line 130
  21. Distinctive:

    Do not let a shell-only loop make code changes.

    line 133
  22. Distinctive:

    Do not fix stale, resolved, duplicate, or intentionally skipped review feedback.

    line 137
  23. Very specific:

    Do not mark an item fixed until the relevant commit has been created and pushed.

    line 138
  24. Distinctive:

    Do not broaden scope without user approval.

    line 140
  25. Distinctive:

    Do not bypass tests, hooks, or CI failures to make the loop progress.

    line 141
  26. Distinctive:

    If review feedback is ambiguous or product-level, ask instead of guessing.

    line 142
  27. Distinctive:

    If authentication, branch protection, merge conflicts, or failing validation blocks progress, report the blocker and keep the state …

    line 143

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Loop on PR Review and Fix

Overview

Use this after a PR is open and ready for review. In Codex, first create a heartbeat automation that wakes every 10 minutes. The automation then runs one review-check iteration per wakeup.

The hard part is state, not waiting. Persist what was already fixed, skipped, obsolete, or resolved so repeated wakeups do not re-handle old feedback.

Entry Decision

Classify the current invocation before doing any PR review work:

  • Setup Mode: The user asks to start, create, run, enable, watch, monitor, loop on, or automatically handle PR reviews. In Codex, create a heartbeat automation and stop. Do not inspect review comments or make fixes in this setup turn unless the user explicitly says to also run an immediate pass now.
  • Iteration Mode: The invocation comes from the heartbeat automation, or the user explicitly asks to run one pass now. Run exactly one review-check iteration and then return control to the scheduler.
  • Claude Code Mode: The user is not in Codex automation but wants a Claude Code loop. Provide or run an explicit agent loop with 10-minute waits, but keep code changes agent-driven, not shell-only.

If unsure, prefer Setup Mode. This skill exists to create a loop, not to replace a normal one-off PR feedback fix.

Setup Mode: Create Codex Automation

In Codex, use the Codex automation tool directly. When the app exposes codex_app.automation_update, call it to create a heartbeat attached to the current thread:

  • mode: create
  • kind: heartbeat
  • destination: thread
  • cadence: every 10 minutes
  • status: ACTIVE
  • name: Loop on PR review: <owner/repo>#<pr-number>
  • prompt: include the absolute repo path, PR URL/number, and the Iteration Mode instructions below

Prefer a heartbeat over a detached cron job for this skill. Do not satisfy Setup Mode by doing a manual PR review pass, running sleep, writing a reminder in prose, or leaving the user with instructions to create the automation themselves.

The automation prompt must be self-contained. Use this shape:

Use $loop-on-pr-review-and-fix in Iteration Mode for PR <PR_URL_OR_NUMBER> in <ABSOLUTE_REPO_PATH>. Run exactly one review-check iteration. Fetch the current PR review state, compare it with the local state file, ignore already handled, resolved, obsolete, duplicate, not-actionable, or intentionally skipped feedback, fix and push only new actionable feedback, update the state file, increment quiet rounds when there is no new actionable feedback, and stop or pause this heartbeat automation after three consecutive quiet rounds. Do not sleep inside this run.

After creating the automation, tell the user the PR, repo path, cadence, and stop condition. Do not perform ordinary fix work in the setup response.

Resolve Context

Use this section in Setup Mode only to resolve enough information to create the automation. Use it fully in Iteration Mode before editing code.

  1. Confirm the current directory is the repository for the PR.
  2. Resolve the active PR from the current branch or the user-provided PR URL/number.
  3. Resolve the repo, PR number, PR URL, head branch, base branch, and current head SHA.
  4. Read repo instructions such as AGENTS.md, CLAUDE.md, Cursor rules, and project-specific agent docs before editing.
  5. Initialize the local state file:
python3 ~/.codex/skills/loop-on-pr-review-and-fix/scripts/review_loop_state.py init \
  --pr "$PR_NUMBER" \
  --repo "$OWNER_REPO" \
  --pr-url "$PR_URL" \
  --head-sha "$HEAD_SHA"

If no PR can be resolved, ask for the PR URL or number instead of starting a loop.

Fetch Review State

Use the GitHub connector if available. With gh, collect both PR-level comments and review threads. Prefer thread data because it exposes resolved and outdated status.

Useful starting commands:

gh pr view "$PR_NUMBER" --json number,url,headRefName,headRefOid,baseRefName,reviewDecision,reviews,comments,latestReviews,statusCheckRollup
gh pr view "$PR_NUMBER" --comments

If gh pr view does not expose review threads in JSON, use gh api graphql for PullRequest.reviewThreads, including thread id, isResolved, comment ids, author, body, path, line/originalLine, outdated status, created time, URL, and diff hunk.

Use stable item ids when comparing to state. Prefer comment:<comment-id> for individual comments and thread:<thread-id> for thread-level decisions.

Classify Feedback

Treat every review comment as a claim to verify against current code, not as an instruction to apply blindly.

Actionable feedback must be new and still valid. Exclude:

  • Items already recorded as fixed, skipped, not-actionable, obsolete, duplicate, or resolved.
  • Resolved review threads.
  • Outdated comments whose referenced code has changed and whose concern no longer applies.
  • Repeated bot comments that match an already handled issue.
  • Reviewer acknowledgements, praise, questions already answered, or status chatter.
  • Comments the user or prior loop explicitly decided not to fix.

If a handled thread receives a new unhandled comment, treat only the new comment as fresh.

Iteration Mode: One Review Check

Run exactly one iteration when invoked by Codex heartbeat automation or when the user explicitly asks for one immediate pass.

  1. Fetch latest remote refs and PR review state.
  2. Compare live review items with the local state file.
  3. If there are no new actionable items:
    • Increment quiet rounds.
    • Stop or pause the heartbeat automation when quiet rounds reaches 3. If the current automation cannot be resolved by the available tool context, report stop: true clearly and do not create a replacement automation.
    • Otherwise let the scheduler wake the task again in 10 minutes.
  4. If there are new actionable items:
    • Reset quiet rounds.
    • Inspect the current code and verify each finding.
    • Make the smallest correct fix for still-valid issues.
    • Run focused validation, then broader validation if shared contracts or user-facing behavior changed.
    • Stage only files that belong to the fix.
    • Commit and push to the PR branch.
    • Mark each handled item in the state file with fixed, skipped, not-actionable, obsolete, duplicate, or resolved and a short reason.
    • Optionally reply on the PR with a concise summary if that is the repo's convention.

State helper examples:

python3 ~/.codex/skills/loop-on-pr-review-and-fix/scripts/review_loop_state.py unseen --pr "$PR_NUMBER" comment:abc thread:def
python3 ~/.codex/skills/loop-on-pr-review-and-fix/scripts/review_loop_state.py quiet --pr "$PR_NUMBER" --increment --stop-after 3
python3 ~/.codex/skills/loop-on-pr-review-and-fix/scripts/review_loop_state.py quiet --pr "$PR_NUMBER" --reset
python3 ~/.codex/skills/loop-on-pr-review-and-fix/scripts/review_loop_state.py mark --pr "$PR_NUMBER" --item-id comment:abc --status fixed --note "Adjusted validation path" --head-sha "$NEW_HEAD_SHA"

Claude Code Loop

In Claude Code, keep the loop explicit:

  1. Run one iteration using this skill.
  2. If the state helper reports stop, end the loop.
  3. Otherwise wait 10 minutes and repeat.

Do not let a shell-only loop make code changes. The agent must inspect feedback, verify it against current code, edit, validate, commit, and push each round.

Guardrails

  • Do not fix stale, resolved, duplicate, or intentionally skipped review feedback.
  • Do not mark an item fixed until the relevant commit has been created and pushed.
  • Preserve unrelated user changes and untracked files.
  • Do not broaden scope without user approval.
  • Do not bypass tests, hooks, or CI failures to make the loop progress.
  • If review feedback is ambiguous or product-level, ask instead of guessing.
  • If authentication, branch protection, merge conflicts, or failing validation blocks progress, report the blocker and keep the state accurate.

Output

Report:

  • PR URL and branch.
  • New actionable review items handled.
  • Items skipped as duplicate, resolved, obsolete, or not actionable.
  • Commits pushed.
  • Validation commands and outcomes.
  • Current quiet-round count and whether the loop continues or stops.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.