Surveiller la PR et les vérifications CI

VérifiéPrudence

Surveille automatiquement une PR soumise jusqu'à ce que les vérifications CI réussissent et que les commentaires de révision soient adressés. Corrige les défaillances via ralph-loop et itère jusqu'au succès.

Spar Skills Guide Bot
DevOpsIntermédiaire
09/03/2026
Claude Code
#pull-request#ci-monitoring#code-review#github#automation

Recommandé pour

Synthèse automatique

Surveille une pull request après soumission : interroge l'état de la CI, corrige les échecs via ralph-loop ou une correction manuelle, puis attend et traite la revue de code Greptile jusqu'à ce que tout soit au vert.

Points forts

  • Boucle bornée avec compteurs explicites (5 cycles de correction CI, 3 de revue) qui évite les itérations infinies.
  • Gestion précise des codes de sortie du script d'attente CI : succès, échec, dépassement de délai, erreur.
  • Repli prévu si ralph-loop est indisponible, avec vérification locale (lint + tests) avant le push.
  • Distingue les revues globales des commentaires ligne à ligne de Greptile pour ne rien laisser passer.

Limites

  • Fortement couplé au dépôt : dépend de .claude/hooks/ci-wait.sh, lint.sh, test.sh et du bot Greptile, donc peu réutilisable tel quel.
  • Le fichier contient des directives impératives du type « EXECUTE THESE STEPS NOW » et pousse des commits automatiquement — à encadrer sur un dépôt partagé.
  • La logique de traitement des commentaires Greptile est tronquée dans le fichier fourni, ce qui rend la fin du parcours imprécise.
Quand l'utiliser

À utiliser juste après l'ouverture d'une PR sur un dépôt GitHub équipé de Greptile et des hooks .claude, pour laisser l'agent relancer la CI et traiter la revue sans surveillance.

Quand l'éviter

À éviter sur un dépôt sans Greptile ni scripts de hooks, ou lorsque les pushes automatiques exigent une validation humaine préalable.

Analyse de sécurité

Prudence
Score qualité80/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.

Points d'attention
  • •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.
Comment cette analyse est faite

Exemples

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

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

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. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Outils déclarés par l’auteur (à vérifier dans votre agent) : Read, Grep, Glob, Bash, Edit, Write, Skill

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

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 doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119'

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

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/monitor-pr-ci-checks-and-code-reviews-mmio7119/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires