Skip to content
Muhammet Şafak
tr
3 min read

Feature Flags: Ship the Code, Open the Feature Later

Separating deploy from release: opening and closing features safely with feature flags, gradual rollout, and the discipline of flag cleanup

TL;DR

A feature flag separates deploy from release: code enters the main branch behind a closed flag, and the decision to turn it on comes later, without a deploy. That buys small merges, gradual rollout and an instant kill switch. The price is that every flag left in place after it has done its job turns into technical debt, so each flag needs an owner and a removal condition.

Row of four toggle switches labeled DEPLOY, ROLLOUT, CLEANUP and FEATURE beside a blank paper tag

A feature lived on its own branch for weeks. Every day it drifted a little further from the main line. By the time the merge finally came due, it had become a frightening pile of conflicts nobody wanted to touch.

Had the same feature sat behind a feature flag, the code could have entered the main branch every day — dormant, off, but merged. That is the first problem a feature flag solves.

Deploy ≠ release

The two are often treated as one, but they are distinct:

  • Deploy — the code reaching the server.
  • Release — the feature becoming visible to the user.

A feature flag separates the two. The code ships to production but sits behind a flag, off. The decision to turn it on is made later, independent of the deploy.

What it buys you

This separation brings a few concrete things:

  • Small, frequent merges. A feature can enter the main branch half-finished, with the flag off. The long-lived branch and its conflict nightmare disappear.
  • On/off without a deploy. Turning a feature on or off no longer needs a new deployment — a flag value is enough.
  • Gradual rollout. Open the feature to 1% of users first, watch, and if nothing breaks, raise it to 10%, then 100%.
  • An instant kill switch. If a feature behaves unexpectedly in production, you silence it by flipping the flag off instead of waiting for a rollback.

Gradual rollout

Gradual rollout is the most valuable use of a feature flag. Instead of opening a new feature to all users at once, you open it by percentage or user segment. At each step you look at the metrics — error rate, latency — and if nothing is wrong, you raise the share.

This is a canary running at the application layer: you move the risk onto a small slice rather than the entire user base.

A flag is technical debt

Now the other side of the coin. A feature flag turns into technical debt if it isn’t deleted once its job is done.

Because every flag is a branch in the code: if flag then new path else old path. Even after a feature is 100% on, that else branch stays in the code — dead, but still read, still tested, still demanding maintenance. Dozens of stale flags turn into a forest of branches that make the code more complex than it needs to be.

The discipline of flag cleanup

So every flag should have an owner and an expiry condition. Once a feature is 100% on and stable, the job is done: delete the flag and the dead branch it guarded.

List your flags somewhere — which one went live when, when it gets cleaned up. A flag that’s never cleaned up creates a new problem as large as the one it solved.

Don’t overdo it

Not every change needs a flag. A small, low-risk fix can ship directly. Save the feature flag for features that are risky, large, or need a gradual rollout. Otherwise, in the name of separating deploy from release, you fill the code with hundreds of needless flags.


A feature flag turns the release into a non-event by separating deploy from release. But the price of that separation is the promise to close every flag you open.

Deleting a flag on time is as much a part of the work as opening it.

Related

Comments

Sign in with your GitHub account to join the discussion. Comments are stored in GitHub Discussions.

Search the site

Start typing to search posts, projects and pages.

Esc to close Powered by Pagefind