GitHub Copilot’s Stacked Sessions: Turning Messy Legacy Overhauls Into Orderly PR Chains

Stacked sessions turn messy legacy refactors into orderly PR chains, making AI-assisted development more reviewable and safe.
Staircase of stacked sessions PR cards from legacy to modern code with dependencies, representing orderly PR chains.
Linked PRs staircase transforms legacy code systematically. By Andres SEO Expert.

Key Takeaways

  • Stacked sessions chain AI coding sessions, each building on the previous, and auto-generate pull requests targeting the prior branch.
  • The feature prevents monolithic pull requests by breaking large refactors into small, reviewable, and testable units.
  • This workflow reduces scope creep and improves trust in AI-generated code by keeping changes small and dependencies explicit.

How GitHub Copilot’s Stacked Sessions Turn Messy Legacy Overhauls Into Orderly Pull Request Chains

On July 30, 2026, GitHub detailed a new capability in the GitHub Copilot app—stacked sessions and stacked pull requests—that enables developers to chain multiple AI-assisted coding sessions, with each one building on the previous and automatically generating a pull request that targets the branch of the prior change. The feature addresses a chronic friction point in large refactors: the tendency to produce a single, monolithic pull request that is difficult to review, test, and merge safely. Cassidy Williams, GitHub’s senior director of developer advocacy, walked through a real-world case study of modernizing a decade-old React application to showcase how the feature turns a tangled legacy upgrade into a manageable sequence of incremental, validated steps.

How Stacked Sessions Chain AI Coding into Ordered Pull Requests

Williams’s post illustrates a common scenario: a legacy React application that accumulated technical debt over a decade, using React 15 and outdated CSS pre-processors. Her first attempt at an AI-driven overhaul failed because she was unaware of a parallel development branch with partial upgrades sitting in her repository.

After switching to that branch and producing a viable pull request for the main styling and dependency updates, she needed to replace the outdated react-bootstrap library—a task that felt like dangerous scope creep. Instead of bloating the existing pull request, she issued a prompt that set the stacking mechanism in motion.

‘Let’s make a pull request for the existing work, and then start a new session for this react-bootstrap replacement work that will branch off this existing work here, and be a separate pull request to merge into dev after this one.’

The GitHub Copilot app responded by closing the previous pull request, creating a new session that inherited the context and changes of the prior one, and then generating a stacked pull request targeting the branch of the first pull request. The GitHub Blog defines a stack precisely:

‘A stack is a series of pull requests in the same repository where each pull request targets the branch of the pull request below it, forming an ordered chain that ultimately lands on your main branch.’

This removes the need for developers to manually juggle multiple branches or rebase them later. The AI agent preserves the logical order of changes, so the react-bootstrap removal session automatically knew to build on the styling overhaul session, not on the original main branch. The resulting pair of pull requests could be reviewed, tested, and merged in sequence without conflicting with each other.

The Agentic Shift: Why Stacked Workflows Reshape AI-Assisted Development

Stacked sessions represent more than a convenience feature; they signal a maturation in how coding AI tools manage complex, multi-step tasks without overwhelming the developer. The classic risk with AI agents is the generation of a massive, single pull request that touches hundreds of files and mixes concerns, making it nearly impossible to audit effectively.

By enforcing an ordered chain, Copilot’s stacking mechanism naturally segments work into reviewable units. Each pull request can be tested independently while carrying forward the accumulated context. This approach mirrors how senior engineers manually craft a series of small, logically dependent patches. Bringing this discipline into an AI-first workflow reduces the temptation of ‘10,000-line procrastination PRs,’ as Williams calls them, and keeps scope creep in check.

For organizations looking to apply AI to legacy modernization—an increasingly common task given the longevity of enterprise codebases—stacked sessions lower the barrier to incremental, safe improvement. Rather than requiring a developer to meticulously plan every step upfront, the AI collaborator can propose and execute chained changes, with the human steering at each boundary. This blend of agency and control is likely to become a benchmark for evaluating coding assistants going forward.

Although no independent benchmarks have yet verified the efficiency gains of stacked sessions at production scale, the architectural approach addresses a core trust problem in AI-generated code: unpredictability. By keeping changes small and dependent relationships explicit, teams can conduct thorough reviews and roll back individual slices without collapsing the entire modernization effort.

From Decade-Old Codebases to Frictionless Modernization

Williams’s experience shows that a project that once seemed too painful to tackle—upgrading a personal dashboard built on React 15 and ancient Bootstrap—can become a smooth, multi-session collaboration with an AI agent that respects branch hierarchy and human decision points. The stacked pull request chain that resulted allowed her to land two separate but related improvements without a tangled merge or lost context.

GitHub’s implementation hints at a future where AI coding tools are not just answer-generating oracles but structured collaborators that understand the craft of software delivery. For engineers managing debt-laden systems, the ability to break down sweeping changes into manageable, reviewable stages may be the most meaningful productivity boost Copilot has delivered yet.

For teams and businesses looking to leverage AI-powered automation to accelerate their own technical renovation projects, Andres SEO Expert’s programmatic AI automation services bring that exact philosophy to content and SEO workflows. Connect with Andres to see how intelligent pipelines can streamline your digital initiatives, and explore Andres SEO Expert’s methodology for turning complex challenges into structured, automated victories.

Frequently Asked Questions

What exactly are stacked sessions and stacked pull requests in GitHub Copilot?

A stacked session is a new AI-powered workflow where a developer can chain multiple coding sessions, each building on the previous one. The Copilot automatically generates a pull request for each session that targets the branch of the prior change, forming an ordered chain of pull requests that ultimately merge into the main branch. This avoids monolithic, hard-to-review PRs.

How do stacked sessions help with modernizing a legacy codebase?

When upgrading a decade-old app (e.g., from React 15 and outdated CSS), a developer often faces a tangled mix of changes. Stacked sessions allow breaking the overhaul into small, incremental steps—like updating dependencies first, then replacing a UI library—each as its own pull request. The AI preserves context and branch hierarchy, so each PR can be reviewed and merged independently without conflicts or scope creep.

What problem do stacked pull requests solve for AI-assisted development?

The main problem is the tendency for AI agents to generate giant, single pull requests that touch hundreds of files and mix concerns, making them nearly impossible to audit. Stacked PRs enforce a chain of small, logically dependent changes. Each change can be tested and reviewed separately, reducing risk and making rollbacks much safer.

How does the stacking mechanism work technically in Copilot?

When you issue a prompt to start a new session that should build on existing work, Copilot closes the prior pull request, creates a new session inheriting the context and changes of the previous one, and generates a stacked PR that targets the branch of the first PR. The result is an ordered chain of PRs, each depending on the one below it, ultimately landing on the main branch.

Why is this considered an ‘agentic shift’ in AI coding tools?

Because it moves beyond simple code generation to structured collaboration. The AI now manages multi-step tasks by segmenting them into reviewable units, mirroring how experienced developers craft small, logically dependent patches. This reduces unpredictability in AI-generated code and builds trust through explicit dependency tracking and incremental validation.

Can stacked sessions be used for projects other than legacy modernization?

Yes. While the article highlights legacy overhauls, stacked sessions are valuable for any complex, multi-step feature development or refactoring. Any time you need to make a series of changes that logically build on each other—without mixing concerns or creating a tangled PR—stacked sessions keep the work organized, reviewable, and safe to merge sequentially.

Prev Next

Subscribe to My Newsletter

Subscribe to my email newsletter to get the latest posts delivered right to your email. Pure inspiration, zero spam.
You agree to the Terms of Use and Privacy Policy