What is a feature flag (feature toggle)?
Quick Answer
A feature flag is a runtime switch that turns a piece of functionality on or off without a redeploy. It lets you merge incomplete work to main safely (it's off), release to a subset of users (canary / % rollout), do A/B tests, and kill a broken feature instantly.
A feature flag is a config switch that enables or disables functionality at runtime, no deploy needed. It's what makes trunk-based development work — I can merge a half-finished feature to main because it's behind a flag that's off. It also lets me roll a feature out to 5% of users, run an experiment, or flip a kill switch if something's on fire in production. The discipline part is cleaning up the short-lived release flags once the feature is fully rolled out, because a codebase littered with dead flags becomes impossible to reason about and test.
- Decouples deploy (code is live but dormant) from release (feature is visible).
- Types: release toggles (short-lived), experiment toggles, ops/kill switches (long-lived), permission toggles.
- .NET:
Microsoft.FeatureManagement, or a service like LaunchDarkly / Azure App Configuration. - Flag debt: remove release toggles promptly — a codebase full of stale flags is a testing and readability nightmare.