Trunk-Based Development: Why Feature Flags Make It Actually Work
Long-lived feature branches feel safe. They're not. Every day a branch sits open, it drifts further from main — and every merge is a small gamble that compounds into a big one.
The Real Cost of Branch-Per-Feature
Most teams reach for a feature branch by reflex. It feels like isolation — your work stays contained while the rest of the team moves on. But after a week or two, that branch is a different codebase. Rebasing becomes archaeology. PRs balloon to 2,000 lines. Review quality drops. Conflicts appear in the worst places.
Trunk-based development (TBD) solves this by keeping everyone integrated. Engineers commit small increments directly to main — or at least merge short-lived branches within a day or two. The integration cost is paid continuously, in seconds, rather than in a single painful merge session.
The objection is always the same: "What if we push unfinished work to main and it breaks production?" That's the right question. Feature flags are the right answer.
Flags as Branch Replacements
A feature flag is a branch in your code, not in your VCS. The incomplete feature ships to production, wrapped in a condition that keeps it invisible until it's ready. Your CI pipeline stays green. Main stays deployable. No one else is blocked.
The pattern is straightforward. Using the Featureflow JavaScript SDK:
import featureflow from 'featureflow-client';
const client = featureflow.init('YOUR_API_KEY');
// Wrap incomplete work — ships to prod, stays dark
if (client.evaluate('new-checkout-flow').isOn()) {
renderNewCheckout();
} else {
renderLegacyCheckout();
}The flag defaults to off. Every engineer on the team can pull the latest main, deploy it, and the incomplete checkout flow is just dead code — until someone in Featureflow turns it on. No branch. No merge conflict. No deploy freeze while someone finishes a feature.
The Discipline That Makes It Stick
TBD with flags only works if you treat flags as temporary. Every flag is a debt entry: it must either graduate to permanent config or be removed once the rollout is complete. Teams that skip this step accumulate flags nobody dares touch — which is ironically worse than long-lived branches.
Three rules that keep it clean:
- Name flags after the feature, not the ticket.
new-checkout-flowages better thanJIRA-4821. - Set a removal target date when you create the flag. Put it in the description field. Make it a ticket.
- Review open flags monthly. Any flag older than 90 days with no recent targeting change is a candidate for cleanup.
Featureflow's flag management dashboard makes this easy — you can see creation dates, last-evaluated timestamps, and targeting rules at a glance. Get started at featureflow.com.
Trunk-based development isn't about bravery — it's about discipline. Feature flags are the tool that makes the discipline sustainable. Ship small, integrate constantly, and keep every unfinished feature dark until it's genuinely ready.
The teams who do this rarely have 2am merge nightmares. They also tend to ship a lot faster.
#TrunkBasedDevelopment#FeatureFlags#ContinuousDelivery#DevOps#CI
Ship to main with confidence
Start free with Featureflow — feature flags that keep trunk-based development safe and fast.
Start Now (Free)Related Articles
Feature Flags for Mobile Apps: Ship Without Waiting on App Store Review
App store reviews take days. Bugs don't wait. Feature flags let mobile teams ship code continuously, gate features remotely, and kill broken behaviour — without a new release.
Feature Flags and Observability: How to Know If Your Rollout Is Working
Releasing to 10% of users without watching metrics is just gambling at a smaller scale. Here's how to connect flag evaluations to your observability stack — so you know when to expand, and when to pull back.
Feature Flags for Customer Targeting: Roll Out Features to the Right Users
Percentage rollouts control how many users see a feature. Targeting rules control which users see it — by plan tier, beta opt-in, org ID, or any attribute you pass. Here's how to use them.