Stacked PR Management
Stacked PR Management
Manage dependent PR workflows (stacked PRs) for large features requiring multiple review iterations.
Purpose
Stacked PR Management enables creating chains of dependent PRs where each PR builds on the previous one. Useful for large features that need incremental review or when working on multiple related changes simultaneously.
When to Use
- Breaking large features into reviewable chunks
- Working on dependent changes in parallel
- Iterating on features while earlier PRs are in review
- Maintaining clean commit history across multiple PRs
Core Capabilities
Stack Creation
# Create PR chain
BASE="main"
BRANCHES=("42-feature/base" "43-feature/middleware" "44-feature/ui")
for i in "${!BRANCHES[@]}"; do
BRANCH="${BRANCHES[$i]}"
NEXT_BASE=$([[ $i -eq 0 ]] && echo "$BASE" || echo "${BRANCHES[$i-1]}")
# Create PR with base as previous branch
PR_NUM=$(gh pr create \
--base "$NEXT_BASE" \
--head "$BRANCH" \
--title "Feature part $((i+1))" \
--body "**Stack:** Part $((i+1)) of ${#BRANCHES[@]}
$([ $i -gt 0 ] && echo "**Base PR:** Search previous PR")" \
--json number -q .number)
# Save to stack
addPRToStack "$PWD" "{\"pr\": $PR_NUM, \"branch\": \"$BRANCH\", \"base\": \"$NEXT_BASE\", \"children\": []}"
done
Stack Visualization
visualizeStack "$(loadPRStack "$PWD")"
# Output:
# main
# └── #42 feat/base
# └── #43 feat/middleware
# └── #44 feat/ui
Stack Rebase
# When base PR merges, rebase stack
BASE_PR=42
DEPENDENTS=$(findDependentPRs "$(loadPRStack "$PWD")" $BASE_PR)
for pr in $DEPENDENTS; do
BRANCH=$(gh pr view $pr --json headRefName -q .headRefName)
git checkout "$BRANCH"
git rebase main
git push --force-with-lease
done
Utilities
savePRStack(cwd, stack)- Save stack stateloadPRStack(cwd)- Load stack stateaddPRToStack(cwd, node)- Add PR to stackremovePRFromStack(cwd, prNumber)- Remove from stackvisualizeStack(stack)- ASCII tree visualizationvalidateStackOrder(stack)- Check for circular dependenciesgetMergeOrder(stack)- Get bottom-up merge orderfindDependentPRs(stack, prNumber)- Find all descendants
Examples
Create 3-PR Stack
# Feature split across 3 PRs
git checkout main
git checkout -b 1-feature/database
# ... make changes ...
git push -u origin 1-feature/database
gh pr create --base main --head 1-feature/database --title "Part 1: Database schema"
git checkout -b 2-feature/api 1-feature/database
# ... make changes ...
git push -u origin 2-feature/api
gh pr create --base 1-feature/database --head 2-feature/api --title "Part 2: API endpoints"
git checkout -b 3-feature/ui 2-feature/api
# ... make changes ...
git push -u origin 3-feature/ui
gh pr create --base 2-feature/api --head 3-feature/ui --title "Part 3: UI components"
Merge Stack in Order
STACK=$(loadPRStack "$PWD")
MERGE_ORDER=$(getMergeOrder "$STACK")
for pr in $MERGE_ORDER; do
# Wait for CI
gh pr checks $pr --watch
# Merge
gh pr merge $pr --squash --delete-branch
# Update base of dependent PRs
DEPENDENTS=$(findDependentPRs "$STACK" $pr)
for dep in $DEPENDENTS; do
gh pr edit $dep --base main
done
done
Best Practices
- Keep PRs small and focused
- Update PR descriptions with stack context
- Merge bottom-up (base PR first)
- Rebase dependent PRs when base changes
- Use --force-with-lease, never --force
- Validate stack with
validateStackOrder()before merge
More from constellos/claude-code-plugins
ui wireframing
This skill should be used when the user asks to "create a wireframe", "design a layout", "plan UI structure", "sketch component layout", "create WIREFRAME.md", "mobile-first wireframe", or mentions ASCII wireframes, layout planning, or UI structure before implementation. Provides mobile-first ASCII wireframe methodology for visualizing layouts before code.
6supabase local development
This skill should be used when the user asks to "start supabase locally", "set up local supabase", "run supabase dev", "initialize supabase project", "configure local database", "start local postgres", "use supabase CLI", "generate database types", or needs guidance on local Supabase development, Docker setup, environment configuration, or database migrations.
6ui interaction
This skill should be used when the user asks to "add client interactivity", "implement form validation", "add event handlers", "use client state", "add Zod validation", "implement React hooks", "add local state", "make component interactive", "add form with validation", "use React Hook Form", or needs guidance on client-side events, form handling, optimistic updates, or when to add "use client" directive.
4ui design
This skill should be used when the user asks to "create a component", "build static UI", "design with TypeScript", "use compound components", "implement contract-first UI", "create React component", "build with Shadcn", or mentions TypeScript interfaces for components, compound component patterns, or Server Components. Provides contract-first static UI methodology with compound components.
4issue management
Use this skill when the user wants to "create issue", "update issue", "add labels", "assign issue", "close issue", "link issues", or manage GitHub issue metadata. Provides comprehensive GitHub issue CRUD operations with intelligent context awareness.
3ai sdk ui
This skill should be used when the user asks to "add AI chat", "implement streaming UI", "use useChat hook", "add AI completion", "implement useCompletion", "create conversational interface", "add streaming text", "implement tool calling UI", "create generative UI", "add AI-powered features", "implement StreamableUI", or mentions AI SDK, streaming responses, chat interfaces, or AI-generated content in React/Next.js applications.
3