5 / 11 · Book 17 · Branching Strategies← prev⊞ allnext →Get the book →
1.5Trunk-Based Development in Detail
Trunk-based development takes GitHub Flow to its logical extreme. Feature branches live less than a day -- often less than a few hours. Developers commit to main frequently, often multiple times per day.
main ──****************************──── (continuous stream of small commits)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Very short-lived branches (hours, not days)
How Trunk-Based Development Works
main(the "trunk") receives commits continuously.- Short-lived branches exist only for the duration of a single code review, typically hours.
- Feature flags replace feature branches. Incomplete features are deployed behind flags, not on separate branches.
- Every commit must pass all tests. There is no stabilization period.
Implications for Testing
- Every commit must pass all tests: The pipeline must be fast and reliable. There is no "fix it later" window.
- Feature flags replace feature branches: Incomplete features are deployed behind flags, which means your tests must be flag-aware.
- Testing shifts left dramatically: QA reviews requirements and writes tests before development starts, because there is no time to catch up later.
- Flaky tests are existential threats: A flaky test that blocks
mainblocks the entire team. Fix flaky tests immediately, with the same urgency as a production incident.
When Trunk-Based Development Works
- The team has high test automation maturity (>90% of tests automated).
- CI pipeline completes in under 10 minutes.
- Feature flags are available and well-managed.
- The team has strong code review discipline.
- Engineers are experienced and disciplined about small, incremental commits.
Pro Tip: Trunk-based development is not "no branches." It is "very short-lived branches." The goal is to minimize divergence from
main, not to eliminate branches entirely.