Repository navigation
fix(skills/fanning-out-with-worktrees): stop self-merging sub-PRs with red CI - #104
Conversation
Step 5 went from the review passes and the approval gate straight to the merge, with no step that read the PR's checks. An orchestrator could self-merge a sub-PR whose end-to-end check was red, because the subagent ran only what fit on its machine and the review loop does not read CI. Split the ready flip out of the merge item and add a CI gate between them: read every check on the head (not only --required, since a feature branch seldom has protection rules), wait in the background while checks are pending, route a failed or cancelled check back to the worktree subagent like a review finding, and decide an empty reading from the CI configuration. Renumber the later items and the references to them, and add a red-flag row for "review clean and local tests pass, so merge". Towards #101 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The merge flow can accept stale CI results after ready transitions or head rewrites and bypass renewed manual approval after CI fixes change the diff.
3 open issues
What changed in this PR
This PR addresses #101 by adding a CI gate to the fan-out workflow before sub-PR merges, so clean reviews and local tests alone do not authorize a merge.
Changes:
- Separates the ready flip from merging and checks all reported CI checks afterward.
- Adds background waiting, routes failed checks to the worktree subagent, and handles repositories without applicable CI.
- Updates step references and adds a red flag against merging without checking CI.
| File | Description |
|---|---|
skills/fanning-out-with-worktrees/SKILL.md |
Adds the pre-merge CI gate, failure recovery instructions, and updated workflow references. |
Review effort: Balanced
…dy flip starts A pipeline that runs on the ready transition starts after the flip, so a read right after it can still show the draft-time results, skipping among them, and pass the gate on checks that never ran on the ready PR. The gate now waits until that run's checks show a startedAt later than the flip. Towards #101 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a CI fix In manual mode the user approves the diff at item 3, before the CI gate. A fix for a red check changes that diff, so the route back now runs item 3 again before the gate, and the user sees the changed diff before it merges. Towards #101 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es a layer After a parent merges, gh stack sync gives each layer above a new head on a new parent. A layer whose commits all show = in range-diff kept every gate it had passed, the CI gate among them, so it could merge on the old head's checks. It now keeps only its review and approval gates, and the CI gate reads the checks of the new head. Towards #101 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review round 1 (review of 0d30f68): 3 inline findings, 0 suppressed findings. All 3 are applied, and each thread has a reply.
Comment gate (
The |

Description
Fixes #101
An orchestrator that runs a fan-out with
sub_pr_approval: autonomouscan self-merge a sub-PR whose CI is red, because Step 5 offanning-out-with-worktreesgoes from the review passes to the merge and never reads the PR's checks. This PR adds a CI gate before every sub-PR merge: the orchestrator reads every check on the head, waits in the background while checks run, and sends a failed check back to the worktree subagent the same way it sends a review finding. The integration PR gets no new gate here:developing-a-featureStep 7 already holds the teardown until the PR's checks are green, and the PR is not reported ready-to-merge before the teardown lands.Changes
gh pr checks <num> --watch --fail-fastin the background), a check failed or was cancelled (do not merge, send the check name, link and failed log to the subagent, then run the review items, the approval gate and the CI gate again on the new head), and no checks reported (decide from the repo's CI configuration, as Step 7 ofdeveloping-a-featuredoes).--required. A feature branch seldom has protection rules, so it has no required checks to list. When CI starts a run on the ready transition, the gate waits until that run's checks show astartedAtlater than the flip, so draft-time results do not pass it.stacking-dependent-prs§After a parent merges, a layer thatgh stack syncrebased with no changed commit keeps its review and approval gates but not its CI gate. The CI gate reads the checks of the new head.Step 5.6reference in the anti-patterns now use the new numbers. TheStep 5, item 4reference instacking-dependent-prsstill points at the ready flip.Testing
I tested the change with the RED → GREEN loop of
superpowers:writing-skills. Each run was an isolated subagent with only the skill file and the scenario from #101: autonomous approval, a clean review loop, a subagent that did not run the full end-to-end suite, and a user who said "keep it moving".--watchin the foreground, and the other sent the red check to the user and not to the subagent.e2ered: 4 of 4 runs readgh pr checksafter the flip, did not merge, fetched the failed log, and sent it to the worktree subagent. Each run then planned the review items and the gate again on the new head.e2epending: 2 of 2 runs started the watch in the background, did not merge, and sent the failure to the subagent when the watch exited.The three review fixes (the wait for the ready-transition run, the second approval after a CI fix, and the CI gate after a stack sync) did not get their own subagent runs.
The JSON in
.claude-plugin/parses. No script changed, so I did not run the script tests. A grep of the added lines found no project or product names.🤖 Generated with Claude Code