Mastering Stacked Diffs and Git Workflow
If you have ever felt paralyzed by a massive feature branch that has fallen weeks behind main, you know the pain of the traditional GitHub Flow. There is a better way: Stacked Diffs.
What is a Stacked Diff?
Instead of one giant branch for a feature, you break your work into a chain (or stack) of small, dependent branches.
main
└─ feature-part-1 (API changes)
└─ feature-part-2 (UI components)
└─ feature-part-3 (Integration)
You submit a Pull Request for feature-part-1. While it is being reviewed, you continue working on feature-part-2 based on feature-part-1. You do not stop. You do not context switch.
Why Stack?
- Faster Reviews: Reviewers only look at small, logical chunks of code.
- Unblocked Development: You never have to wait for a review to continue coding.
- Easy Reverts: If Part 2 has a bug, you can revert just that part without killing the whole feature.
Tooling Matters
Managing stacks manually with standard Git commands can be painful (git rebase --interactive hell). Tools like Graphite (and increasingly, native Git features) make this workflow seamless.
At MatterAI, we use stacked diffs for everything. It allows our small team to ship with the velocity of a team 10x our size.
Best Practices
- Keep stacks usually under 4-5 deep. Any deeper and managing dependencies becomes tricky.
- Merge from the bottom up. Once the bottom PR is approved and merged, rebase the rest of the stack on top of
main. - Communicate with reviewers. Let them know it is a stack so they understand the context of the changes.
MatterAI builds frontier AI infrastructure for engineering teams — from inference-optimized models to autonomous coding agents and agentic code reviews.
Explore what we're building:
- Orbital IDE — Autonomous AI coding agent with background agents and deep codebase memory
- AI Code Reviews — Agentic pre-commit reviews across GitHub, GitLab, and Bitbucket
- Axon Models — Frontier-grade reasoning models at 70% lower inference cost
Share this Guide:
More Guides
LLM Integration for AI Agents: A Complete Engineering FAQ
Everything engineers need to know about integrating, testing, and productionizing LLMs in AI agents: model selection, tool calling, structured outputs, error handling, observability, and cost optimization.
22 min readAgentic Workflows: Building Self-Correcting Loops with LangGraph and CrewAI State Machines
Build production-ready AI agents that iteratively improve their outputs through automated feedback loops, combining LangGraph's state machine architecture with CrewAI's multi-agent orchestration for robust, self-correcting workflows.
14 min readBun Runtime Migration: Porting High-Traffic Node.js APIs with Native APIs and SQLite
Learn how to migrate high-traffic Node.js APIs to Bun for 4× HTTP throughput and 3.8× database performance gains using native APIs and bun:sqlite.
10 min readDeno 2.0 Workspaces: Build Monorepos with JSR Packages and TypeScript-First Development
Learn how to configure Deno 2.0 workspaces for monorepo management, publish TypeScript packages to JSR, and automate releases with OIDC-authenticated CI/CD pipelines.
7 min readGleam on BEAM: Building Type-Safe, Fault-Tolerant Distributed Systems
Learn how Gleam combines Hindley-Milner type inference with Erlang's actor-based concurrency model to build systems that are both compile-time safe and runtime fault-tolerant. Covers OTP integration, supervision trees, and seamless interoperability with the BEAM ecosystem.
5 min readContinue Reading
LLM Integration for AI Agents: A Complete Engineering FAQ
Everything engineers need to know about integrating, testing, and productionizing LLMs in AI agents: model selection, tool calling, structured outputs, error handling, observability, and cost optimization.
22 min readAgentic Workflows: Building Self-Correcting Loops with LangGraph and CrewAI State Machines
Build production-ready AI agents that iteratively improve their outputs through automated feedback loops, combining LangGraph's state machine architecture with CrewAI's multi-agent orchestration for robust, self-correcting workflows.
14 min readBun Runtime Migration: Porting High-Traffic Node.js APIs with Native APIs and SQLite
Learn how to migrate high-traffic Node.js APIs to Bun for 4× HTTP throughput and 3.8× database performance gains using native APIs and bun:sqlite.
10 min readShip Faster. Ship Safer.
Join thousands of engineering teams using MatterAI to autonomously build, review, and deploy code with enterprise-grade precision.
