plugins/dev/skills/pr-stack/SKILL.md
Plan and execute splitting a large PR or branch into a reviewable stacked PR sequence.
npx skillsauth add rp1-run/rp1 pr-stackInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Plan and execute splitting a large PR, local branch, or remote branch into an ordered stack of smaller reviewable PRs.
Use the pre-resolved projectRoot, kbRoot, workRoot, and codeRoot values from the generated Workflow Bootstrap section. Run all source-control commands from codeRoot, and write workflow artifacts only under workRoot.
Constraint: plan first; create branches/PRs only after explicit user approval.
stateDiagram-v2
[*] --> planning
planning --> executing : approved
planning --> reporting : plan_only
executing --> reporting : stack_created
reporting --> [*] : done
On each phase transition, report via:
rp1 agent-tools emit \
--workflow pr-stack \
--type status_change \
--run-id {RUN_ID} \
--step {CURRENT_STATE} \
--data '{"status": "running"}'
RUN_ID comes from the generated Workflow Bootstrap section.RUN_NAME from the resolved source: use "PR Stack: PR #{number}" for a GitHub PR, otherwise "PR Stack: {source_ref}".--name "{RUN_NAME}".{"status":"failed","reason":"..."} and stop.Example sequence:
rp1 agent-tools emit --workflow pr-stack --type status_change --run-id {RUN_ID} --name "PR Stack: PR #42" --step planning --data '{"status": "running"}'
rp1 agent-tools emit --workflow pr-stack --type waiting_for_user --run-id {RUN_ID} --step planning --data '{"prompt":"Approve this split plan and allow branch/PR creation?","context":"pr-stack requires explicit approval before creating branches, commits, pushes, or PRs"}'
rp1 agent-tools emit --workflow pr-stack --type status_change --run-id {RUN_ID} --step executing --data '{"status": "running"}'
rp1 agent-tools emit --workflow pr-stack --type status_change --run-id {RUN_ID} --step reporting --data '{"status": "running"}'
rp1 agent-tools emit --workflow pr-stack --type status_change --run-id {RUN_ID} --step reporting --data '{"status": "completed"}'
SOURCE as recovery point; no unrelated edits.SOURCE diff/commits/checks only; stop when split boundaries cannot be proven.Emit planning running before command execution.
resolve-args, do not generate a UUID, and do not re-derive directories.git -C {codeRoot} status.gh pr view and gh pr diff; record URL, number, head branch, base, head SHA.git -C {codeRoot} fetch, record remote ref and SHA.SOURCE ref and exact SHA. Do not push to, rebase, reset, delete, or amend SOURCE.BASE_BRANCH...SOURCE_SHA with git diff, git diff --numstat, and git log.GENERATED_EXCLUSIONS plus obvious lockfiles/generated outputs only when the plan names each path and why it is generated.CHECK_COMMAND provided, use it.CHECK_COMMAND.Before any branch or PR creation, produce a user-facing split plan.
The plan is primarily for a human reviewer/maintainer deciding whether to approve execution. Keep it concise, scannable, and decision-oriented. Do not lead with internal workflow IDs, raw SHAs, merge-state dumps, long file lists, or test log excerpts. Put internal metadata in YAML frontmatter and put detailed evidence in a compact appendix only when it helps the user audit the plan.
Required plan format:
---
source: "{SOURCE_URL_OR_REF}"
source_title: "{SOURCE_TITLE_IF_KNOWN}"
source_branch: "{SOURCE_BRANCH_IF_KNOWN}"
source_head_sha: "{SOURCE_HEAD_SHA}"
base_branch: "{BASE_BRANCH}"
base_sha: "{BASE_SHA_IF_KNOWN}"
stack_id: "{STACK_ID}"
max_line_change: {MAX_LINE_CHANGE}
generated_exclusions: []
check_commands:
- "{CHECK_COMMAND}"
workflow_run_id: "{RUN_ID}"
---
# PR Stack Plan: {human source label}
**Recommendation:** {Ready to execute after approval | Execution blocked until ... | Plan only}
{One short paragraph explaining why this split is the right review shape.}
## Stack At A Glance
| # | PR | Base | Size | What Reviewers Validate |
|---|----|------|------|-------------------------|
| 1 | {title} | `{base}` | {+/- total} | {one concrete review goal} |
## Proposed PRs
### 1. {PR title}
- Branch: `{branch}`
- Intent: {one sentence}
- Changes: {short file-area or commit summary, not a long path dump}
- Validation: `{check command}` plus any PR-specific check
- Size: {added + deleted} counted lines; generated exclusions: {none or named paths}
- Risk: {main risk in one sentence}
- Confidence: {Supported/Provisional/etc.}
## Approval Gate
Approve this split plan and allow branch/PR creation?
## Technical Appendix
- Recovery point: `{source ref}@{source head sha}`
- Reconstruction: {how top-of-stack diff will be compared to source diff}
- Commit groups: {short list only when cherry-pick order matters}
- Blockers: {conflicts, checks, source drift, or none}
Plan content requirements:
Stack At A Glance must fit on one screen for typical stacks. Use one row per PR.Proposed PRs may include branch names, intent, validation, size, risk, and confidence. Avoid dumping all files unless file paths are the only way to understand scope; if needed, include only representative directories in the body and exact path lists in the appendix.Technical Appendix, not in top-level body sections.Snapshot, Observations, Execution Refresh, Execution Stop, or Retry Stop; those read as logs. Use Recommendation, Stack At A Glance, Proposed PRs, Checks, Blockers, Approval Gate, and Technical Appendix.## Execution Status section with Result, What happened, Current blocker, and Next step. Keep raw logs in a referenced file path or appendix excerpt, not the main narrative.none.Derive STACK_ID as pr-{number} for PR sources, otherwise sanitize the source ref by lowercasing and replacing characters outside [a-z0-9._-] with -.
Write the plan to {workRoot}/pr-stacks/{STACK_ID}-stack-plan.md and register it:
rp1 agent-tools emit \
--workflow pr-stack \
--type artifact_registered \
--run-id {RUN_ID} \
--step planning \
--data '{"path": "pr-stacks/{STACK_ID}-stack-plan.md", "feature": "{STACK_ID}", "storageRoot": "work_dir", "format": "markdown"}'
Ask exactly:
Approve this split plan and allow branch/PR creation?
Also emit the waiting gate:
rp1 agent-tools emit \
--workflow pr-stack \
--type waiting_for_user \
--run-id {RUN_ID} \
--step planning \
--data '{"prompt":"Approve this split plan and allow branch/PR creation?","context":"pr-stack requires explicit approval before creating branches, commits, pushes, or PRs"}'
If PLAN_ONLY=true, emit reporting running, then reporting completed, and stop after the plan.
Without exact approval, do not create branches, commits, pushes, or PRs. Emit reporting running, then reporting completed, and output the plan path.
Emit executing running before creating a branch, commit, push, or PR.
BASE_BRANCH. For PR N, branch from PR N-1 branch.git cherry-pick.git add -p / git restore -p; keep each commit scoped to the current PR.MAX_LINE_CHANGE after generated exclusions.git push to PUSH_REMOTE.gh pr create --base <previous-branch-or-base>.## 🥞 Stack map
1. [PR title](TBD)
2. 👉 [Current PR title](TBD) ← you are here
3. [Next PR title](TBD)
TBD stack-map link with real PR URLs via gh pr edit.SOURCE was a PR, post a summary comment with gh pr comment; prefix the message with 🤖.SOURCE was only a branch, include the summary in final output unless the user supplied a comment target.Emit reporting running after stack creation, then verify:
BASE_BRANCH for PR 1 or prior stack branch for PR N.MAX_LINE_CHANGE, excluding only named generated files.gh pr checks after creation when available.git diff --binary BASE_BRANCH...SOURCE_SHA to git diff --binary BASE_BRANCH...TOP_STACK_BRANCH; differences are blockers unless already listed as intentional generated-file exclusions.SOURCE ref still equals recorded SHA, or report exact drift.Append the final report to {workRoot}/pr-stacks/{STACK_ID}-stack-plan.md, then emit reporting completed.
git push --force, git reset --hard, branch deletion, destructive rebase, or source-branch rewrite without explicit chat confirmation naming the exact command.During plan:
During execution:
Final:
SOURCE preservation resultrp1 agent-tools emitgit statusgit fetchgit diffgit loggit branchgit checkoutgit cherry-pickgit addgit restoregit commitgit pushgh pr viewgh pr diffgh pr creategh pr editgh pr commentgh pr checksjustSingle pass per phase. Do not:
pr-stacks/.documentation
Ask about rp1 capabilities, discover skills, and get workflow guidance.
tools
Generate an evidence-grounded markdown walkthrough for a pull request.
development
Run a bounded, evidence-driven two-agent debate into a separate rp1 debate artifact with backend locks only.
testing
Intent-aware map-reduce PR review with CI/CD support, confidence gating, and intelligent comment deduplication.