PR Workflow Manager
Find the skills before inventing a workflow
This discovery section is the bootstrap: apply it before executing any workflow, native-goal activation or helper rule below. First read applicable target-repository and higher-priority user/safety/authority instructions to resolve source intent. The target PR's base/head SHA is not the skills-source revision; merely reading this entry point does not authorize its operational rules or establish that an alias already ran a helper.
- Pin intent. Apply target-repository policy and the task's explicit skills-source ref, including an intentionally older revision. If neither selects a revision, resolve the official
jleechanorg/jleechan-skillsdefault-branch tip from current trusted source evidence or a read-only remote-ref query. Resolve the selected ref to an immutable commit; record the repository identity, requested ref, resolved SHA and evidence in the existing execution record. Do not infer intent from a familiar checkout path, installation date, version label or cached remote-tracking ref. Unresolved conflicting requirements need clarification before dependent work. - Compare candidates. Inspect the known official checkout's remote, HEAD and local changes, and any discovered installed source's provenance. Bind the manager, lifecycle files and their loaded dependencies (including any executable helpers) to the pinned commit (for example, by comparing bytes against that commit or verified revision-bound package hashes); a remote URL or claimed version alone is insufficient. A checkout at another commit is stale for this task even if official; an installed copy is not automatically newer or authoritative. Missing provenance or modified instruction files cannot establish an exact-revision match.
- Select without overwriting. Use a verified matching installed source or matching checkout; prefer the verified installed source when the known checkout is stale. Otherwise obtain the exact pinned revision in an unused isolated source directory from verified local Git objects, or clone
https://github.com/jleechanorg/jleechan-skills.gitand fetch only what is needed when network access is available and authorized. Verify the resulting HEAD and loaded files against the pin. Never update, reset, stash, switch branches in, or overwrite the incumbent dirty checkout or installed tree to resolve instructions. Unrelated dirty work may remain when the loaded files are verified unchanged. - Load one revision. Record the selected source path and verification result, then load
pr-workflow-manager/SKILL.md,pr-lifecycle/SKILL.mdand their required dependencies from that same verified skills tree (.claude/skills/in a checkout). Reconcile their operational rules with higher-priority instructions before executing them; the selected manager replaces this bootstrap copy's operational rules. Retain this verified source selection rather than restarting an older manager's unpinned discovery. Do not mix a selected lifecycle with another revision's manager, references or helpers. Before any helper execution, verify its availability, provenance and interface compatibility with the selected rules. If an alias already attempted activation, inspect actual state without replaying an unverified command; prior execution is not proof of compatibility. Keep the pin for the run; an intentional revision change requires re-verification and reassessment of affected obligations. - Reconcile command semantics as well as helper compatibility. A revision pin establishes which instructions were selected; it does not establish that their runtime command examples still have the same meaning. Before using any goal query, capability probe, or composer command, verify its read/write semantics against the active runtime's supported interface and current documentation. Never treat
/goal activeas a status query solely because a pinned source says so: on Claude Code versions where/goal <condition>sets a goal, that command mutates state. Inspect goal state, including whether the user cleared, paused, or stopped it, through a verified read-only native API or a provenance- and interface-verified status helper. For goal inspection, use a composer command only when its exact form is documented read-only for that runtime. Intentional goal-setting commands remain subject to the reconciled activation contract and user authority. If semantics are unknown, do not probe by invoking it; report the state as unverified and use the lifecycle's unsupported/unavailable fallback. Check native API semantics independently of helper presence; a missing helper does not make a supported native read API unavailable, and helper availability does not prove command compatibility. - Handle gaps explicitly. A missing or incompatible helper required by the reconciled contract keeps its dependent action/gate open: report the missing capability and continue independent authorized work. Never borrow an executable from another revision silently. If the selected contract permits an unsupported-capability fallback, record that fallback without claiming activation. Offline or unavailable Git/network access does not require an update: use locally verifiable material when it satisfies the intended pin. If intent, freshness evidence or required files cannot be verified, report the exact missing ref/provenance/capability, keep dependent gates open and continue independent authorized work. Do not silently substitute an older or unproven source, or claim it current.
Source identity and freshness do not grant authority or replace target-repository policy. Preserve every applicable gate, branch/source ownership rule and separate merge/credential authorization; selecting an older source is not permission to bypass those requirements.
Terminal goal and entry contract
An unqualified /prw (/pr-workflow) defaults to driving the PR to FINAL_READY across all applicable gates under one continuous session goal, unless the user explicitly requests an earlier milestone. Intermediate checkpoints (opening draft, pushes, initial approval, undrafting, stage labels) are not task completion; merge authority remains separate. For canonical completion and exit conditions, follow pr-lifecycle. Apply six-stage.md title and label rules only when the target repository explicitly opts into that workflow.
Start sequence (in this order, in the first turn unless a bootstrap gap keeps a step open):
- Complete the discovery bootstrap above.
- Make the single goal-activation decision below and print its
Goal:line before the first PR-mutating action. - Capture
accepted_at(UTC time the task was accepted) in the task context; copy it unchanged into the execution record when that record is first written, never substituting PR creation time. UseUNKNOWNwhen acceptance was not observed, and keep the original value on resume. - Preflight the route and record it in the execution record: the selected route and the evidence kind each claim needs under evidence standards (for example video for an interaction claim); the coverage each source vote's
COVERAGE:must show before it counts (static-review § Scope: the complete diff and every changed path at both revisions); and the votes required, with each candidate seat's account and current availability from a timestamped probe or quota hint (never a review dispatch), counting each eligible separate cold seat once (advice § Identity). If available eligible seats cannot fill the quorum, report that now with theUNAVAILABLElines and earliest reset; the gate stays open and independent work continues; once every seat in the order of attempts has a receipt or an evidenced skip reason, pr-lifecycle's self-review fallback keeps the PR moving with final approval withheld. Recordmerge_authorizationfrom authority already in hand:authorizedonly with a quoted source that pr-lifecycle's merge authorization rule accepts (an operator statement covering merging this PR, a standing approval whose stated conditions apply, or that rule's tier needing no human approval, citing the tier and counted delta); a request to drive the PR or general goodwill never counts. Only when none applies, ask once whether merge is authorized and recordnot authorized, ornot askedwhen the question cannot be posed; continue without waiting and update the record if an answer arrives.authorizedis required for the final step to merge and waives no gate or other merge-authority check; without it the run ends atFINAL_READYunmerged and reports that, without a separate stop to ask. Redo the route preflight when the route changes; retain applicable authorization and re-evaluate its conditions against the current candidate.
Carry the advice candidate roster and attempt report into orchestration delegates' task briefs (not cold reviewer prompts), including authorized backups and the remaining dispatch budget. Record the reason for each unattempted candidate; a health check is not a review launch.
- Name the earliest unmet obligation and start it in the same turn; for an opted-in six-stage repository, a newly created draft gets its current stage label then.
- Automatic native goal activation: When
/prwstarts, detect capability through the supported CLI interface (native goal tool/API when available, or cmux-goal when hosted in cmux) and activate or reuse one task-scoped native session goal throughFINAL_READY; never revive a goal the user cleared, paused, or stopped. Detailed activation rules (supported/absent, already-active, user-cleared/stopped protection, unsupported fallback, and verified persistence) are canonically owned by pr-lifecycle's terminal goal contract. This is the only activation decision; current aliases do not set goals, and activation an older alias already attempted is handled by the bootstrap (inspect actual state, never replay). Decide it once, after the bootstrap source/authority resolution and before the first PR-mutating action (read-only inspection and clause probes may come first). Compose a one-line condition (no backslashes)<repo> PR <N> at <the endpoint the user requested, default FINAL_READY>, or stopped with the exact blocker only the user can clear; an earlier or read-only endpoint such as "stop after Stage 0" replaces FINAL_READY. A runtime with a native goal tool uses it. For a selected revision that requires cmux-goal'sbin/self_goal.py set(tmux and cmux hosts), first apply the bootstrap provenance/compatibility checks, then run only the verified compatible helper from that revision in isolated mode (python3 -I <verified helper path> set ..., so the target repository's cwd andPYTHON*environment cannot inject modules) and print its observedGoal:line verbatim. Never assume a helper exists at an intentionally older pin. - Endpoint lanes and waiting: In Claude Code, run an endpoint lane as a top-level session so it can own its goal and long-lived jobs. Background commands owned by a foreground subagent end with that subagent's run (runtime documentation). Use subagents for bounded work, not unattended endpoint ownership.
- With a verified active goal on interactive Claude Code 2.1.236 or later, start long jobs in the background and yield only after independent authorized work is exhausted. The runtime defers goal evaluation while work runs and delivers completion as a new turn. Its default check-ins back off from 30 minutes to 1 hour and then 2 hours; versions 2.1.246 onward cap idle check-ins at three until the next user message.
CLAUDE_CODE_GOAL_CHECKIN_MINUTES=0disables check-ins (goal behavior). Check-ins do not replace a job timeout, deadline or completion receipt. - On another runtime, an older version, or without verified goal activation and completion delivery, retain foreground ownership through the supported wait API. Do not spin in polling/sleep loops. At completion or check-in, read the actual result before dispatching more work; if a process disappeared, inspect outputs and side effects. Retry at most once only when safely repeatable and within the original budget; otherwise record the exact blocker and continue independent authorized work. Never replay an uncertain send or mutation blindly.
One operational contract
Before selecting a branch, stage, or gate, inspect the target repository's AGENTS.md, CLAUDE.md, and scoped instructions. Local repository instructions take precedence within their domain. Where local instructions are silent, apply the canonical pr-lifecycle completion loop.
Repository overlay. Then load the repository's PR overlay, if any: .claude/pr-overlay.md read from the PR's actual base ref (for example git show origin/<base>:.claude/pr-overlay.md), so a PR cannot loosen its own rules; if the PR edits the file, the base version still governs. If there is none, use the operator overlay at ${XDG_CONFIG_HOME:-$HOME/.config}/jleechan-skills/pr-overlays/<owner>/<repo>.md when it exists. An overlay is plain Markdown with up to three headings:
## Proof route: how this repository produces behavior proof;## Preview:required,opportunisticornone;## CI: which stages wait on remote CI, and when a slow required check is replaced by the local-equivalent record.
Precedence, highest first: target AGENTS.md/CLAUDE.md, then the repository overlay, then the operator overlay, then the shared defaults. Either overlay may relax a repository rule only by quoting the operator instruction that grants the exception, with its date and where it was given (session, PR comment or message), so a reviewer can trace it. If the PR's reviewer cannot locate the cited message, the grant counts for nothing. A repository overlay's grant counts once it has merged through the repository's normal review. An operator overlay's grant lapses when a repository overlay lands. Otherwise the repository rule wins. In the PR's stage or execution record, name the overlay and its commit or file hash, and copy verbatim every repository rule it relaxed and the grant quoted for it.
Verify ownership and exact branch
- Read target repository
AGENTS.md/CLAUDE.md, current user scope, existing PR, and source-owner/hold records. Reconcile with any sole writer before writing to prevent competing updates. - Verify actual head repository, head branch, head SHA, and base from live PR metadata:
gh pr view <N> --json url,headRefName,headRefOid,headRepository,baseRefName. Inspect remotes, local status, and upstream; a similarly named branch or a log grep is not source binding.
- Fetch the verified branch using the existing authorized remote. Work in the incumbent checkout or an explicitly coordinated isolated worktree; preserve dirty state and unrelated changes.
- Never use hard resets, force-pushes, deleted branches, or discarded work as routine verification; this skill grants none of those actions and no new writer. Re-read remote head before publication; unexpected remote movement requires reconciliation, not overwrite.
- For upstream mechanics and branch tracking verification, follow git-branch-tracking.
Per-PR execution ownership
The persistent driver owns the single native session goal under the
manager's start contract. Each PR-specific task objective belongs in its worker
brief and execution record, not in a separate subagent native goal.
For every accepted PR, create a row in the existing execution record and name
at least one execution subagent. Give it a PR-specific task objective, primary
obligation, candidate SHA, permitted actions, and expected artifact. This task
objective is an assignment brief, not a requirement to activate a separate
native goal for the subagent. Use one writer per branch and retain independent
review roles.
Follow review-records
for per-PR execution, verified waits, and failure recovery.
A worker assignment or acknowledgment does not prove start. Confirm a start from
an observed task-scoped action or verified live job against the PR revision.
Keep the driver accountable until execution ownership is observed and recorded.
If a worker fails to start or exits, inspect its output and side effects,
then take the next bounded safe action as driver or recover on an eligible host.
Prefer the current host when it has task-specific headroom. For a host-specific
blocker, measure the alternate host and use /lm for Mac-to-Linux or /mac-mirror
for Linux-to-Mac portable work when that route is eligible; verify the worker's
actual start on the intended PR SHA. Apply the existing safe-retry limit and
never loop on assignments, polls, or sleeps. Record an exact blocker, owner,
next action, and real resumption trigger when work cannot start. A wait or
failure on one PR does not gate intake of independent PRs.
Practical publication guidance
Apply these compact defaults where explicit repository instructions are silent; existing global merge/push safety remains canonical:
- First branch push: Verify target and upstream tracking (
git push -u <verified-remote> HEAD), following git-branch-tracking. - Same-repository PR creation: Verify head and base repositories are identical, then bind explicitly:
gh pr create --repo <verified-base-owner/repo> --draft --base <verified-base> --head <verified-branch>; in a repository that opts into six-stage, also pass --label <current stage label> so the draft is labeled at creation. If that fails (missing label or permission):
1. Check whether the failed call already opened the PR: gh pr list --repo <verified-base-owner/repo> --head <verified-branch> --base <verified-base> --json number,headRefOid,isCrossRepository,baseRefName, accepting only a same-repository match into the verified base whose headRefOid equals the pushed SHA (--head matches branch names only, so a same-name fork PR is not ours).
2. Create without the label only if no such PR exists, then apply it with gh pr edit <that PR number> --repo <verified-base-owner/repo> --add-label <current stage label>.
3. If labeling still fails, record the label as missing in the readback, keep label sync open for the next transition, and continue rather than stalling.
- User-owned fork PR creation: Use the same explicit
--repoand--basewith--head <verified-head-user>:<verified-branch>. If a tool cannot express the exact head repository (such as GitHub CLI fork or organization limitations), use an already-authorized capable interface or report the precise blocker; never guess from a same-name branch. - After-create readback: Read back both repository identities, head/base branches, head SHA and, for six-stage repositories, the stage label before updating or claiming the intended PR.
- Existing PR updates: Scoped commit and ordinary push only through the PR's sole writer; re-read remote head SHA immediately afterward to verify publication.
- Missing upstream repair: Verify the remote branch, then configure tracking:
git branch --set-upstream-to=<remote>/<branch>. - Connector updates: Connector authorized expected-head non-forced updates and exact readback are distinct from native Git upstream; do not treat connector publication as establishing native Git upstream tracking.
Autonomous execution and boundaries
Drive the PR through the pr-lifecycle completion loop, which owns route selection, gate order, obligation records, asynchronous work, evidence applicability and final claim-to-proof checks. Load six-stage.md stage rules only when the target repository opts into that workflow; its evidence publication section applies to every PR under the selected route. Load the relevant on-demand routing/recovery references when their decisions are needed. Open new PRs as drafts; undraft only after its applicable draft gates pass, except an early undraft under the preview-deploy exception when a repository's preview workflow (e.g. a GCP preview gated on non-draft PRs) must run to produce evidence. The self-review fallback is the other case: once every seat in the order of attempts has a receipt or an evidenced skip reason and the source votes are still short, undraft after every other draft gate passes.
Headless PR owner (`--nudge`)
/pr --nudge <PR> hands execution to a headless PR owner under pr-owner-nudger: resolve the jleechan-skills source checkout holding scripts/pr_nudger_round.py, verify or create a dedicated checkout on the PR head branch, write the per-PR scope from the PR's /ironclad contract, run scripts/pr_nudger_round.py enroll with the chosen --cli (codex or agy) and --model, start the first tick with scripts/pr_nudger_round.py retry-now --kick, and turn the current session into the independent Stage 5 verifier rather than writing on the branch. /pr --nudge --stop <PR> retires the target via scripts/pr_nudger_round.py retire. Enabling dispatch (enabled: true) and merging stay with the operator.
Boundaries
Creating or updating a PR does not authorize merge, deployment, credential changes, new quota, native/account operations, schedule changes or another owner's source work. Merge authority remains repository/user-specific and must be satisfied separately. Stage title and label presentation follows six-stage.md only when the target repository explicitly opts into it; every PR follows six-stage.md's evidence publication contract and review-records, including the selected route's exemptions. Stage-specific exit records apply only to opted-in repositories; shared publication requirements do not adopt stage titles or labels.