Monitor PR CI Checks and Code Reviews

VerifiedCaution

Automatically monitors a submitted PR until CI checks pass and code review comments are addressed. Fixes failures via ralph-loop and iterates until all checks are green.

Sby Skills Guide Bot
DevOpsIntermediate
3/9/2026
Claude Code
#pull-request#ci-monitoring#code-review#github#automation

Recommended for

Automated summary

Monitors a pull request after submission: polls CI status, fixes failures through ralph-loop or a manual fallback, then waits for and addresses the Greptile code review until everything is green.

Strengths

  • Bounded loop with explicit counters (5 CI fix cycles, 3 review cycles) that prevents runaway iteration.
  • Clear handling of the CI wait script's exit codes: pass, fail, timeout and error each get a distinct path.
  • Built-in fallback when ralph-loop is unavailable, including local lint and test verification before pushing.
  • Separates top-level Greptile reviews from line-level comments so neither is missed.

Limitations

  • Tightly coupled to the repo: it relies on .claude/hooks/ci-wait.sh, lint.sh, test.sh and the Greptile bot, so it is not portable as-is.
  • Contains imperative 'EXECUTE THESE STEPS NOW' directives and pushes commits automatically — needs guardrails on a shared repository.
  • The Greptile comment-handling logic is truncated in the supplied file, leaving the end of the workflow underspecified.
When to use it

Use it right after opening a PR on a GitHub repo wired up with Greptile and the .claude hooks, to let the agent re-run CI and handle review unattended.

When not to use it

Avoid it on repos without Greptile or the hook scripts, or when automated pushes require human sign-off first.

Security analysis

Caution
Quality score80/100

No destructive or exfiltrating commands (no curl|sh, rm -rf, or credential posting); actions are legitimate gh/git/gh-api operations for PR monitoring. However it does grant autonomous commit-and-push, executes unreviewed repo scripts, delegates to another autonomous skill, and processes untrusted CI/review text that can drive further edits — hence caution rather than safe.

Findings
  • •Executes repo-local helper scripts by path (`bash .claude/hooks/ci-wait.sh`, `lint.sh`, `test.sh`) whose contents are not part of this skill; behavior depends entirely on untrusted repo contents.
  • •Step 2 auto-stages, commits, and pushes CI fixes to the remote branch with no human approval, while Step 4 requires approval for review fixes — inconsistent guardrails around remote mutations.
  • •Ingests untrusted external text (CI failure logs, Greptile review bodies and line comments) and feeds it directly into code edits and pushes — a prompt-injection surface that could steer the agent into unrelated changes.
  • •Delegates to the `ralph-loop` skill (Skill tool), an unreviewed third-party capability that performs autonomous code fixing.
  • •Long-running polling design (30 min CI wait, up to 90 polls / 3 hours) consumes agent and API resources for extended periods.
  • •Uses `AskUserQuestion` which is not in the declared allowed-tools list — functional inconsistency that could cause silent no-approval fallback.
  • •Imperative 'EXECUTE THESE STEPS NOW / do not just describe' framing pushes immediate autonomous execution with git push rights.
  • •Auto-commits and pushes CI fixes to the PR branch without human approval (Step 2c); the explicit user-approval checkpoint at Step 4d applies only to review-comment fixes, so code can land on a shared branch unattended.
  • •Delegates remediation to another skill ("ralph-loop") via the Skill tool, expanding autonomous scope beyond this file's own contents and unverifiable here.
  • •Executes repo-local helper scripts with bash (.claude/hooks/ci-wait.sh, .claude/hooks/lint.sh, .claude/hooks/test.sh) whose contents are not shipped with the skill; trust depends entirely on the working tree, which may include code from the PR under review.
  • •Posts review replies and comments to GitHub via `gh api` under the user's identity, which can misattribute automated responses to a human.
  • •Long-lived autonomous polling loops (up to 90 polls / 3 hours plus repeated CI waits) keep the agent acting with minimal oversight.
  • •The 'EXECUTE THESE STEPS NOW / do not just describe' preamble is pushy instruction framing, though it is legitimate for a workflow skill rather than an attempt to subvert the auditor.
  • •No secret exfiltration, no curl|sh, no destructive filesystem commands, and explicit iteration caps (5 CI fixes, 3 review fixes) are present.
How this analysis is made

Examples

Watch current branch PR
/watch-pr
Watch a specific PR until green
Watch PR #482: keep re-running CI and fixing failures until checks pass, then handle Greptile's review comments.
Recover from a failed CI run
The lint and test jobs failed on my PR #517 — run /watch-pr to pull the failing logs, fix the code, push, and keep iterating until CI is green.

