|
| 1 | +--- |
| 2 | +name: next-pr |
| 3 | +description: Review and advance the next easy-to-merge pull request in this repository. Use when the user wants Codex to list open PRs, pick the most trivial low-risk PR, establish a clean baseline on the default branch, rebase the PR, rerun tests and benchmarks, summarize findings for approval, and only merge and push after explicit user approval. |
| 4 | +--- |
| 5 | + |
| 6 | +# Next PR |
| 7 | + |
| 8 | +Follow this workflow when the user wants to catch up on pull requests by taking the next easiest one first. |
| 9 | + |
| 10 | +## GitHub Access |
| 11 | + |
| 12 | +Use the `gh` CLI for GitHub interactions in this workflow. |
| 13 | + |
| 14 | +- Use `gh pr list` to enumerate open PRs. |
| 15 | +- Use `gh pr view` to inspect candidate PRs and changed files. |
| 16 | +- Use `gh pr checkout` or `gh api` for PR-specific fetch and checkout operations. |
| 17 | + |
| 18 | +Only fall back to the web or raw API calls if `gh` is unavailable or not authenticated. |
| 19 | + |
| 20 | +## Checkout Rules |
| 21 | + |
| 22 | +Do not use `git worktree` in this workflow. |
| 23 | + |
| 24 | +- Stay in the user's current checkout. |
| 25 | +- Use local branches in the current repository when preparing the baseline branch and the PR review branch. |
| 26 | +- If uncommitted local changes make that unsafe, stop and tell the user instead of creating a worktree. |
| 27 | + |
| 28 | +## Workflow |
| 29 | + |
| 30 | +1. Identify the parent repo and its default branch. |
| 31 | +Use the actual remote default branch rather than assuming `main` or `master`. |
| 32 | + |
| 33 | +2. List all open pull requests on the parent repo. |
| 34 | +Prefer the parent repo over a fork unless the user says otherwise. Use `gh pr list` against the parent repo. |
| 35 | + |
| 36 | +3. Pick the most trivial PR and explain why it is the easiest yes/no decision. |
| 37 | +Prefer small, low-risk PRs such as: |
| 38 | +- dependency bumps with narrow blast radius |
| 39 | +- docs-only or config-only changes |
| 40 | +- tiny test fixes |
| 41 | +- one-commit PRs with limited file scope |
| 42 | + |
| 43 | +Avoid PRs that: |
| 44 | +- change behavior across many files |
| 45 | +- mix refactors with fixes |
| 46 | +- need product or architecture decisions |
| 47 | +- are hard to evaluate because baseline validation is broken |
| 48 | + |
| 49 | +4. Establish a clean baseline before touching the PR branch. |
| 50 | +Update the local default branch from `origin` and validate that exact branch first. |
| 51 | + |
| 52 | +Run the repo's real validation commands, not substitutes. Include benchmarks when the repo has a benchmark workflow. |
| 53 | + |
| 54 | +If baseline validation fails: |
| 55 | +- do not treat PR validation as authoritative |
| 56 | +- fix the baseline first if that matches the user's requested workflow |
| 57 | +- otherwise stop and tell the user the PR cannot be judged against a green baseline yet |
| 58 | + |
| 59 | +5. Check out the PR only after the baseline is green. |
| 60 | +Create a dedicated local review branch for the PR in the current checkout. Use `gh pr checkout` or an equivalent `gh`-driven fetch to materialize the PR locally. Rebase it on the latest default branch tip. Resolve conflicts carefully without discarding upstream or user work. |
| 61 | + |
| 62 | +6. Validate the rebased PR branch. |
| 63 | +Run the same tests and benchmarks used for the baseline so the comparison is meaningful. Call out: |
| 64 | +- passes or failures |
| 65 | +- benchmark regressions or improvements |
| 66 | +- new warnings, flaky behavior, or environment issues |
| 67 | + |
| 68 | +7. Summarize for approval before merging. |
| 69 | +Report: |
| 70 | +- PR number and title |
| 71 | +- why it was chosen |
| 72 | +- what changed at a high level |
| 73 | +- rebase result |
| 74 | +- baseline validation result |
| 75 | +- PR validation result |
| 76 | +- recommendation and any risks |
| 77 | + |
| 78 | +Do not merge or push yet. |
| 79 | + |
| 80 | +8. Merge only after explicit user approval. |
| 81 | +After approval, integrate the rebased PR into the default branch in the way the repo expects. Preserve the PR commits unless the user asks to squash or rewrite them. |
| 82 | + |
| 83 | +9. Push only after the merge is complete and the default branch is in the intended state. |
| 84 | +Push the default branch to the appropriate remote and report what was pushed. |
| 85 | + |
| 86 | +## Validation Rules |
| 87 | + |
| 88 | +- Use the same command set for baseline and PR validation so results are comparable. |
| 89 | +- If the repo has both fast checks and full checks, run the full set unless the user explicitly narrows scope. |
| 90 | +- If benchmarks are noisy, report broad direction and uncertainty instead of overclaiming precision. |
| 91 | +- If a failure is clearly pre-existing, say that explicitly and separate it from PR-specific findings. |
| 92 | + |
| 93 | +## Communication |
| 94 | + |
| 95 | +- Tell the user which PR you picked and why it is the lowest-risk candidate. |
| 96 | +- When baseline is broken, say that first. |
| 97 | +- Before merge and push, stop at an approval gate and wait for the user. |
| 98 | +- After approval, report exactly which branch was updated and pushed. |
0 commit comments