Skip to main content
ClaudeWave
Skill28.2k repo starsupdated today

pr-verify

The pr-verify skill enables interactive verification and merging of GitHub pull requests labeled "bot:ready-to-merge" in the AionUi repository. It displays a filterable list of recent PRs with change metrics and type classification, performs impact analysis on selected PRs, supplements test coverage information, provides confidence scoring, and executes one-click merges. Use this workflow when ready to review and merge vetted pull requests with automated confidence assessment.

Install in Claude Code
Copy
git clone --depth 1 https://github.com/iOfficeAI/AionUi /tmp/pr-verify && cp -r /tmp/pr-verify/.claude/skills/pr-verify ~/.claude/skills/pr-verify
Then start a new Claude Code session; the skill loads automatically.

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/aionui-verify-<PR_NUMBER>` — never use `/tmp/aionui-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 `没有找到 bot:ready-to-merge 的 PR。` 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   | 标题                              | 变更          | 类型
--|------|-----------------------------------|---------------|--------
1 | #123 | fix(auth): handle token expiry    | +45 / -12     | bugfix
2 | #124 | feat(ui): add dark mode toggle    | +230 / -18    | feature
```

Then prompt:

> 请输入序号选择 PR,或输入 q 退出:

- 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("已自动 review") or test("已自动修复")))] | 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:

> ⚠️ 该 PR 在标记 bot:ready-to-merge 后有新提交(最新提交:`<LATEST_COMMIT_TIME>`,标签时间:`<LABEL_SET_TIME>`)。
> 建议重新 review 后再合并。请选择:
> r - 移除 bot:ready-to-merge 标签,触发重新 review
> c - 忽略并继续验证

- `r` → remove `bot:ready-to-merge` label:
  ```bash
  gh pr edit $PR_NUMBER --remove-label "bot:ready-to-merge"
  ```
  Display `已移除标签,PR 将在下一轮自动化中重新 review。` 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:**

> ⏳ 以下 CI job 尚未完成:[job 列表]
> 请选择:
> w - 等待 CI 完成后继续(推出,请稍后重新运行)
> c - 忽略,继续验证

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

**CI failed prompt:**

> ❌ 以下 CI job 未通过:[job 列表及结论]
> 请选择:
> s - 跳过此 PR
> c - 忽略失败,继续验证

- `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 of rebase?** Since we squash-merge all PRs, the intermediate commit
> history is irrelevant. `git merge` produces exactly the conflicts GitHub shows (one pass
> over the final diff), while `git rebase` replays each commit individually, often creating
> extra conflicts in files that GitHub reports as clean. Always use merge for conflict
> resolution