| name | stacked-mr |
| description | Autonomous AFK mode: build a stack of owner-scoped PRs/MRs, then batch-review them to the bar. Human merges. Use on /stacked-mr or 'stack PRs'. |
/stacked-mr — Stacked PR/MR Pass
Builds a stack of PRs/MRs without reviewing each one immediately, then runs a
batch review pass at the end. The canonical owner, knowledge, artifact, and
follow-up contract is
docs/workflow/agent-process.md.
Stack Shape
main
-> 0012-first-ticket PR #1 base: main
-> 0013-second-ticket PR #2 base: 0012-first-ticket
-> 0014-third PR #3 base: 0013-second-ticket
Each PR/MR diff is against its parent branch. The human merges bottom-up.
Merging caution (learning 0002): squash-merging the stack in a tight
loop races GitHub's retargeting — children get auto-closed when a parent
branch is deleted, or merge INTO the parent instead of main. Before each
merge, wait until the PR's baseRefName is main and it is MERGEABLE
(or retarget it explicitly with gh pr edit N --base main). See
docs/learnings/0002-stacked-squash-merge-race.md.
Phase 1 — Build Stack
For each runnable ticket:
- Pick the next
now / next ticket by priority within the requested scope.
- Confirm exactly one owner agent. If work needs multiple owners, split into
linked tickets before building.
- Set status
in-progress.
- Run the knowledge phase from
docs/workflow/agent-process.md.
- Branch from the current stack tip.
- Implement TDD-first and commit.
- File owner-scoped follow-up tickets for deferred work.
- Run local smoke checks and inspect the diff.
- Push the feature branch.
- Open a PR/MR with base set to the parent branch.
- Link the PR/MR URL into the ticket and update the stack ledger.
Do not run the code-review agent during this phase except for explicit
trust-critical escape hatches.
Phase 2 — Batch Review
- Refresh forge state for every PR/MR in the ledger.
- Run one
code-review agent pass per PR/MR in isolated worktrees.
- Collect verdicts and review artifacts.
- Fix
request-changes branches, re-review only affected PRs/MRs, and restack
children with --force-with-lease to feature branches only.
Phase 2.5 — Joint MR digest (human read surface)
The per-MR reviews above are the automated merge gate. They are not a human
read surface — a human would still open N diffs. Produce ONE combined
/digest over the whole stack so the human reviews the
batch once. Because each MR is stacked on the previous, the stack tip already
contains the union of the batch — the joint diff is free.
- Open one joint MR,
base=main, source = the stack-tip branch, as a
draft labeled do-not-merge:
glab mr create --target-branch main --source-branch "$STACK_TIP" --draft \
--label do-not-merge \
--title "[BATCH] <scope> — joint review (do not merge)" \
--description "Combined read surface for !#A..!#N. Members merge individually, bottom-up."
Record its number as $JOINT and the member MR numbers.
- Run the
code-review agent once on the joint MR (full main...stack-tip
diff). That same codex session also emits the /digest patch — no extra
model run. Around it run the deterministic digest stages with
--joint "<member-csv>" (see /digest Stages 1 + 3).
- The joint review's verdict is informational — the member MRs' own reviews
stay the merge bar. Surface the joint digest; the human reads it once, then
merges the stack bottom-up.
The joint MR is never merged. Close it when the stack has fully landed (it's a
draft + do-not-merge; a future merge-sync extension can automate this).
Continue Conditions
- Runnable scoped tickets remain: keep building.
- True human-only blocker: file HITL and continue another lane.
- PR/MR cannot reach the bar after reasonable cycles: mark the ticket
stuck
with the artifact path and continue independent work.
- Scoped backlog exhausted: finish batch review and summarize.
Summary Format
Stack of N PRs/MRs, merge bottom-up:
#1 0012-first-ticket base: main approve / tests pass
#2 0013-second-ticket base: 0012-first-ticket request-changes
Include PR/MR URLs, ticket ids, owners, bases, verdicts, test status, HITL
items, delegated artifact paths, and follow-up tickets.
Hard Rules
- Never merge.
- Every PR/MR reaches the review bar before final handoff.
- Force-push only feature branches and only with
--force-with-lease.
- TDD-first for every implementation ticket.
- Batch reviews run in isolated worktrees.
- The joint MR is draft +
do-not-merge — a read surface only. Never merge it,
never let it gate the member MRs.