Brifing

Taming the Beast: AI-Generated Pull Requests with Stacked Reviews

Revolutionize code review with GitHub's stacked pull requests approach

The GitHub Blog3 min

1The Double-Edged Sword of Development

For years, developers have faced a dilemma: create one massive pull request that's painful to review or split it into smaller chunks requiring manual synchronization. Gartner predicts AI tools will boost software development productivity by 50% by 2028. However, these tools don't eliminate pull request structure decisions - they make them more critical than ever.

2Anatomy of a Monolithic PR

A typical single pull request for adding product search to a shopping assistant includes: new data model and seed data, API route with validation, client wiring, UI components, and empty/fallback/error states - all in a 1000+ line diff file. AI agents trained on traditional coding patterns default to this delivery method, creating review nightmares.

3The Review Vicious Cycle

Reviewers facing 1721-line changes often respond with 'I'll review this later,' creating delays. Large PRs lead to context loss, poor feedback quality, and ultimately under-reviewed merges. This triggers manual conflict resolution and time-consuming processes before features land in production, often with compromised quality.

4Stacked PRs: A Structural Solution

Stacked pull requests transform delivery through logical decomposition. Instead of solving entire features at once, they create small, focused layers following dependency chains. GitHub's native stacked PR support manages this structure through both UI and CLI (gh stack), enabling independent review of each logical component while maintaining natural context flow between layers.

5Layered Architecture Example

Product search feature implemented in 4 layers: L1 (feat/catalog-data) - Core catalog data structure and access module, L2 (feat/search-api) - /api/products/search endpoint, L3 (feat/chat-grounding) - API-integrated chat functionality, L4 (feat/grounded-ui) - Product cards and state management. Each layer demands different reviewer expertise: data engineers, API specialists, and UI experts.

6AI Agent Stack Discipline

The gh-stack CLI extension (npx skills add github/gh-stack) trains AI agents in stacked PR creation. In our example, specialized agents handle each layer: data modeling for L1, backend for L2, and frontend for L3/L4. This enforced discipline guarantees small, single-concern pull requests that are easier to review and maintain throughout the development lifecycle.

7CI's Pivotal Role

In stacked PR management, each layer's CI checks run against the stack base (typically main branch). GitHub's native support automatically propagates changes upward through the stack, enabling early conflict detection. Consistent CI across all layers ensures stability while allowing parallel development streams to progress independently yet coherently.

8Data Layer Implementation

The foundational layer (feat/catalog-data) establishes type-safe catalog structure, seed data, validation rules, and data access modules. Reviewed by data owners, this layer provides the robust foundation for subsequent API and UI layers. AI agents here focus exclusively on data structure without contamination from presentation concerns.

9API Layer Integration

The second layer (feat/search-api) implements the validated /api/products/search endpoint. Backend agents concentrate solely on API contracts here. Reviews focus on design principles and performance optimizations. Successful implementation at this layer dramatically simplifies client integrations in upper layers.

10UI Layer Optimization

The final two layers (feat/chat-grounding and feat/grounded-ui) shape user experience. Layer three integrates chat with real product data while layer four implements product citation cards and state management. UI specialists review these layers for user flows and visual consistency, benefiting from the clean separation of concerns.

11Revolutionary Efficiency Gains

Stacked pull requests revolutionize AI-assisted development, reducing code review times by up to 60% while decreasing error rates and boosting team productivity. Expected to become standard practice by 2028, this method will prove indispensable for teams leveraging AI agents in large-scale projects, fundamentally changing how we manage complex code changes.

Original article: The GitHub Blog — Devlerin Kabusu: Yapay Zeka ile Pull Request Yönetimi