What is feature flagging and how to use it
· Category: DevOps & CI/CD
Short answer
Feature flags are conditional code branches controlled by external configuration. They let you hide incomplete features from users, run A/B tests, and instantly disable a buggy feature without a code deployment.
Details
At its simplest, a feature flag is an if (flagEnabled) check around new code. Managed services like LaunchDarkly, Unleash, or Flagsmith provide UI dashboards, targeting rules, and analytics. Flags can be boolean, multivariate, or audience-targeted. They are essential for trunk-based development and continuous deployment because they allow long-running features to be merged early.
However, feature flags add technical debt if not cleaned up. Establish a policy to remove flags once a feature is fully rolled out. For the deployment pipeline that supports frequent releases, see How to set up a CI/CD pipeline with GitHub Actions. If you are rolling out gradually, How to implement canary releases pairs naturally with flag-based targeting.
Tips
- Keep flag checks close to the entry point of a feature rather than scattering them throughout the codebase.
- Use a consistent naming convention and expiration date for every flag.
- For testing flag states, how to use async/await can help when fetching flag configuration from a remote service at startup.