# Loop Until Checks Pass

Iterates on a pull request until the latest checks are green or a blocker is named.

- Repository: https://github.com/paperclipai/paperclip (109885 stars)
- Category: Git and review
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add paperclipai/paperclip --skill prcheckloop -g -a claude-code -y`
Codex: `npx skills add paperclipai/paperclip --skill prcheckloop -g -a codex -y`
Cursor: `npx skills add paperclipai/paperclip --skill prcheckloop -g -a cursor -y`
Gemini CLI: `npx skills add paperclipai/paperclip --skill prcheckloop -g -a gemini-cli -y`

## Description

Iterate on a GitHub PR until latest-head checks are green or a precise blocker is named. Use when a PR still has failing or pending checks after review fixes, including after greploop.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# PRCheckloop

Get a GitHub PR to a fully green check state, or exit with a concrete blocker.

## Scope

- GitHub PRs only. If the repo is GitLab, stop and use `check-pr`.
- Focus on checks for the latest PR head SHA, not old commits.
- Focus on CI/status checks, not review comments or PR template cleanup.
- If the user also wants review-comment cleanup, pair this with `check-pr`.

## Inputs

- **PR number** (optional): If not provided, detect the PR for the current branch.
- **Max iterations**: default `5`.

## Workflow

### 1. Identify the PR

If no PR number is provided, detect it from the current branch:

```bash
gh pr view --json number,headRefName,headRefOid,url,isDraft
```

If needed, switch to the PR branch before making changes.

Stop early if:

- `gh` is not authenticated
- there is no PR for the branch
- the repo is not hosted on GitHub

### 2. Track the latest head SHA

Always work against the current PR head SHA:

```bash
PR_JSON=$(gh pr view "$PR_NUMBER" --json number,headRefName,headRefOid,url)
HEAD_SHA=$(echo "$PR_JSON" | jq -r .headRefOid)
PR_URL=$(echo "$PR_JSON" | jq -r .url)
```

Ignore failing checks from older SHAs. After every push, refresh `HEAD_SHA` and
restart the inspection loop.

### 3. Inventory checks for that SHA

Fetch both GitHub check runs and legacy commit status contexts:

```bash
gh api "repos/{owner}/{repo}/commits/$HEAD_SHA/check-runs?per_page=100"
gh api "repos/{owner}/{repo}/commits/$HEAD_SHA/status"
```

For a compact PR-level view, this GraphQL payload is useful:

The rest: https://github.com/paperclipai/paperclip/blob/HEAD/.agents/skills/prcheckloop/SKILL.md
