Stacked pull requests
Submit, review, and synchronize Workbench changes with GitHub native stacks.
Use GitHub’s official gh stack extension, including for one focused PR. Keep tests with their behavior, dependent changes in one stack, and independent changes in separate stacks.
Install and start
With Git 2.36+, GitHub CLI 2.0+, and repository push access:
gh auth login
gh extension install github/gh-stack
Update with gh extension upgrade github/gh-stack. Native stacks require same-repository branches. Official CLI reference.
Create and submit
Start with a clean worktree and local main fast-forwarded to origin/main. Fetching alone does not update local main; update it in its owning checkout. If it diverged, coordinate with its owner rather than resetting it.
bun run pr:init codex/wb-123-my-change
# Implement and verify the change.
git add <owned-files>
git commit -m "feat: describe the change (WB-123)"
bun run pr:status
bun run pr
pr:init can also adopt an existing named branch. From a tracked branch, switch to a new branch from current main before adopting independent work. Do not switch a dirty worktree or discard edits.
Stage only your owned files with git add <owned-files>, then commit before running bun run pr. That command submits committed active layers as drafts; it does not stage, commit, merge, or deploy. GitHub CI provisions hosted previews for same-repository PRs after required checks pass. Inspect the diff, title, description, and validation before bun run pr --open marks them ready.
For a dependent change, run bun run pr:add codex/next-change, implement it, and commit normally. The first PR targets main; the next targets its parent. Submission pushes every active layer in the current stack. Check git status and bun run pr:status first.
A single tracked PR gets a GitHub stack object only when a second layer exists. Verify native membership, not just chained base branches. Do not mix Graphite/custom metadata into the stack.
Link Linear tickets
Every PR needs a Workbench issue identifier in its title and an explicit relationship in its body, including drafts and every stack layer. The check accepts only Workbench’s WB-* tickets. Example title: feat: add account settings (WB-123). A branch such as codex/wb-123-account-settings helps identify the work but does not satisfy the title/body check.
Replace the PR template’s Linear comment with one of these lines, using a real ticket:
| PR scope | Body |
|---|---|
| Completes the issue’s acceptance criteria | Closes WB-123 |
| Implements part of a shared issue | Contributes to WB-123 |
| Provides context without advancing the issue | Relates to WB-123 |
Fixes, Resolves, and Refs are also accepted. A relationship can use the full Wurthy issue URL. Each identifier in the title needs its own relationship line. Links in comments, plain mentions, template comments, and fenced examples do not satisfy the check. The check validates format, not ticket existence, permissions, or acceptance criteria; confirm those in Linear during review. There are no automatic bot or maintenance exemptions.
Prefer one issue per independently scoped change. For several layers implementing one issue, put Contributes to WB-123 in the earlier layers and Closes WB-123 in the final layer. Retain the issue ID in each title. If layers instead have separate tickets, each may close its own ticket; link the broader project or parent issue separately as context. Do not mark the shared issue complete when only its first layer lands.
The Linear Issue check reruns after PR title/body edits, new commits, reopening, and marking ready for review. Its metadata-only pull_request_target workflow reads the validator from the default branch, with read-only repository permission and no dependency installation, so a PR cannot replace its own required validator. Changes to this workflow take effect after landing on the default branch; validate an introducing PR locally before enabling the requirement. Merge-group runs acknowledge prior per-PR metadata validation. To reproduce the check locally, use the CLI reference.
Keep issue identifiers in final squash titles and relationship lines in squash bodies. The intended repository settings select PR title/body for squash messages. Native stacks still use the existing submission and merge commands.
Issue lifecycle
| Event | Result |
|---|---|
Closing PR lands on main |
Merged (a started status) |
| PR merges into another feature branch | No merge status change |
| Production deployment and release reporting succeed | Done for eligible completed issues |
| Plan, preview, or failed/canceled deployment | Does not complete a production release; never moves the issue to Done |
Contributing PRs advance work without completing it. A shared issue must have no open contributing or closing PRs before it can move to Done. Plans, previews, and failed or canceled deployments do not complete a production release or move an issue to Done. Context-only relationships do not complete issues. Configure the Linear integration and production pipeline before enabling the workflow.
Update a layer
Check out the owning layer (gh stack down when appropriate), commit its fix, then update descendants:
gh stack rebase --upstack
gh stack push
gh stack top
Use gh stack rebase to incorporate current trunk changes. Resolve conflicts and stage the files before gh stack rebase --continue; use --abort to cancel. Inspect status before proceeding, and wait for fresh CI/review after changes.
Stack metadata is shared across linked worktrees. Give each stack one owner; coordinate mutations affecting others. Never stash, reset, clean, or force-push another task’s work to unblock synchronization.
Review and merge
Every layer must satisfy the bottom base’s protections:
- Green Linear Issue, Checks, React Doctor, Knip, Tests, and Build, with an up-to-date branch.
- Resolved conversations, linear history, and normally one eligible non-author approval. Changed reviewable content dismisses stale approvals.
Sriketkalone has a review-only exception. CI and all other requirements still apply; administrators have no general exemption.
Squash-merge only the approved contiguous bottom portion through native GitHub stack merging (gh stack merge --squash). Selecting a layer also includes every unmerged layer below it. Each PR produces one squash commit. Add --yes for non-interactive use. Do not use ordinary PR auto-merge or the legacy synchronous merge API for stacks.
For the named review exception, merge the bottom PR individually through GitHub’s native asynchronous API, sync, and wait for fresh checks before merging the next. The CLI does not expose the exception flag. See native merge requirements.
After merging, run bun run pr:sync --prune from a clean worktree. Verify the remaining PR’s base and diff. Preserve existing PR numbers and never close PRs or delete branches as a recovery shortcut.
Recover a stale PR base
If sync leaves the next PR targeting a merged branch:
- Confirm no affected PR is merging, queued, or set to auto-merge. Coordinate with the owner to stop concurrent merge operations.
- Run
gh stack unstack <stack-number>. Verify every intended open PR was removed from the remote stack; merged members may remain. - Retarget the new bottom PR to
main, retaining any higher layers’ order and parent branches. - Readopt existing branches bottom-first with
bun run pr:init <bottom-branch> <next-branch>(or one branch for one remaining PR). - Submit with
bun run pr, verify bases/diffs, and wait for fresh CI/review.
Production and previews
A push to main starts Production: all five checks, then Alchemy deployment. Pending migrations precede the dependent server. Keep schema changes additive and release-compatible; stack merge does not make database and app deployment atomic. Production runs serialize without cancellation, but are not a FIFO guarantee for every revision.
The standard hosted preview workflow handles PR infrastructure. Closing or merging the PR deletes its preview resources including its database branch and records, while preserving personal and production databases. Other manual deployments still require explicit approval.
After a successful production deployment, the same job records a continuous Linear release for the deployed SHA. Full history lets the release tool scan since the previous recorded release, including work from earlier failed deployments. It does not use only the current push range or branch refs. Plan runs skip reporting. A reporting failure makes the workflow fail after deployment; it does not roll back production. Repair the integration before the next authorized deployment, whose scan can catch up. Do not redeploy just to retry reporting without deployment approval.
Maintain repository settings
.github/main-protection.json and .github/repository-settings.json record intended settings; committing them does not apply them. An authorized administrator can inspect existing settings, preserve subsequent requirements, and apply the files:
gh api --method PATCH repos/CreditWurthy/workbench --input .github/repository-settings.json
gh api --method PUT repos/CreditWurthy/workbench/branches/main/protection --input .github/main-protection.json
The PUT replaces classic protection. Never weaken checks or protection to merge a stack.