Treat Feature Flags as Managed Code, Not Permanent Switches

Treat Feature Flags as Managed Code, Not Permanent Switches

Feature flags let a team deploy code without immediately exposing its behavior to every user. That flexibility supports gradual releases, experiments, and emergency shutdowns. It also adds system complexity because every active flag creates another decision for developers, testers, and operators to understand.

Flags serve different purposes

A feature flag is a runtime decision that determines whether part of an application is enabled. Microsoft describes feature flags as a way to separate feature release from code deployment. Teams can target selected users, roll out a feature gradually, or change its availability without rebuilding the application (Microsoft Learn).

That flexibility does not make all flags equivalent. Pete Hodgson separates them into categories such as release toggles, experiment toggles, operations toggles, and permissioning toggles. A release toggle may exist only while a team integrates unfinished work. An experiment flag may remain active long enough to produce useful results. An operations flag may be permanent when it serves as an emergency control for a high-cost or optional feature (Hodgson, 2017).

Before adding a flag, record its category and purpose. That information helps the team decide who should control it, how often to review it, and whether to remove it later.

Every flag needs an owner

Once a flag has a purpose, assign responsibility for maintaining it. A flag without a named maintainer can leave cleanup work to whoever happens to notice it. LaunchDarkly recommends assigning responsibility for groups of flags and including flag cleanup in the workflow’s definition of done. Keep ownership visible in the repository or flag-management system rather than in team memory (LaunchDarkly).

Temporary flags also need an expected end date. Hodgson recommends storing useful metadata such as a description, primary contact, creation date, and expiration date for short-lived toggles. An expiration date does not make the flag disappear automatically. Instead, it creates a visible review point before a temporary design becomes part of the permanent architecture.

Names should describe intent instead of implementation. A name such as checkout-new-tax-calculation tells a future maintainer more than flag-17. Clear descriptions also help during incidents, when an operator may need to decide whether disabling a flag will remove a useful feature or protect the service from additional load.

Test both sides deliberately

Ownership and metadata make a flag easier to manage, but they do not make its code safe. Flagged code has at least two important states: enabled and disabled. Both states need automated coverage. Hodgson notes that teams must test the code paths that may be enabled or disabled in production. A test suite that checks only the default state can allow the inactive path to decay until a rollout or emergency switch exposes it (Hodgson, 2017).

Microsoft says a code path can be reactivated when a flag is cleared, so it needs testing and maintenance until the flag is removed. This matters especially for flags that remain in production after a feature is fully rolled out. If the old path is no longer required, deleting the flag and its unused code is safer than preserving an untested branch (Microsoft Learn).

Tests should also cover flag evaluation boundaries. If a flag uses an external service, verify behavior when its configuration is unavailable, delayed, or inconsistent. Otherwise, a configuration problem could become an application-wide failure.

Clean flags on a schedule

Testing must continue only as long as the flag remains necessary. Flag cleanup is a normal engineering task, not optional housekeeping. When a feature reaches all intended users, remove temporary flag checks, delete dead code, and archive the corresponding configuration. LaunchDarkly says a feature is ready for cleanup when it is fully rolled out or an experiment has ended. Leaving the flag in place preserves unnecessary branches and makes future changes harder to reason about.

Microsoft recommends monitoring usage and system-health metrics during incremental exposure. LaunchDarkly recommends regular monthly or quarterly review cycles and says quarterly archiving is a general best practice. It also warns that a flag should not be archived merely because it appears inactive (LaunchDarkly).

A practical team policy is to make flag removal part of the original feature work. LaunchDarkly says a team can create a second pull request for removing a flag when the first pull request adds it. This connects removal to the feature instead of asking a future team to rediscover why the flag exists.

Keep flags out of configuration

Careful ownership and cleanup do not make feature flags suitable for every setting. They are not a replacement for secrets management, general configuration, or a database. LaunchDarkly advises against using them for credentials, database hosts, API URLs, or large structured data. Flags work best when they represent a small number of meaningful product or operational decisions.

The long-term practice is simple: use flags to control change, then remove short-lived flags when the change is complete. Keep only the permanent controls that have a clear operational or product purpose, and review those controls as the system evolves.

References

  1. Hodgson, P. (2017, October 9). Feature toggles (aka feature flags). Martin Fowler. https://martinfowler.com/articles/feature-toggles.html
  2. Microsoft. (n.d.). Progressive experimentation with feature flags. Microsoft Learn. https://learn.microsoft.com/en-us/devops/operate/progressive-experimentation-feature-flags
  3. Microsoft. (n.d.). Understand feature management using Azure App Configuration. Microsoft Learn. https://learn.microsoft.com/en-us/azure/azure-app-configuration/concept-feature-management
  4. LaunchDarkly. (n.d.). Reducing technical debt from feature flags. LaunchDarkly Documentation. https://launchdarkly.com/docs/guides/flags/technical-debt