Shipping AI-Generated Features as Stacked PRs: A Complete Spec Kit + gh stack Tutorial
A step-by-step guide to pairing spec-driven development with stacked pull requests — from specify init all the way to a fully merged feature. Why this tutorial exists AI coding agents are fast. Dangerously fast. Point an agent at a feature request and ten minutes later you're staring at a pull request with 180 changed files. Nobody reviews that. It sits for days, goes stale, and gets merged with…
This tutorial offers a comprehensive guide to integrating spec-driven development with stacked pull requests using Spec Kit and gh stack tools. Developed for an e-commerce team building payment features, the setup ensures each feature is broken down into small, manageable pull requests with each containing no more than 100 files.
This approach prevents large, unreviewable pull requests from being merged, instead promoting a review/merge workflow that takes a stack of small, reviewable PRs from open to merged state. The setup requires several prerequisites like GitHub CLI, valid authentication, Git, uv, and an AI agent like Claude. Once prerequisites are met, a fresh project is set up using the Spec Kit, and the project is initialized with the AI agent.
A key gate is created to ensure each stack unit does not exceed 100 changed files, which is verified before pushing any changes or running gh stack. The agent is then instructed to follow a strict contract regarding the formation of a stacked PR, including file caps, branching strategy, and merge order. The tutorial also covers creating a spec file for the feature, planning the feature as a stack, and grouping tasks under units with clear exit definitions.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.