name: watch-pr description: Monitor a PR's CI checks and Greptile code review after submission. Polls CI status, auto-fixes failures via ralph-loop, waits for Greptile review, addresses comments, and iterates until green. allowed-tools: Read, Grep, Glob, Bash, Edit, Write, Skill

/watch-pr

Monitor a submitted PR until CI passes and code reviews are addressed.

EXECUTE THESE STEPS NOW

When this skill is invoked, you MUST execute these steps immediately. Do NOT just describe what will happen — actually do it.

Step 0: Resolve PR Number and Repo

Extract the PR number from $ARGUMENTS. If no argument was provided, detect from the current branch:

gh pr view --json number -q '.number'

If no PR is found, stop with: "No PR found for current branch. Create one with gh pr create or pass a PR number: /watch-pr 123"

Also resolve the repo identifier:

gh repo view --json nameWithOwner -q '.nameWithOwner'

Store as PR_NUMBER and REPO. Initialize counters:

  • CI_FIX_COUNT = 0 (max 5)
  • REVIEW_FIX_COUNT = 0 (max 3)

Report to the user:

## Watching PR #<PR_NUMBER>
Monitoring CI and reviews for https://github.com/<REPO>/pull/<PR_NUMBER>

Step 1: WAITING_CI — Poll CI Checks

Run the CI polling script with a 30-minute timeout:

bash .claude/hooks/ci-wait.sh <PR_NUMBER> 1800

Important: Set the Bash tool timeout to 600000ms (10 minutes). If the script exceeds this, re-invoke it with the remaining timeout: bash .claude/hooks/ci-wait.sh <PR_NUMBER> <REMAINING_SECONDS>.

Evaluate the exit code:

  • Exit 0 (all checks passed): Go to Step 3 (WAITING_REVIEW).
  • Exit 1 (checks failed): Go to Step 2 (CI_FAILED).
  • Exit 2 (timeout): Report to user: "CI checks did not complete within 30 minutes. Check manually." Stop.
  • Exit 3 (error): Report error and stop.

Step 2: CI_FAILED — Fix and Retry

Increment CI_FIX_COUNT. If CI_FIX_COUNT > 5, stop with:

CI has failed 5 times. Manual intervention required.
PR: https://github.com/<REPO>/pull/<PR_NUMBER>

2a. Identify failed checks and get logs:

# Get the head SHA for this PR
HEAD_SHA=$(gh pr view <PR_NUMBER> --json headRefOid -q '.headRefOid')

# List failed workflow runs for this commit
gh run list --commit "$HEAD_SHA" --json databaseId,name,conclusion --jq '.[] | select(.conclusion == "failure")'

For each failed run, fetch the failure logs:

gh run view <RUN_ID> --log-failed 2>&1 | tail -200

2b. Try ralph-loop first:

Invoke the ralph-loop plugin to fix the failures:

Skill tool: skill: "ralph-loop"

If ralph-loop successfully fixes the issues (tests pass locally), commit and push the changes, then go to Step 1.

2c. Fallback to inline fix (if ralph-loop unavailable or fails):

  1. Read the failure logs from step 2a
  2. Identify the root cause (test failure, lint error, build error, etc.)
  3. Read the relevant source files
  4. Fix the code
  5. Verify locally:
    bash .claude/hooks/lint.sh && bash .claude/hooks/test.sh
    
  6. Stage, commit, and push:
    git add <specific-files>
    git commit -m "fix: address CI failure (<brief description>)"
    git push
    

2d. Return to Step 1 (WAITING_CI).

After pushing the fix, CI will re-run. Go back to Step 1.


Step 3: WAITING_REVIEW — Poll for Greptile Review

All CI checks have passed. Now wait for Greptile's code review.

Poll every 120 seconds for up to 3 hours (max 90 polls). On each poll:

# Check for reviews from greptile-apps[bot]
REVIEW_COUNT=$(gh api repos/<REPO>/pulls/<PR_NUMBER>/reviews \
  --jq '[.[] | select(.user.login == "greptile-apps[bot]")] | length')
# Check for line-level comments from greptile-apps[bot]
COMMENT_COUNT=$(gh api repos/<REPO>/pulls/<PR_NUMBER>/comments \
  --jq '[.[] | select(.user.login == "greptile-apps[bot]")] | length')

Decision logic:

  • If both counts are 0: print "Waiting for Greptile review... (poll N/90)", sleep 120 seconds, and poll again.
  • If 3-hour timeout reached with no review: go to Step 5 (DONE) with note "Greptile review did not arrive within 3 hours."
  • If review exists, check if actionable:
    • Actionable (go to Step 4): The latest review state is CHANGES_REQUESTED, OR there are line-level comments from greptile-apps[bot].
    • Not actionable (go to Step 5): Review state is APPROVED or COMMENTED with no line-level comments.

