Trunk-Based Development: The Path to Continuous Delivery
Trunk-Based Development#
The Alternative to Feature Branches#
Most teams use feature branches. Developers create a branch, work in isolation for days or weeks, then open a pull request and merge back to main.
This feels safe. You can’t break main while working in isolation. But isolation creates its own problems.
Trunk-based development inverts this approach. Developers commit to main frequently—multiple times per day. Branches are short-lived (hours at most) if they exist at all.
This sounds risky. How do you prevent broken code in main?
The answer is the same practices that enable safe trunk-based development also prevent breaks: continuous integration, feature flags, and rigorous testing.
Why Trunk-Based Development Works#
Reduced Merge Conflicts#
The longer you work in a branch before integrating, the greater the chance of conflicts. Your changes diverge from others’ changes, creating merge conflicts when you finally integrate.
Trunk-based development eliminates most conflicts. You integrate before significant divergence occurs.
Early Problem Discovery#
When you commit to main frequently, integration problems surface immediately. If your code breaks the build, you know in minutes, not days.
This is better than discovering in code review that your changes don’t integrate well.
Knowledge Sharing#
Frequent commits to main mean everyone sees what everyone else is doing. Code review still happens (either pre-commit via pair programming or post-commit), but the work is visible immediately.
This creates natural knowledge sharing. New approaches get noticed and adopted quickly.
Continuous Deployment#
Trunk-based development enables deploying main to production at any time. When you merge to main is when code becomes deployable. This enables rapid feedback from production.
With feature branches that exist for weeks, main is frozen while branches are in flight. Production is blocked until the branch is done.
Psychological Safety#
Frequent commits create lower stakes around each commit. You’re not making a huge change that needs perfect review. You’re making a small, focused change that can be adjusted quickly if needed.
This creates psychological safety. People aren’t afraid to commit because the impact of any single commit is limited.
The Data: DORA Metrics#
The DORA (DevOps Research and Assessment) research measured thousands of development teams and correlated practices with performance.
Trunk-based development is one of the strongest correlations with elite performance:
- Elite performers: Commit to main multiple times per day
- High performers: Commit to main daily
- Medium performers: Commit weekly
- Low performers: Commit monthly or less
Elite performers are 160% more likely to use trunk-based development than low performers.
This isn’t correlation without causation. Trunk-based development creates the practices that enable rapid, safe deployment.
Enabling Trunk-Based Development#
Trunk-based development requires:
1. Continuous Integration#
Automated tests run on every commit. If tests fail, the commit is rejected.
Without CI, trunk-based development would mean frequent commits of broken code. With CI, commits only succeed if they pass tests.
2. Feature Flags#
Not all code reaching main should be active. Feature flags allow code to be in main but not enabled for users.
New features are hidden behind flags. Once they’re tested and ready, the flag is toggled.
This decouples deployment (pushing code to main and production) from release (enabling features for users).
3. Comprehensive Testing#
You need confidence that code reaching main doesn’t break existing functionality. This requires:
- Unit tests for individual components
- Integration tests for subsystem interactions
- End-to-end tests for critical user flows
- Smoke tests in production
Testing is the safety net that makes trunk-based development safe.
4. Code Review (Different Form)#
You still need code review, but it happens differently:
- Pair programming: Review happens while code is being written
- Post-commit review: Code is in main, reviewers look at it immediately and can request changes (fixed in next commit)
Post-commit review sounds chaotic, but with feature flags, the code is safe even if review finds issues. The feature is off; it won’t affect users.
5. Discipline#
Not every development team is ready for trunk-based development. It requires:
- High quality automated tests
- Agreement on code standards
- Willingness to review code quickly
- Comfort with continuous deployment
Teams that cut corners on these enablers run into problems with trunk-based development.
Common Concerns#
”Won’t we deploy broken code to production?”#
Feature flags decouple deployment from release. You deploy code but don’t enable features for users until they’re verified. Production stays safe.
Without feature flags, this is a legitimate concern. With them, it’s not a problem.
”What about long-running features?”#
Long-running features that take weeks to develop don’t fit the trunk-based model well.
The solution is breaking the feature into smaller, deployable increments. Instead of “implement new dashboard,” break it into “add dashboard data collection” (deploys, feature off) → “build dashboard UI” (deploys, feature off) → “enable dashboard” (deploys, feature on).
Each increment is small and testable. It reaches main and production frequently without being user-visible until the full feature is ready.
”What about coordinated releases?”#
If you have multiple teams that need to coordinate releases, trunk-based development makes this easier, not harder.
All teams commit to main continuously. When release time comes, you deploy the current state of main. No scrambling to merge branches at the last minute.
Adopting Trunk-Based Development#
Start with a pilot team#
Have one team try trunk-based development with strong CI/CD and feature flags. Measure:
- Deployment frequency
- Lead time for changes
- Mean time to recovery from failures
- Merge conflict frequency
Build confidence through tooling#
Invest in CI/CD infrastructure. Automated testing. Feature flag systems. These are prerequisites, not optional nice-to-haves.
Establish code review discipline#
Whether through pairing or post-commit review, establish that code review is fast-tracked. Code sits in main for hours before review, not days.
Measure and adjust#
Track metrics. How often are commits reverted? Are production issues increasing? Is team velocity improving?
Use data to tune your approach.
Misconceptions#
Trunk-Based Development Doesn’t Mean No Branches#
Developers often work in short-lived branches (hours, not days). The point is frequent integration, not literally committing to main every time.
Trunk-Based Development Isn’t Reckless#
With proper CI/CD, testing, and feature flags, trunk-based development is safer than feature-branch isolation that delays integration.
Trunk-Based Development Isn’t For Everyone Yet#
Some organizations aren’t ready due to insufficient testing infrastructure or organizational constraints. That’s okay. The trajectory is toward trunk-based development as the norm.
The Future#
Elite-performing organizations already use trunk-based development. As CI/CD tooling improves and organizations mature, adoption will spread.
The combination of trunk-based development, feature flags, and rigorous testing creates the conditions for rapid, safe deployment.
Conclusion#
Trunk-based development is a practice that separates elite-performing organizations from the rest.
It requires investment in CI/CD and testing infrastructure, but the payoff is enormous: rapid deployment, fewer merge conflicts, better knowledge sharing, and higher team morale.
If your organization is stuck with long-lived feature branches and monthly deployments, try trunk-based development. Start with one team. Invest in the infrastructure needed to make it safe.
You’ll likely find that the fearless deployment it enables is worth the investment.