Why feature flags
Decouple deployment from release. Code ships to production but is invisible until the flag is enabled. Enables: gradual rollouts, A/B testing, kill switches for risky features, and testing in production.
Types of flags
- Release flags — hide incomplete features. Removed once fully released. Short-lived.
- Experiment flags — A/B tests. Removed after experiment concludes.
- Ops flags — kill switches for performance or stability. Live indefinitely.
- Permission flags — enable features for specific users or plans. Permanent.
Evaluation
if (featureFlags.isEnabled("new-checkout", user)) {
return newCheckoutFlow(cart);
} else {
return legacyCheckoutFlow(cart);
}
Targeting rules
Enable for: specific user IDs (internal testing), percentage of users (gradual rollout), user attributes (country, plan, beta opt-in).
Preventing flag sprawl
Every flag must have an owner and a planned removal date. Stale flags are tech debt — set calendar reminders to clean up. A codebase with 200 flags is untestable.
Tooling
LaunchDarkly, Unleash (open-source), Flagsmith (open-source), or a simple Redis-backed implementation for basic needs.