Stacking PRs (GitHub + CodeRabbit)
Knowtis uses GitHub's gh-stack extension for stacked PRs and CodeRabbit for automated first-pass review.
Workflow
- Branch with a Conventional prefix:
feat/<name>,fix/<name>,docs/<name>. - Install the extension once with
gh extension install github/gh-stackifgh stackis unavailable. - Build a tracked stack with
gh stack init <bottom-branch>,gh stack add <next-branch>, andgh stack submit --auto --open, or adopt existing PRs withgh stack link <bottom> … <top>.linktakes PRs or branches bottom-first, creates no local tracking, and only adds membership. - Keep every PR under 100 changed files; CodeRabbit refuses larger reviews. Check with
git diff --name-only <base> <head> | wc -lbefore opening. - Trigger CodeRabbit with
@coderabbitai full reviewand confirm inline comments exist. A green check without comments can mean the review was skipped; fair-usage failures must be retried after the named window. - Address all review feedback before human review.
- Merge with an explicit target, for example
gh stack merge <pr-number> --yes, then rungh stack synclocally. Never manually rebase a stacked branch after GitHub merges and retargets a layer. - Detailed context lives in the PR description; commits stay single-line.
Gotchas
gh stack viewneeds local tracking; afterlink, rungh stack checkout <stack-number>first.gh pr editis broken on this repo (deprecated GraphQL field). Change bases and bodies withgh api repos/<owner>/<repo>/pulls/<n> -X PATCH --input -.- Deleting a branch that is the base of an open PR auto-closes that PR, and GitHub then refuses both a base change and a reopen. Run
gh pr list --base <branch>before deleting anything. - Verify
gh auth statusshows the intended account before every write.
Rules of thumb
- A PR that mixes a refactor with a behavior change should be split into a stack (refactor below, behavior on top).
- Do not merge a middle layer independently; use the stack-aware merge flow.
- CI must be green per-PR;
nx affectedkeeps each stack level cheap.