Skip to content
Back to skills

Finish Pr

ASecurity

Complete the post-submit PR loop: wait for CI and Cursor Bugbot on the latest pushed revision, triage and fix actionable findings, amend and resubmit, and repeat until clean. MUST be used after creating or updating a PR before declaring implementation work complete.

  • 35 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 20, 2026
testingrustgobashgitapiperformance

Works with

  • cursor
  • api

Security analysis

A96/100
  • mediumUses curl or wget to download content

Pro scans all 2 files and shows the line behind each finding

Scanned November 9, 2026

npx -y skills add ayunis-core/ayunis-core --skill finish-pr --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Finish Pr?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Finish Pr
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ayunis-core-finish-pr/badge)](https://www.skillsdirectory.com/skills/ayunis-core-finish-pr)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: finish-pr
description: "Complete the post-submit PR loop: wait for CI and Cursor Bugbot on the latest pushed revision, triage and fix actionable findings, amend and resubmit, and repeat until clean. MUST be used after creating or updating a PR before declaring implementation work complete."
---

# Finish PR

Treat PR submission as the start of verification, not the end of the task. Keep ownership of the PR until its latest submitted revision is green and Bugbot-clean.

## 1. Resolve the submitted PRs

Load `git-workflow` and follow its push safety rules throughout this workflow.

Identify every PR whose branch was created or updated by the submission. For a stack, include every submitted PR in the stack, not only the current or top PR. Record each PR number, URL, branch, and remote head SHA:

```bash
gh api "repos/{owner}/{repo}/stacks?pull_request=<pr-number>" --jq '.[].pull_requests[].number'   # every PR in the stack, bottom to top
gh pr view <branch-or-number> --json number,url,headRefName,headRefOid
```

Use the remote `headRefOid` as the revision under verification. If the remote head changes while waiting, discard the stale result and restart verification for the new SHA.

### Trigger Bugbot — it does not run on its own

Cursor Bugbot no longer reviews PRs automatically on open or push. Without a trigger comment, no `Cursor Bugbot` check run appears on the head SHA, and the wait in §2 never ends. After **every** submission (PR creation and every later `gh stack push` or `gh stack submit`), comment on each PR whose head changed:

```bash
gh pr comment <pr-number> --body "@bugbot run"
```

For a stack, comment on every submitted PR in the stack, not only the top. A trigger posted before the latest push does not cover the new head; post it again.

## 2. Wait for CI and Bugbot

Wait for all checks on every submitted PR. For an ordinary PR:

```bash
gh pr checks <pr-number> --watch --interval 30
```

### Legacy Graphite check — do not use `--watch` while it is pending

The Graphite GitHub app may still post `Graphite / mergeability_check`. It is not a required check and not part of the workflow. On a stacked PR it stays in progress until every downstack PR merges, so `gh pr checks --watch` waits for it forever even after all real verification has passed.

If that exact check is pending on the recorded head SHA, do not run `--watch` for that PR. Poll the JSON state instead and evaluate every check except that one:

```bash
gh pr checks <pr-number> --json name,bucket,state,link
```

Continue while any other check is pending; handle any other failure or cancellation normally. Record the pending Graphite check in the verification report.

If no checks are visible immediately after submission, wait 30 seconds and query again. Do not interpret absent checks as success. If CI checks appear but `Cursor Bugbot` doesn't, first confirm you posted `@bugbot run` after the latest push (§1).

### Zero runs created — check the platform before the repo

If **no workflow runs exist at all** for the new head SHA after a couple of minutes, the cause is far more often platform-side than repo-side. Check that first, before diagnosing workflow triggers, branch filters, or re-pushing:

```bash
curl -s https://www.githubstatus.com/api/v2/summary.json \
  | jq '.components[] | select(.name == "Actions") | {name, status}'
gh run list --limit 10   # repo-wide: are other branches stuck too?
```

If Actions reports `degraded_performance` or `major_outage`, stop diagnosing the PR — go to the outage rule below. Runs that GitHub never created during an incident do not appear later on their own; they need a re-trigger *after* recovery.

## 2b. External platform outage — report blocked, do not camp on it

A confirmed platform incident is an **external condition**, which §5 already classifies as blocked. Blocked means hand back, not poll harder.

- **Do not** sit in escalating in-session sleep loops, background watchers, or self-scheduled wake-ups waiting for a provider to recover. Sessions have burned 2–6 hours this way, across multiple PRs on the same day, while the answer was always "GitHub is down."
- **Within ~1 hour** of confirming the incident, report the PR as blocked with the incident status and the exact SHA awaiting verification, and stop. Let the user decide whether to wait.
- **Never push a no-op or empty commit** to force a `synchronize` event. It pollutes the branch history with meaningless SHAs and discards any Bugbot pass already earned on the real head.
- **After recovery**, re-trigger with a same-SHA method so existing check results stay valid:

  ```bash
  gh pr close <pr-number> && gh pr reopen <pr-number>   # same SHA, re-fires triggers
  ```

  Do this **once**, and say in the report that you did it — closing and reopening is a visible mutation of PR state, not a silent recovery step. If it does not produce runs, report blocked rather than repeating it.

The same applies to any external provider the loop depends on (Bugbot, the registry, Linear). Verify the incident is real before invoking this rule — a single failed check is not an outage.

After the watch completes, inspect the final state explicitly:

```bash
gh pr checks <pr-number> --json name,bucket,state,link
```

Treat `pending`, `fail`, and `cancel` buckets as unfinished. A skipped check is acceptable only when the workflow intentionally skipped it; mention that in the final report.

Do not trust Cursor Bugbot's check conclusion by itself. A successful Bugbot check can still leave review comments.

## 3. Address CI failures

For each failing or cancelled check:

1. Read the check details, annotations, and failed GitHub Actions logs. Use `gh run view <run-id> --log-failed` for Actions failures.
2. Classify the failure before changing code:
   - **PR-caused and actionable**: fix it in the existing PR.
   - **Flaky or cancelled**: rerun it once, then wait for the rerun.
   - **Infrastructure failure or demonstrably failing on the base revision**: gather evidence and report the PR as blocked; do not broaden the PR silently.
3. Run the relevant local validation for any code change.
4. Amend and resubmit with the process in `git-workflow`.

After any resubmission, refresh every affected PR's remote head SHA and restart the full CI and Bugbot loop. Results from the previous SHA no longer count.

### CI experiments go on a throwaway branch, never the PR branch

Some evidence needs CI to run code that must not ship: diagnostic logging to catch a CI-only failure, or a deliberately failing test that proves a required check goes red. Keep that code off the real PR branch. Pushing it there and amending it out later costs an extra CI round. It also leaves a diagnostic head that reviewers and Bugbot may see, and the clean run on the real change no longer counts as the final verification.

Instead, run the probe in parallel with the real PR's CI:

```bash
git switch -c probe/<ticket>-<what> <real-pr-head-sha>
# add the probe commit
git push origin probe/<ticket>-<what>      # plain git push; never add it to a stack
git switch <real-pr-branch>                # back to the real branch
gh pr create --draft --base <real-pr-base-branch> --head probe/<ticket>-<what> \
  --title "DO NOT MERGE: <ticket> <what> probe" --body "Throwaway CI probe for #<real-pr>."
# wait for the run, record its URL as evidence in the real PR's description or report
gh pr close <probe-pr> --delete-branch
```

The real PR branch only ever carries the real change. If a diagnostic already landed on it, amend it out (`git commit --amend` on the PR branch, then push per `git-workflow`), return the PR to ready-for-review, and re-run this loop on the clean head.

## 4. Address Bugbot findings

Load `bugbot-triage` and use its paginated comment fetching, full-stack scan, root-cause tracing, and verdicts. Do not recreate a shallower Bugbot review here.

The implementation request that produced the PR authorizes fixes for actionable CI and Bugbot findings that stay within the PR's scope:

- **Valid and simple**: implement the direct root-cause fix.
- **Valid but symptom**: implement the structural fix recommended by the triage, unless that would materially expand the requested scope; if it would, stop and explain the decision needed.
- **Invalid**: record the evidence, reply when useful, and resolve the thread if permitted.

For valid findings, amend the existing PR rather than creating a separate fix PR. Resolve addressed threads when permitted. Resubmit and restart verification on the new head SHA.

## 5. Completion gate

Do not declare the task complete until all of these are true for every submitted PR:

- The recorded remote head SHA is still the PR's current head.
- Every CI check has completed successfully or was intentionally skipped with a documented reason; a pending legacy `Graphite / mergeability_check` as described in §2 is also acceptable and must be documented.
- Cursor Bugbot completed on the current head.
- All Bugbot comments across the submitted stack were triaged and no actionable finding remains.
- The local worktree is clean and the submitted branches contain every fix.

A polling timeout is not success. Report **blocked**, never **done**, when authentication, infrastructure, or another external condition prevents verification.

"Keep waiting" applies to checks that are *running* — queued jobs, a slow test suite, a Bugbot pass in flight. It does **not** license open-ended polling when nothing is running because the platform is down: that is the blocked case, and §2b governs it. If you have polled the same unchanged external condition more than a few times, you are no longer verifying — report and hand back.

If the same CI failure or Bugbot finding survives three fix attempts, stop and escalate with the attempts and evidence. New findings on successive revisions are progress and restart the count for those findings.

## Report

Report the PR URLs and concise evidence for CI and Bugbot status. Mention fixes made during the loop. If blocked, name the exact unfinished check or finding and the evidence that prevents further progress.

Files in this skill

  • SKILL.md6.9 KB
  • agents/openai.yaml204 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.