# Goal PR

Drive a pull request to a clean state and merge it: run the `review-pr` skill, fix...

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

## Install

Claude Code: `npx skills add dyoshikawa/rulesync --skill goal-pr -g -a claude-code -y`
Codex: `npx skills add dyoshikawa/rulesync --skill goal-pr -g -a codex -y`
Cursor: `npx skills add dyoshikawa/rulesync --skill goal-pr -g -a cursor -y`
Gemini CLI: `npx skills add dyoshikawa/rulesync --skill goal-pr -g -a gemini-cli -y`

## Description

Drive a pull request to a clean state and merge it: run the `review-pr` skill, fix every mid-or-above finding, and repeat until no mid-or-above findings remain, then merge. Use when the user wants to finish a PR by reviewing, fixing, and merging it, or triggers on "the `goal-pr` skill".

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

# Goal PR

target_pr = the user's request

This skill drives a pull request all the way to merge. It repeatedly runs
the `review-pr` skill, fixes every finding of severity `mid` or above, and merges the PR
once a review round reports no `mid`-or-above findings.

## 0. Determine and Prepare the Target PR

1. If `target_pr` is provided (e.g. `123`, `#123`, or a PR URL), use it.
2. Otherwise, look for the PR of the current branch:

   ```bash
   gh pr view --json number,title,state,headRefName 2>/dev/null
   ```

3. If no PR exists yet, create one (this satisfies the "PR is the goal" intent):
   - Use the `commit-push-pr` skill to commit the current changes, push the
     branch, and open a PR.
   - Then resolve `target_pr` to the freshly created PR number.

Confirm that the current local branch is the PR's head branch, because the fix
phase below must commit and push fixes onto that branch. If they differ, ask the
user how to proceed and stop.

## 1. Exit Condition

The loop exits when a single review round satisfies **both** of:

- **0** findings of severity `mid`, `high`, or `critical` (only `low` findings,
  or none at all, may remain).
- The PR's GitHub Actions checks are **green**, no check is `fail` or
  `pending`.

Set a hard safety cap of **10 iterations**. If the exit condition is still not
met at the cap:

- If CI is green and every remaining finding is `mid` (no `high` or
  `critical`), merge anyway: record the remaining findings with the
  `create-scrap-issue` skill so they are tracked, then go to **Section 3**.
  `mid` findings are not merge blockers.
- Otherwise (a `high` / `critical` finding remains, or CI is red), stop the
  loop and report the remaining findings and failing CI instead of merging.

## 2. Iteration Loop

Repeat the following until the exit condition is satisfied or the cap is hit.

### 2-1. Review Phase

The rest: https://github.com/dyoshikawa/rulesync/blob/HEAD/.rulesync/skills/goal-pr/SKILL.md
