Cloud & DevOps Trending

What Are Feature Flags and How Do Teams Use Them?

How feature flags work, the 4 main types teams use, and the cleanup habits that stop old flags turning into risky technical debt.

Quick answer

Feature flags are switches in your code that turn a feature on or off at runtime without a new deployment. Teams use them to ship unfinished work safely, roll features out to a few users first, run A/B experiments and switch off broken features instantly. The catch is cleanup: old flags pile up as technical debt unless you remove them.

What Are Feature Flags and How Do Teams Use Them?

Photo: Unsplash

On this page

Your team finished a big feature on Tuesday, but marketing wants to announce it next month. Meanwhile, 5 other changes are waiting to ship. Do you hold everything back, or maintain a long-lived branch that gets harder to merge every day?

Feature flags solve this. They let you deploy code to production with the new feature switched off, then turn it on whenever you choose, for everyone or just a few users. Used well, they make releases calmer and rollbacks almost instant. Used carelessly, they leave a trail of forgotten switches that can cause serious bugs.

This guide explains how feature flags work, the main ways teams use them, and the habits that keep them from becoming debt.

What a feature flag actually is

At its simplest, a feature flag is a conditional in your code whose value you can change without redeploying. The OpenFeature project, an open standard for feature flagging hosted by the Cloud Native Computing Foundation, describes a flag as an if/else statement that can be controlled at runtime.

if (flags.isEnabled("new-checkout", user)) { showNewCheckout(); } else { showOldCheckout(); }

The value usually comes from a flag service or configuration store rather than being hard-coded. Most flag systems are also context-aware: the decision can depend on who the user is, which country they are in, which plan they pay for, or a random percentage bucket.

You will also hear feature flags called feature toggles, feature switches or release toggles. They all mean the same basic idea.

Deploy is not the same as release

The biggest benefit of feature flags is that they separate 2 events teams often treat as one:

  • Deploy: putting new code onto production servers
  • Release: letting users actually see and use the new behavior

Without flags, deploying is releasing. With flags, you can deploy many times a day with features hidden, then release on your own schedule. That makes practices like trunk-based development and continuous deployment much safer, because unfinished work can live in the main branch, switched off.

Key takeaway: Feature flags let you decouple deploying code from releasing features. That one change makes it possible to ship small changes often, release gradually and turn off problems in seconds, as long as you remove flags once they have done their job.

The 4 main types of feature flags

Not all flags are the same. Treating them differently is the first step to keeping them under control. The open source flag platform Unleash, for example, categorizes flags by purpose and gives each type an expected lifetime.

Flag type What it is for Typical lifespan Example
Release flag Hide unfinished or unreleased features, then roll them out Short: days to weeks Turn on the new checkout page for 10% of users
Experiment flag A/B or multivariate tests to compare versions Short: length of the experiment Test 2 pricing page layouts
Operational flag or kill switch Turn off a feature or degrade gracefully under load or failure Some short, kill switches often permanent Disable recommendations if the service slows down
Permission or entitlement flag Control access by plan, role or customer Long-lived or permanent Show advanced reports only to Pro customers

Unleash’s defaults suggest about 40 days for release and experiment flags, 7 days for operational flags, and no expiry for kill switches and permission flags. Your numbers may differ, but the principle holds: most flags should be temporary.

Release toggles

Release flags are the workhorse. Developers merge code behind a flag that is off by default. When the feature is ready, the team turns it on for internal staff, then a small percentage of customers, then everyone. If error rates rise, they turn it off without a rollback or hotfix.

This gradual rollout is similar to a canary deployment, but it happens at the feature level inside a single deployed version. Our comparison of blue-green vs canary deployments covers the infrastructure-level equivalents.

Experiments

Experiment flags randomly assign users to variants and record which variant each user saw. Combined with analytics, they let product teams measure whether a change actually improves sign-ups, conversion or engagement. The flag is only half the job here. You also need a clear metric, enough traffic, and a decision rule set before the test starts.

Kill switches and operational flags

Operational flags give on-call engineers a fast way to reduce load or shut off a misbehaving feature during an incident. A kill switch on a non-essential feature, like personalized recommendations, can keep the core product running when a dependency fails. These flags are worth testing regularly, because a kill switch nobody has flipped in a year may not work when you need it.

How teams roll out a feature with flags

A typical release with feature flags looks like this:

  1. Create the flag with a clear name, owner, type and planned removal date. Default it to off.
  2. Wrap the new code in the flag check, keeping the old path working.
  3. Merge and deploy to production as normal through your CI/CD pipeline. Users see no change.
  4. Turn it on internally for staff or test accounts and check behavior in production.
  5. Roll out gradually, for example 1%, then 10%, then 50%, watching errors, latency and business metrics at each step.
  6. Go to 100% once you are confident.
  7. Remove the flag and the old code path, then delete the flag from your flag system.

Step 7 is the one teams skip. That is where flag debt begins.

Flag debt: the hidden cost

Every flag adds a branch to your code. Two flags create 4 possible combinations, and 10 flags create over 1,000. Tests rarely cover them all. Old flags also confuse new engineers, who cannot tell which paths are still live.

The worst case is a forgotten flag that gets reused or flipped by mistake. The best-known example is Knight Capital. According to the US Securities and Exchange Commission’s 2013 order, Knight left unused code called Power Peg in its trading system for years, and new code deployed in 2012 repurposed a flag that had formerly activated it. The new code reached 7 of 8 servers. On the eighth, the repurposed flag triggered the old logic. The SEC says Knight sent more than 4 million orders in about 45 minutes and lost over $460 million.

Not every stale flag will cost that much, but the lesson is clear: dead code behind a flag is still code that can run. Our guide to technical debt covers how small shortcuts like this compound over time.

Cleanup habits that prevent flag debt

Teams that use flags heavily build cleanup into the process, not into good intentions.

Habit How to do it
Give every flag an owner The person or team who created it is responsible for removing it
Set an expiry date at creation Record when the flag should be gone, based on its type
Use clear, unique names Include the feature and type, and never reuse an old flag name
Create the removal ticket up front Open the cleanup task when you create the flag, not after launch
Track stale flags Many flag tools mark flags past their expected lifetime as potentially stale
Cap active flags Some teams limit how many temporary flags a team can have at once
Remove code before deleting the flag Delete the flag check and the old code path first, then archive the flag
Review flags regularly Add a short flag review to sprint retros or monthly maintenance

Unleash, for instance, automatically marks flags as potentially stale once they pass their expected lifetime and warns against reusing names of deleted flags, because old code may still reference them.

Build or buy a feature flag system

You can start with a configuration file or environment variables, but that only works for simple on and off switches. Once you need percentage rollouts, user targeting, audit logs and instant changes without restarts, most teams use a dedicated tool.

Option Good for Watch out for
Config file or environment variables 1 or 2 simple switches Needs a redeploy or restart to change; no targeting
Homegrown flag service Teams with unusual needs and spare engineering time You build and maintain targeting, UI, audit and SDKs yourself
Open source flag platforms (such as Unleash or Flagsmith) Teams wanting control and self-hosting You run and secure the service
Commercial SaaS (such as LaunchDarkly) Teams wanting managed targeting, experiments and governance Ongoing subscription cost; vendor dependency
Built into your platform (such as GitLab feature flags or AWS AppConfig) Teams already on that platform Feature depth varies by product

The OpenFeature standard offers a vendor-neutral API, so your application code calls one interface while the provider behind it can change. That reduces lock-in if you later switch tools.

Where to start

  1. Pick one upcoming feature and put it behind a single release flag.
  2. Agree on a naming and ownership convention before you create a second flag.
  3. Choose a tool that matches your scale. A config-based switch is fine for a first trial; move to a flag service once you need gradual rollouts.
  4. Add flag removal to your definition of done so a feature is not finished until its temporary flag is gone.
  5. Measure the effect. Track deployment frequency and change fail rate with DORA metrics to see whether flags make releases safer.

Conclusion

Feature flags are one of the simplest ways to make releases less stressful. They let you ship small changes continuously, test with real users, and turn off problems instantly. Their only real downside is the debt they leave behind, and that is a habit problem, not a tooling problem. Give every flag an owner and an end date, and they stay an asset.

Sources

Questions readers ask

Frequently asked questions

What is a feature flag in simple terms?

A feature flag is an on and off switch inside your software that controls whether a feature is active, without needing to deploy new code. Developers wrap new code in a condition, and the flag's value comes from a settings service. Teams can then turn the feature on for everyone, nobody, or selected users at any time.

What is the difference between a feature flag and a feature toggle?

There is no real difference. Feature flag, feature toggle, feature switch and release toggle are different names for the same technique: a runtime condition that turns functionality on or off. Some teams use "toggle" for simple on and off switches and "flag" for systems with targeting, but the terms are generally interchangeable.

Are feature flags a security risk?

They can be if misused. Flags that are evaluated in client-side code can reveal hidden features, so never rely on a client-side flag to protect sensitive functionality or data. Restrict who can change flags in production, keep an audit log, and remove stale flags, because old flags can accidentally reactivate outdated code.

How long should a feature flag stay in the code?

Temporary flags should be removed soon after they reach 100% or the experiment ends, often within weeks. Unleash's default expected lifetime is about 40 days for release and experiment flags and 7 days for operational flags. Kill switches and permission flags can be permanent, but they should still have a named owner.

Do I need a paid tool for feature flags?

No. You can start with a configuration file, environment variables or an open source platform such as Unleash or Flagsmith. Paid tools add managed hosting, advanced targeting, experimentation and governance features. Choose based on how many flags you run, whether you need percentage rollouts, and how much infrastructure you want to maintain.

How are feature flags different from A/B testing?

Feature flags are the mechanism; A/B testing is one use of it. A flag decides which version a user sees. An A/B test adds random assignment, a defined success metric and statistical analysis to learn which version performs better. Many flag platforms include experimentation features, but you can use flags without running experiments.

What is flag debt?

Flag debt is the build-up of old feature flags and their unused code paths that were never removed. It makes code harder to read and test, and stale flags can be flipped or reused by mistake, triggering outdated behavior. Prevent it by giving each flag an owner and expiry date and removing the code once a rollout is complete.

Reader reviews

Was this guide useful

No reviews yet. Share your experience and help other readers.

Write a review
Your rating
Never shown publicly

Reviews are checked before they appear. We never show your email. Please review only places or services you have used.

Manishdai
Written by

Manishdai

Manishdai writes about the technology that is reshaping every industry — from AI agents and cloud platforms to healthtech, fintech and the IT companies building it all across the United States.