Long-lived feature branches are one of the most persistent sources of pain in software development. They accumulate merge conflicts, delay integration, and create a false sense of progress — you feel productive while the branch diverges further from reality.

Trunk-based development (TBD) offers a better model: everyone commits to the main branch, and the main branch is always deployable. But this raises an obvious question — how do you develop large features without breaking production?

The answer is feature flags.

The Problem with Feature Branches

Let’s be honest about what long-lived branches cost:

  • Merge conflicts that grow exponentially with branch age
  • Integration risk that’s invisible until the branch merges
  • Delayed feedback because code isn’t tested in production until the very end
  • Review bottlenecks because 2,000-line PRs are nobody’s idea of a good time

Teams that ship weekly or bi-weekly releases often spend more time managing branches than writing features. The process becomes the product.

How Feature Flags Enable Trunk-Based Development

Feature flags let you merge incomplete work into main without exposing it to users. Here’s the workflow:

1. Create a flag before you start coding

Before writing the first line of a new feature, create a flag in your management platform. This establishes the boundary between “deployed” and “released.”

2. Wrap new code paths behind the flag

const showNewSearch = await client.getFlag('enhanced-search-v2', {
  userId: user.id,
});

if (showNewSearch) {
  return renderEnhancedSearch(query);
}

return renderLegacySearch(query);

3. Merge to main daily

Because the flag is off by default, your incomplete feature is invisible in production. You can merge every day — small, reviewable pull requests that integrate cleanly.

4. Test in production with the flag enabled

Enable the flag for your team, QA environment, or a small percentage of users. You’re testing with real data, real traffic, and real infrastructure — not a staging environment that’s three weeks behind production.

5. Roll out gradually

When the feature is ready, increase exposure from 1% to 10% to 50% to 100%, monitoring metrics at each stage.

6. Clean up the flag

Once the feature is fully rolled out and stable, remove the flag and the old code path. This is the step most teams forget — and it matters. Stale flags are technical debt.

Practical Patterns

The Strangler Pattern

Replacing a legacy system component? Use a flag to route traffic between the old and new implementations. This lets you migrate incrementally without a risky cut-over.

Feature Decomposition

Break large features into independently flag-gated sub-features. A “redesigned dashboard” might include separate flags for:

  • dashboard-v2-layout — The new grid layout
  • dashboard-v2-charts — Updated chart components
  • dashboard-v2-filters — New filtering system

Each can be developed, tested, and released independently.

Dark Launching

Deploy the new code path and enable it for internal users only. Run it in production for weeks before any external user sees it. By the time you release, you’ve already caught and fixed issues that would have been launch-day surprises.

Convention Over Chaos

Trunk-based development with feature flags only works with discipline. Establish conventions early:

ConventionWhy It Matters
Flag naming: team-feature-descriptionPrevents collisions and makes ownership clear
Maximum flag age: 30 daysForces cleanup and prevents flag sprawl
Required reviewers for flag changesPrevents accidental exposure of unfinished features
Flag-off-by-defaultEnsures new code is invisible until explicitly enabled

The Cultural Shift

The hardest part of adopting trunk-based development isn’t technical — it’s cultural. Engineers need to feel safe merging incomplete work. Product managers need to trust that “deployed” doesn’t mean “released.” And everyone needs to agree that a 50-line PR merged today is better than a 500-line PR merged next week.

Feature flags make this transition possible by providing a safety net. You can always turn it off.


ShipSilently makes trunk-based development effortless with instant flag management and sub-millisecond evaluation. Start your free account.