run-spec-worktree-merge
Take a verified task pull request to merged — poll CI and review with runspec.py pr-check, run bounded review rounds through the same worker, keep the branch current by merging origin/main, merge only on verdict=ready, confirm the merge on origin/main, and clean up the task's worktree
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-10
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- run-spec-worktree-merge
- description
- Take a verified task pull request to merged — poll CI and review with runspec.py pr-check, run bounded review rounds through the same worker, keep the branch current by merging origin/main, merge only on verdict=ready, confirm the merge on origin/main, and clean up the task's worktree
- argument-hint
- <spec-name> --task N --pr P --worktree <path>
03 SKILL.md 正文
Run Spec — Review Loop and Merge
Every task's work reaches main through its own pull request, merged by the orchestrator only when GitHub, not the worker, says it is ready. This is the step that turns "the worker says it is done" into "it is done".
Input
$ARGUMENTS: the spec, the task, its pull request and the worker's worktree path (absent when resuming a pull request from an earlier run). A lifecycle pull request passes --lifecycle instead of a task.
Invocation contexts
- Slash command: runs the loop for one pull request and reports the verdict; it merges only when the person confirms (write gate) or passed
--merge. - Model-invoked: the same.
- Non-interactive: inside
/run-spec, the run's start is the pre-approval to merge its own task and lifecycle pull requests onverdict=ready. Without that context, the merge is a write gate: stop at it and return the verdict.
Steps
-
Wait for GitHub, then read it.
gh pr checks <pr> --watch --interval 30 # waits for CI; its exit status is not the verdict python3 scripts/harness/runspec.py pr-check --spec <spec> --task <N> --pr <pr>The verdict is the last line.
pr-checkrequires: the pull request open and not a draft; every check's latest run passing or skipped,CI OKandCodeRabbitpresent; zero unresolved review threads; a mergeable state that is not conflicting, behind or blocked; the task's completion entry in the pull request's owntasks.md, naming this pull request; every changed file inside the task'sFilesor named in itsSpec deviations; and no leak in the title, body or added lines (scripts/ci/check-public-hygiene.sh).- Exit 3,
verdict=unknown(a check pending, the review not posted, merge state not computed): wait and poll again. Never merge on 3. A review bot that has not started after ten minutes gets a@coderabbitai reviewcomment. - Exit 1,
verdict=not-ready: go to step 2. - Exit 0,
verdict=ready: go to step 3. - Exit 2: GitHub or git could not be read. That is missing data, not a verdict: retry, then escalate.
- Exit 3,
-
Review round. Send the
reason=lines to the same worker with the review-round template (/run-spec-dispatch). Recordreview_round. When it returns, re-run/run-specPhase 2 step 3 (verification) on the new head, then step 1 here. After three rounds that still endnot-ready, stop the run: escalation 1.behindorconflict: the worker mergesorigin/maininto its branch in its worktree (never a rebase, never a force push), re-runs its gates and pushes.- Reviewing a branch whose base trails origin/main: review the branch's own diff,
git diff <merge-base> HEADwith<merge-base>fromgit merge-base origin/main HEADaftergit fetch origin main, for scope and deletions. A tree-diff against origin/main shows other merged work as deletions the branch never made; use it only to confirm the merge result after the branch is updated. scope:for a file the task legitimately needed: the worker names it inSpec deviationswith the reason. The orchestrator passes--accept-scope <path>only for a file the spec itself sanctions elsewhere, and records why in averifyevent.leak:in the diff: the worker removes it and pushes. A credential (token,private-key) that was pushed at all stays exposed in the branch history: stop the run and have the operator revoke it. A leak in the title or body stops the run and goes to the operator: the body's edit history stays public, and agh apiwrite to the pull request is a publishing action (.claude/hooks/guard-publish.sh).
-
Merge.
git -C <worktree> status --porcelain # must print nothing: no work left behind git worktree remove <worktree> # refuses a dirty worktree; never --force past that gh pr merge <pr> --squash --delete-branch python3 scripts/harness/runspec.py verify-merged --spec <spec> --task <N> --pr <pr> python3 scripts/harness/runspec.py event --spec <spec> --kind merge --task <N> --pr <pr> --result okUnder an autonomy grant (
scripts/orchestration/autonomy.sh statusreports it live),.claude/hooks/guard-autonomy.shrefuses that merge line: record the verdict under the grant withpython3 scripts/orchestration/autonomy.py merge-check --pr <pr> --spec <spec> --task <N>(--lifecyclefor a lifecycle pull request), and merge with thegh pr merge <pr> --squash --match-head-commit <sha>it prints (add--delete-branch).verify-mergedfetches origin and requires the pull request merged, its merge commit on origin/main, and the task's entry there naming the pull request. Anything else is not a merge: record--result failand stop the run. A dirty worktree at the first command means the pushed branch is not the whole work: resume the worker to commit or discard it, then start again at step 1. -
Report
[<done>/<total>] Task N — <name>: MERGED (PR #<pr>), thengit fetch originso the next batch's workers start from the new tip.
Conflict prevention
Parallel tasks have disjoint Files by construction (/run-spec-parallel-detection). The spec files every task edits merge without conflict because each task writes only its own tasks.md block and its own seeded handoff.md section. The conflicts that remain come from a file outside the Files lists, usually one named as a deviation: the second pull request to merge picks it up at step 2 as behind or conflict.
Output
One line per pull request: PR #<pr> task <N>: merged (<merge sha>), or the verdict and reasons at the stop.
04 同仓库更多 Skills
mythhelm-deliver-backlog
Coordinate a MYTHHELM backlog run with the shared stage checks and maintainer checkpoints.
mythhelm-bootstrap
Orient a Grok Build session in the MYTHHELM repository before task or spec work.
vendor-consult
Run one advisory stage consult (premise-ground, spec-validate, task-review, change-review, stuck-oracle, dossier) with an optional external vendor, then adjudicate the answer at its anchors
update-docs
Bring README, docs/, knowledge/, WORKFLOW.md and CLAUDE.md in line with what a shipped spec or a merged change actually did — find every statement the change made stale, fix it where readers look, and add only the new facts they need
triage
Score an idea or a GitHub issue against the master spec's stages, gates and commitments, check it for duplicates, and recommend whether it becomes a backlog card; read-only
test-driven-development
Red-green-refactor for Go — use when implementing any feature, bug fix or behaviour change, before writing implementation code