Delivery & Operations

Feature Flag

Also known as: feature toggle, flag

Definition

A feature flag is a runtime switch that changes behaviour without a deploy, separating release from deployment. Code ships dark, is enabled for a subset of users, and can be turned off in seconds — which makes rollback a configuration change rather than a redeploy.

Last reviewed · Part of the Architecture Glossary

In practice

Flags are not one thing, and conflating the kinds is what makes them rot:

KindLifetimeOwner
Release toggleDays to weeks — delete after rolloutThe shipping engineer
Experiment flagThe length of the experimentProduct / data
Ops toggle (kill switch)PermanentOn-call
Permission / entitlementPermanentProduct — this is not really a flag, it is a feature of the plan model

Hygiene that keeps the count sane: an expiry date on every release toggle, a CI check that fails on flags older than 90 days, and removal of the flag in the same pull request that makes the behaviour permanent.

Testing matters more than teams expect. Two flags produce four code paths; ten produce a thousand. Test the combinations that will actually ship — current production state and the target state — and treat the rest as a reason to keep the flag count low.

When it matters

Trunk-based development, incremental migrations, risky changes to a hot path, and anything where the business wants to choose the launch moment.

Common mistake

Leaving them in. A codebase with 200 live flags has 200 untested branches and no one who can say what the production configuration means. Deleting a flag is part of shipping the feature, not a cleanup task for later.

See also

Go deeper