Skip to content
tezvyn:

How do feature flags enable unfinished work in Trunk-Based Development?

Source: travis-ci.comMediumHow cards are made

How do feature flags enable unfinished work in Trunk-Based Development?
Summary

Using feature flags to integrate unfinished work in main while keeping it hidden.

Key points

Commit behind off flags; CI/CD deploys trunk continuously; flags gate exposure for gradual rollouts.

What's really being asked

This question probes whether you understand the core tension in Trunk-Based Development: integrating code frequently without releasing unfinished work. The interviewer wants to see that you can separate deployment mechanics from user-facing release decisions, and that you know how feature flags fit into a continuous CI/CD pipeline rather than acting as a band-aid for poor branching strategy.

The full answer

Four specific things in order. First, the developer workflow: engineers working on multi-week features still merge to main daily or multiple times per day, but wrap new code paths in feature flags that default to off in production. Second, the CI/CD interaction: the pipeline builds and deploys main continuously, treating every commit as production-ready because the dormant flag hides incomplete behavior; automated tests run against both flag states where needed. Third, runtime behavior: the application evaluates flags at request time using a flag service or config, so the same binary serves both old and new code paths without separate artifacts. Fourth, release progression: when the feature is complete, the team enables it for internal users, then a small percentage of traffic, then full rollout, with the ability to instantly disable via a kill switch if errors spike.

The mistakes people make

Three red flags stand out. One, suggesting long-lived feature branches as the primary mechanism; this contradicts TBD and reintroduces merge conflict pain. Two, claiming feature flags let you skip tests or merge broken code; the trunk must always be green, and flags require testing both on and off states. Three, confusing flags with separate deployment environments; staging is not a substitute for integrating to main, and flags live in production code, not in branch isolation.

What usually comes next

The interviewer may ask how you handle flag cleanup and technical debt, since stale flags clutter the codebase; expect to discuss time-bombing flags or mandatory removal tickets. They might also ask about testing strategy, specifically how to test flag combinations without exponential blowup, or how to manage flag consistency across microservices. Another angle is operational risk: what happens if the flag evaluation service fails, and how do you default safely.

A concrete example

Imagine a team adding a new recommendation engine that takes six weeks. Instead of a branch, they merge the data model in week one behind flag RECOMMENDATIONS_V2 set to false. The CI/CD pipeline deploys this to production ten times per day with no user impact. In week three they add the API layer, still behind the flag. In week six they enable it for 5 percent of users, monitor latency and error rates, then ramp to 100 percent over two days. If latency jumps by more than 50 milliseconds, the flag reverts to false in seconds without a rollback deployment.

Interview question

How does Trunk-Based Development allow a team to continuously deploy an unfinished multi-week feature without exposing it to end users?

  • a.Merge the incomplete code to main without tests because the dormant feature flag prevents users from ever executing the broken paths.
  • b.Keep the feature on a long-lived branch until it is complete, merging to main only in the final week to avoid shipping incomplete work.
  • c.Deploy the incomplete code only to a dedicated staging environment, promoting the artifact to production once the feature is fully built.
  • d.Wrap the new code paths in a feature flag that defaults to off in production, allowing the same binary to deploy continuously while keeping the feature hidden.Correct
Why?

Feature flags that default to off let teams integrate to main daily and deploy continuously while hiding incomplete behavior from users. The long-lived branch approach in option B contradicts Trunk-Based Development and reintroduces painful merge conflicts.

Just read this? Test yourself on what you have been reading.

Read the original → travis-ci.com

You just looked this up. Could you explain it out loud?

That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles