Feature flag
Also called feature toggle, feature switch.
A switch in the code that turns a feature on or off for chosen users at runtime, without deploying new code.
Last updated
What it is.
The code for a new feature ships to production hidden behind a flag. A flag service or config then decides who sees it: nobody, staff only, one customer, ten percent of users or everyone. Turning it off is instant.
Flags separate deploying code from releasing a feature. They power canary releases, A/B tests, beta programmes and kill switches for risky parts of a system.
Why it matters
Flags let teams merge and ship small changes every day, even when a feature is not finished, and let product teams choose release timing. A kill switch turns an incident into a click rather than an emergency deploy.
In a product build
We evaluate flags on the server for anything that affects security or data, give each flag an owner and a removal date, and log flag changes in the audit log. Old flags are deleted once a feature is fully released.
Common mistakes.
- 01
Never removing flags, until the code is full of dead branches.
- 02
Hiding a feature only in the front end while the API still serves it.
- 03
Testing only the flag-on path, so turning it off breaks something.
Related terms.
- Canary releaseA release method that sends a small share of users to a new version first, watches for problems, and widens the rollout step by step.
- A/B testAn experiment that shows two versions of something to random groups of users and measures which one does better on a chosen metric.
- Blue-green deploymentA release method that runs two identical production environments and switches all traffic from the old one to the new one in one step.
- CI/CD (continuous integration and delivery)An automated pipeline that builds and tests every code change (CI) and then releases it to users in a repeatable way (CD).
- Technical debtThe future cost of shortcuts taken in code today.