Skip to main content
ClaudeWave
Skill596 estrellas del repoactualizado 3d ago

pr-verify

|

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/FerroxLabs/wayland /tmp/pr-verify && cp -r /tmp/pr-verify/.claude/skills/pr-verify ~/.claude/skills/pr-verify
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# PR Verification & Merge

Interactive workflow to verify `bot:ready-to-merge` PRs - displays impact analysis, supplements tests, and provides one-click merge with confidence scoring.

**Announce at start:** "I'm using pr-verify skill to verify and merge ready PRs."

## Usage

```
/pr-verify [pr_number]
```

`$ARGUMENTS` may contain an optional PR number.

- Without argument: display list of `bot:ready-to-merge` PRs for selection
- With argument: skip list, go directly to that PR number

---

## Configuration

```
PR_DAYS_LOOKBACK: env var (default: 7) - lookback window for PR list
CRITICAL_PATH_PATTERN: env var - pattern to detect critical file paths
```

**REPO** is detected automatically at runtime - do not hardcode it:

```bash
REPO=$(gh repo view --json nameWithOwner --jq '.nameWithOwner')
```

**Worktree path:** always `/tmp/wayland-verify-<PR_NUMBER>` - never use `/tmp/wayland-pr-*` (reserved for pr-automation/pr-fix).

---

## Steps

### Step 1 - PR List Display

Parse `$ARGUMENTS` for an optional PR number.

**If a PR number is provided:** skip the list, jump directly to Step 2 with that PR number.

**If no argument provided:** query `bot:ready-to-merge` PRs from the last `PR_DAYS_LOOKBACK` days (default 7):

```bash
DAYS=${PR_DAYS_LOOKBACK:-7}
gh pr list \
  --state open \
  --label "bot:ready-to-merge" \
  --search "created:>=$(date -v-${DAYS}d '+%Y-%m-%d' 2>/dev/null || date -d "${DAYS} days ago" '+%Y-%m-%d') -is:draft" \
  --json number,title,labels,changedFiles,additions,deletions,headRefName,baseRefName,commits,createdAt,author \
  --limit 50
```

If the result is empty: display `No bot:ready-to-merge PRs found.` and exit.

For each PR, infer the type from the first commit message prefix:

| Prefix pattern | Type     |
| -------------- | -------- |
| `fix(`         | bugfix   |
| `feat(`        | feature  |
| `refactor(`    | refactor |
| `chore(`       | chore    |
| `docs(`        | docs     |
| `perf(`        | perf     |
| `test(`        | test     |
| other          | misc     |

Display as a numbered table:

```
# | PR   | Title                             | Changes       | Type
--|------|-----------------------------------|---------------|--------
1 | #123 | fix(auth): handle token expiry    | +45 / -12     | bugfix
2 | #124 | feat(ui): add dark mode toggle    | +230 / -18    | feature
```

Then prompt:

> Enter a number to select a PR, or q to quit:

- User inputs a number → use that PR
- User inputs `q` → exit

Save the selected PR number as `PR_NUMBER` for all subsequent steps.

---

### Step 2 - Pre-flight Checks

Run three checks in order. A failure in any check presents the user with an action choice.

#### Check 1 - New Commits Since Ready-to-Merge Label

```bash
# Time when bot:ready-to-merge label was last set (infer from bot comment)
LABEL_SET_TIME=$(gh pr view $PR_NUMBER --json comments \
  --jq '[.comments[] | select(.body | test("<!-- pr-automation-bot -->") and (test("bot:ready-to-merge") or test("auto-reviewed") or test("auto-fixed")))] | last | .createdAt // ""')

LATEST_COMMIT_TIME=$(gh pr view $PR_NUMBER --json commits \
  --jq '.commits | last | .committedDate')
```

If `LATEST_COMMIT_TIME > LABEL_SET_TIME` (new commits after the label was set), prompt:

> ⚠️ This PR has new commits after bot:ready-to-merge was set (latest commit: `<LATEST_COMMIT_TIME>`, label time: `<LABEL_SET_TIME>`).
> Re-review is recommended before merging. Choose:
> r - Remove bot:ready-to-merge label and trigger re-review
> c - Ignore and continue verification

- `r` → remove `bot:ready-to-merge` label:
  ```bash
  gh pr edit $PR_NUMBER --remove-label "bot:ready-to-merge"
  ```
  Display `Label removed. PR will be re-reviewed in the next automation cycle.` and return to list (Step 1).
- `c` → continue to Check 2.

#### Check 2 - CI Status

```bash
gh pr view $PR_NUMBER --json statusCheckRollup \
  --jq '.statusCheckRollup[] | {name: .name, status: .status, conclusion: .conclusion}'
```

Required jobs: `Code Quality`, `Unit Tests (ubuntu-latest)`, `Unit Tests (macos-14)`, `Unit Tests (windows-2022)`, `Coverage Test`, `i18n-check`

Informational exclusions: `codecov/patch` and `codecov/project` are informational - exclude them from all failure checks.

| Condition                                                | Action              |
| -------------------------------------------------------- | ------------------- |
| All required jobs SUCCESS, no non-informational failures | Continue to Check 3 |
| Any required job QUEUED or IN_PROGRESS                   | Prompt (see below)  |
| Any non-informational job FAILURE or CANCELLED           | Prompt (see below)  |

**CI still running prompt:**

> ⏳ The following CI jobs are not yet complete: [job list]
> Choose:
> w - Wait for CI to finish (exit and re-run later)
> c - Ignore and continue verification

- `w` → exit
- `c` → continue to Check 3

**CI failed prompt:**

> ❌ The following CI jobs did not pass: [job list and conclusions]
> Choose:
> s - Skip this PR
> c - Ignore failures and continue verification

- `s` → remove `bot:ready-to-merge` label (let pr-automation re-process next round), return to list (Step 1):
  ```bash
  gh pr edit $PR_NUMBER --remove-label "bot:ready-to-merge"
  ```
- `c` → continue to Check 3

#### Check 3 - Merge Conflicts

```bash
gh pr view $PR_NUMBER \
  --json mergeable,mergeStateStatus,headRefName,baseRefName \
  --jq '{mergeable, mergeStateStatus, head: .headRefName, base: .baseRefName}'
```

| `mergeable`   | Action                                                                 |
| ------------- | ---------------------------------------------------------------------- |
| `MERGEABLE`   | Continue to Step 3                                                     |
| `UNKNOWN`     | Skip this PR (return to list), log: `mergeability unknown, will retry` |
| `CONFLICTING` | Attempt auto-merge (see below)                                         |

**Auto-merge attempt on conflict:**

> **Why merge instead