github

Turn one giant AI-generated pull request to a reviewable stack (opens in new tab)

Coding agents can rapidly produce complete features, but they often deliver them as enormous, shallow pull requests that are difficult to review and slow to merge. GitHub’s stacked pull requests address this by decomposing a feature into small, dependency-ordered layers. The result is a reviewable chain of changes that preserves context while reducing maintenance and merge conflicts.

The Problem with Giant AI-Generated Pull Requests

  • A seemingly simple product-search feature may include:
    • A data model and seed data
    • An API route and validation
    • Client integration and UI states
  • Coding agents commonly generate all of this in a single 1,000-plus-line pull request.
  • Large pull requests:
    • Become difficult to review thoroughly
    • Cause reviewers to lose context
    • Receive lower-quality feedback
    • Take longer to merge
    • Are more likely to land under-reviewed

Traditional alternatives are also imperfect: one large pull request harms reviewability, while a manually maintained chain of smaller pull requests creates synchronization work and conflict-management overhead.

Stacked Pull Requests

  • Stacked pull requests break a feature into logical, dependent layers.
  • Each pull request focuses on one concern and remains small enough for reviewers to understand.
  • Later layers build naturally on earlier, already-reviewed work.
  • Different layers can be assigned to specialized reviewers, such as data or UI owners.

For the product-search example, the proposed stack is:

  • L1 – feat/catalog-data: Typed catalog, seed data, validation, and data access; based on main
  • L2 – feat/search-api: Validated /api/products/search endpoint; based on L1
  • L3 – feat/chat-grounding: Connects chat to the API and real product data; based on L2
  • L4 – feat/grounded-ui: Adds product citation cards and UI states; based on L3

Setting Up the Stack

  • Choose the stack base first, because CI checks and merge rules are evaluated against it.
  • Place foundational work closest to the base and dependent work above it.
  • Install GitHub’s CLI extension:
gh extension install github/gh-stack
  • Teach coding agents how to create and manage stacks:
gh skill install github/gh-stack

Alternatively:

npx skills add github/gh-stack
  • Ensure CI is configured, since every pull request layer is checked against the stack base.

Assigning Agents to Layers

The example uses separate agents with strict scope boundaries:

  • L1: Data modeler agent
  • L2: Backend agent
  • L3: Frontend agent
  • L4: Frontend agent

This division encourages each agent to produce a focused pull request rather than reconstructing the entire feature in one pass.

Recommended Workflow

The development process starts with the foundational catalog layer and proceeds upward through the dependency chain. Agents work autonomously within their assigned scope, while each completed layer can be reviewed independently before subsequent layers are evaluated.

Stacked pull requests are a practical way to preserve the productivity benefits of coding agents without sacrificing review quality. Teams should define clear layer boundaries, establish the stack base, assign appropriate reviewers or agents, and run CI for every layer.