home / skills / onekeyhq / app-monorepo / 1k-monitor-pr-ci

1k-monitor-pr-ci skill

/.claude/skills/1k-monitor-pr-ci

This skill monitors a PR's CI checks and review comments, auto-fixing failures and prompting you to address reviews until ready to merge.

npx playbooks add skill onekeyhq/app-monorepo --skill 1k-monitor-pr-ci

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
4.3 KB
---
name: 1k-monitor-pr-ci
description: Monitors a PR's CI checks and review comments until all pass and issues are resolved. Use when watching CI status, waiting for checks to pass, or fixing CI errors on a pull request.
disable-model-invocation: true
argument-hint: [PR number or URL]
---

# Monitor PR CI & Reviews

Monitor a pull request's CI checks and review comments. Auto-fix CI failures, prompt user for review feedback.

## Input

`$ARGUMENTS` - PR number, PR URL, or omit to auto-detect from current branch.

## Workflow

### Step 1: Resolve PR number

Determine the PR to monitor:

- If `$ARGUMENTS` is a number, use it directly
- If `$ARGUMENTS` is a GitHub URL, extract the PR number
- If `$ARGUMENTS` is empty, detect from current branch:
  ```bash
  gh pr list --head "$(git branch --show-current)" --json number --jq '.[0].number'
  ```
- If no PR found, stop and inform the user

### Step 2: Poll loop

Each iteration (`[Check N/30]`):

1. **Fetch CI status**:
   ```bash
   gh pr checks <PR_NUMBER>
   ```

2. **Fetch review comments** (every iteration):
   ```bash
   gh pr view <PR_NUMBER> --json reviews,comments,reviewDecision
   gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments --jq '.[] | {user: .user.login, body: .body, path: .path, line: .original_line, created_at: .created_at}'
   ```

3. **Display status summary**:
   ```
   [Check 3/30]

   CI Status:
   | Check            | Status  | Duration |
   |------------------|---------|----------|
   | lint (24.x)      | pass    | 5m34s    |
   | unittest (24.x)  | pending | -        |

   Reviews: 1 new comment from @reviewer
   ```

4. **Decide next action** based on priority:

   | CI Status | Reviews | Action |
   |-----------|---------|--------|
   | Any fail | - | **Auto-fix** CI failure (Step 3) |
   | Any pending | New comments | Show comments to user, keep waiting |
   | Any pending | No new comments | Wait 60s, re-check |
   | All pass | New comments | Show comments to user (Step 4) |
   | All pass | No new comments | Done (Step 5) |

### Step 3: Auto-fix CI failures

For each failed check:

1. Get failure log:
   ```bash
   gh run view <RUN_ID> --log-failed 2>&1 | tail -100
   ```
   Extract the run ID from the check URL.

2. Analyze the failure and determine the cause.

3. **Fixable** (lint error, type error, test failure from our changes):
   - Fix the code
   - Commit: `fix: resolve CI <check-name> failure`
   - Push to PR branch
   - Wait 30s, return to Step 2

4. **Not fixable** (infra issue, flaky test, unrelated failure):
   - Report failure details to user
   - Suggest actions (re-run, skip, manual fix)
   - Ask user how to proceed

### Step 4: Handle review comments

When new review comments are detected:

1. **Display each comment clearly**:
   ```
   New review comment from @reviewer:
   File: src/views/Example.tsx:42
   > Consider using useCallback here to prevent re-renders

   Review decision: CHANGES_REQUESTED
   ```

2. **Prompt the user**:
   - Show all unresolved comments
   - Ask: "Do you want me to address these review comments?"
   - If user says yes: fix the code, commit, push, return to Step 2
   - If user says no/later: continue monitoring CI only

3. **Track comment state**: Remember which comments have been shown to avoid repeating them in subsequent iterations.

### Step 5: Final report

When all CI checks pass and no new unhandled comments:

```
All CI checks passed!

| Check            | Status | Duration |
|------------------|--------|----------|
| lint (24.x)      | pass   | 5m34s    |
| unittest (24.x)  | pass   | 4m42s    |
| CodeQL           | pass   | 2m7s     |

Review status: approved / no reviews / changes requested
PR: <URL>
```

- All CI passed + approved → ready to merge
- All CI passed + no review → waiting for review
- All CI passed + changes requested → needs to address comments

## Polling Rules

- **60 seconds** between checks when pending
- **30 seconds** after fix+push to allow CI restart
- **Maximum 30 iterations** (~30 min), then ask user to continue or stop
- Always show `[Check N/30]`

## Important Notes

- CI failures: auto-fix without asking
- Review comments: always show to user, ask before fixing
- Never force-push or amend commits
- Each fix is a new commit
- Fix multiple CI failures in one commit when possible
- Do NOT re-run checks automatically (only if user requests `gh run rerun`)

Overview

This skill monitors a pull request’s CI checks and review comments until all checks pass and reviewer issues are resolved. It continuously polls the PR, summaries CI results and new review feedback, and can apply safe, non-destructive fixes for common CI failures. Use it to watch CI status, respond to reviewer comments, and prepare a PR for merge with minimal manual overhead.

How this skill works

The skill determines the target PR from a number, a GitHub PR URL, or by detecting the current branch. It enters a poll loop (up to 30 iterations) that fetches CI check statuses and review comments each cycle, displays a concise status summary, and chooses actions based on priorities. When it detects fixable CI failures it applies code fixes, commits, and pushes; when it finds new review comments it presents them and asks whether to address them. It respects safety rules: no force-pushes, each change is a new commit, and re-runs are only performed if you request them.

When to use it

  • Watching a PR until CI checks finish and pass
  • Waiting for intermittent or delayed checks to complete
  • Automatically fixing straightforward CI failures (lint, type, or tests from your changes)
  • Alerting and responding to new reviewer comments on a PR
  • Preparing a PR to be merge-ready without manual polling

Best practices

  • Run from the feature branch or provide the PR number/URL to avoid ambiguity
  • Review suggested auto-fixes before pushing when prompted
  • Limit auto-fixes to clear, code-local issues (lint, type, test failures caused by your changes)
  • Decline or review fixes for infra or unrelated failures; decide to rerun or escalate
  • Use the prompt for review comments so you control behavior and avoid unintended code changes

Example use cases

  • A lint rule broke after a recent change—auto-fix, commit, and push to restart CI
  • A long-running test suite is pending—monitor until it finishes or ask to extend the polling window
  • New reviewer requests changes—display comments, accept to auto-apply fixes, or defer
  • Intermittent infra failures—detect non-fixable errors and prompt for manual intervention
  • Prepare a PR for merge by ensuring all checks pass and reviewer concerns are addressed

FAQ

How does it pick the PR if I don't supply one?

It detects the current git branch and queries GitHub for an open PR matching that head; if none is found it stops and informs you.

Which CI failures will it auto-fix?

It auto-fixes clear, local issues like lint or type errors and failing tests caused by your changes. Infra, flaky, or unrelated failures are reported and require your direction.

Will it re-run CI workflows automatically?

No. The skill does not re-run workflows unless you explicitly request a rerun with the appropriate command.