To check review state:

gh api repos/<REPO>/pulls/<PR_NUMBER>/reviews \
  --jq '[.[] | select(.user.login == "greptile-apps[bot]")] | last | .state'

Step 4: REVIEW_RECEIVED — Address Greptile Comments

Increment REVIEW_FIX_COUNT. If REVIEW_FIX_COUNT > 3, stop with:

Greptile has requested changes 3 times. Manual intervention required.
PR: https://github.com/<REPO>/pull/<PR_NUMBER>

4a. Fetch the review body:

gh api repos/<REPO>/pulls/<PR_NUMBER>/reviews \
  --jq '[.[] | select(.user.login == "greptile-apps[bot]")] | last | .body'

4b. Fetch all line-level comments:

gh api repos/<REPO>/pulls/<PR_NUMBER>/comments \
  --jq '[.[] | select(.user.login == "greptile-apps[bot]")] | .[] | {id: .id, path: .path, line: .line, body: .body}'

4c. Address each comment:

For each line-level comment:

  1. Read the file at the specified path and line
  2. Understand the suggestion
  3. If it aligns with project principles: apply the fix
  4. If it conflicts with .claude/docs/PRINCIPLES.md or .claude/docs/INVARIANTS.md: do NOT apply it. Reply explaining why:
    gh api repos/<REPO>/pulls/<PR_NUMBER>/comments/<COMMENT_ID>/replies \
      -f body="Not applied: <reason based on project principles>"
    
  5. For applied fixes, reply to acknowledge:
    gh api repos/<REPO>/pulls/<PR_NUMBER>/comments/<COMMENT_ID>/replies \
      -f body="Fixed in latest push."
    

4d. Human approval checkpoint:

Before committing review fixes, present a summary to the user for approval:

## Greptile Review Changes Summary

| # | Comment | Action | File |
|---|---------|--------|------|
| 1 | <brief description> | Applied / Declined | <path> |
| 2 | ... | ... | ... |

Approve these changes before pushing? (y/n)

Use the AskUserQuestion tool to get explicit approval. If the user declines, stop and let them handle the review manually.

4e. Verify, commit, and push:

After user approval:

bash .claude/hooks/lint.sh && bash .claude/hooks/test.sh

If local checks pass:

git add <specific-files>
git commit -m "fix: address Greptile review comments"
git push

4f. Return to Step 1 (WAITING_CI).

CI will re-run after the push. Go back to Step 1.


Step 5: DONE — Final Report

## Watch PR Complete

### PR
https://github.com/<REPO>/pull/<PR_NUMBER>

### CI Status: PASSED
- CI fix iterations: <CI_FIX_COUNT>

### Greptile Review
| Status | Details |
|--------|---------|
| Received | YES / NO (timed out) |
| Actionable comments | N |
| Comments addressed | N |
| Comments declined | N (with reasons) |
| Review fix iterations | <REVIEW_FIX_COUNT> |

### Final Status: READY FOR HUMAN REVIEW / NEEDS ATTENTION

If final status is READY (CI green, reviews addressed), report:

PR is ready for human review.

If final status is NEEDS ATTENTION (hit iteration limits), explain what remains.


Safeguards

| Limit | Value | Behavior when exceeded | |-------|-------|----------------------| | CI fix iterations | 5 | Stop, report failures, ask user | | Greptile wait timeout | 3 hours | Continue without review | | Review fix iterations | 3 | Stop, report outstanding comments |

When to Use

  • After /pre-submit-pr creates and pushes a PR
  • After pushing fixes to an existing PR
  • When you want automated CI monitoring and review handling

When NOT to Use

  • Before a PR exists (run /pre-submit-pr first)
  • For draft PRs that aren't ready for review
  • When you want manual control over CI fixes

Workflow Integration

/work-on-issue #42  →  Start from GitHub issue
    ↓
/write-tests        →  Create failing tests (Red)
    ↓
/implement          →  Make tests pass (Green)
    ↓
/update-docs        →  Fix stale docs across repo
    ↓
/simplify           →  Refactor (optional)
    ↓
/pre-submit-pr      →  Validate before PR
    ↓
/watch-pr           →  Monitor CI + Greptile review  ← THIS SKILL

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/monitor-pr-ci-checks-and-code-reviews-mmio7119/download' --output '.skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119/SKILL.md.part' && mv '.skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119/SKILL.md.part' '.skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Grep, Glob, Bash, Edit, Write, Skill

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119/SKILL.md' && test -s '.skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/watch-pr' && cp -R '.skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119' '.claude/skills/watch-pr'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119'

openskills read 'monitor-pr-ci-checks-and-code-reviews-mmio7119'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills