DevOps/CI-CD

Feature Flags

Feature flags are conditional switches in code that enable or disable functionality at runtime without deploying new code, decoupling deployment from feature release.

What is Feature Flags?

Feature flags are conditional switches in code that enable or disable functionality at runtime without deploying new code, decoupling deployment from feature release. Also called feature toggles or feature switches, they allow teams to merge incomplete features to main branch behind a flag, gradually roll out changes to user segments, and instantly kill problematic features without rollback. LaunchDarkly, Unleash, and Statsig are popular feature flag management platforms.

How does Feature Flags work?

Feature flags wrap new functionality in conditional checks that evaluate at runtime. The flag's state — on or off — is determined by a central configuration service that can target specific users, percentages, geographies, or custom attributes.

When code encounters a feature flag check, it queries the flag service (typically with local caching for performance) and executes the appropriate code path. This evaluation happens per-request, enabling real-time changes without redeployment.

Flag management platforms provide dashboards for toggling flags, setting targeting rules, and scheduling activations. They also track flag lifecycle — creation, testing, full rollout, and removal — preventing technical debt from accumulating. SDKs handle evaluation logic client-side with minimal latency overhead, falling back to default values if the flag service is unreachable.

Progressive rollouts use percentage-based flags to gradually increase exposure: 1% for initial validation, 10% for broader testing, then 100% for general availability.

Why does Feature Flags matter?

Feature flags reduce deployment risk by separating code shipping from feature activation. Teams can deploy daily while controlling exactly when users see changes. For AI products, flags enable safe model version rollouts — serving a new model to 5% of users, monitoring quality metrics, then expanding if results meet thresholds without any infrastructure changes.

Best practices for Feature Flags

  • Establish a flag lifecycle policy with expiration dates to prevent permanent conditional complexity in code
  • Use feature flags for operational kill switches on dependencies that may degrade under load
  • Implement flag-level audit logs to track who changed what and when for compliance requirements
  • Limit long-lived flags to operational concerns and remove release flags within two sprints of full rollout
  • Test both flag states in CI to ensure the off-path remains functional when flags are toggled

About the Author

Aaron is an engineering leader, software architect, and founder with 18 years building distributed systems and cloud infrastructure. Now focused on LLM-powered platforms, agent orchestration, and production AI. He shares hands-on technical guides and framework comparisons at fp8.co.