InsightsDevOps
Feature flags with an owner and an expiry date
How to keep feature flags from turning into permanent, untested branches. Separate the flag types, give each an owner and a removal date, evaluate through a vendor-neutral API, and delete flags as routinely as you create them.
Published November 5, 20265 min read
Feature flags are easy to add and rarely removed. Each one is a branch in production code that tests do not cover in both directions, and a runtime switch that can change behavior without a deploy. A year in, a service has dozens of flags, nobody remembers which are live, and a flag flipped during an incident has effects no one predicted.
The fix is not fewer flags. It is treating each flag as something with a purpose, an owner and an end date.
Four kinds of flag
Most trouble comes from managing all flags the same way. They differ in how long they live and who changes them.
| Type | Purpose | Lifetime | Who flips it |
|---|---|---|---|
| Release | Merge unfinished work, then turn it on | Days to weeks | The feature team |
| Experiment | Compare variants for a metric | Weeks | Product and the feature team |
| Ops | Shed load or disable a costly feature during an incident | Long, sometimes permanent | On-call engineers |
| Permission | Enable a capability for a plan or customer group | Permanent | Product, or an entitlement system |
Release and experiment flags are temporary by design, so they need a removal date. Ops flags are permanent, so they need a runbook entry and a test. Permission flags are really business data, and often belong in your entitlement model rather than in a flag system.
Record the type in the flag's name or metadata. A flag named checkout-new-tax-engine says nothing about whether it should exist next quarter.
Give every flag an owner and an expiry
When a flag is created, require three fields:
key: checkout-new-tax-engine
type: release
owner: team-checkout
created: 2026-11-05
remove-by: 2026-12-03
description: Routes tax calculation through the new engine.The remove-by date is the important one. It turns "we will clean this up later" into a visible commitment. A scheduled CI job can list flags past their date and open an issue for the owning team:
checkout-new-tax-engine release team-checkout overdue by 12 days
search-ranking-v2 experiment team-search overdue by 3 daysDo not fail builds over overdue flags. That teaches people to extend dates without looking. A report that lands in the owning team's backlog gets acted on far more reliably, and a quarterly review can look at what remains.
Evaluate through a vendor-neutral API
Calling a flag vendor's SDK directly from business code makes switching providers a refactor across every service. OpenFeature is an open specification for flag evaluation with SDKs in many languages. Application code talks to the OpenFeature client, and a provider connects it to whichever flag system you run:
import { OpenFeature } from '@openfeature/server-sdk'
const client = OpenFeature.getClient('checkout')
export async function renderSummary(order: Order, user: User) {
const useNewTax = await client.getBooleanValue(
'checkout-new-tax-engine',
false,
{ targetingKey: user.id },
)
return useNewTax ? renderWithTaxEngine(order) : renderLegacy(order)
}Three details are worth getting right:
- The default value is your failure mode. It is what the code uses when the flag system is unreachable or the flag does not exist. For a release flag it should be the old, proven behavior. For an ops flag that disables a feature, it should be the safe state under load.
- The targeting key identifies the subject. The specification describes it as an optional identifier, such as a user or service, which some providers need for percentage rollouts and overrides. Without it, such providers may behave unpredictably, so pass it whenever you roll out gradually.
- Provider and application are set up once. Register the provider at startup with
OpenFeature.setProvider(...)and create clients per component.
flagd is an open-source OpenFeature-compliant evaluation engine that reads flag definitions from files, HTTP endpoints, Kubernetes custom resources or gRPC services. It has no UI or persistence layer of its own, so it suits teams that want flags managed as code in Git. Hosted products are the alternative when non-engineers need to change flags through a console. Either way, the application code above does not change.
Make flag changes observable
A flag flip is a production change. If it is not visible next to deploys, the first question in an incident, "what changed?", gets the wrong answer.
OpenFeature hooks run at defined stages of an evaluation: before, after, error and finally. An after hook is a natural place to record which value was served:
import type { Hook } from '@openfeature/server-sdk'
export const flagTelemetry: Hook = {
after(hookContext, details) {
metrics.increment('flag_evaluations_total', {
flag: hookContext.flagKey,
variant: details.variant ?? String(details.value),
})
},
error(hookContext, err) {
logger.warn({ flag: hookContext.flagKey, err }, 'flag evaluation failed')
},
}Register it once with OpenFeature.addHooks(flagTelemetry). Be careful with cardinality: flag keys and variants are bounded, but user IDs are not, and must never become metric labels.
Also send flag changes to the same place as deploy events, whether that is an annotation on dashboards or an entry in the change log your on-call engineers read. A canary release analysis is easier to interpret when a flag change is not hiding among the variables.
Removal is part of the work
A release flag is finished when the feature is on for everyone and the code path is gone. Make removal a normal task:
- Turn the flag on for 100% and leave it for a full release cycle.
- Delete the flag check and the dead branch in one pull request. Tests for the old path go too.
- Delete the flag definition afterwards, not before. Removing the definition first makes running instances fall back to the default value, which may be the old behavior.
- Close the tracking issue.
Put the removal ticket in the same sprint as the feature, not in a backlog. Creating it when the flag is created, with the remove-by date as its due date, is the cheapest way to keep it from being forgotten.
Limits on combinations
Flags interact. Two independent flags give four combinations, ten give over a thousand, and nobody tests them all. Keep the number manageable:
- Prefer flags that guard one self-contained path over flags that change behavior in many places.
- Avoid one flag depending on another. If it cannot be avoided, document the dependency in both definitions.
- Cap the count of live release flags per team. A cap of a handful makes the cost of a new flag visible.
- Do not use a flag to hide a risky database change. Schema changes need the expand-and-contract approach, because a flag cannot be rolled back across data that has already been rewritten.
What changes
Flags go back to being what they were meant to be: a short-lived way to separate deploying from releasing, plus a small set of well-tested emergency switches. Incidents are easier to read because every flip is recorded. Changing flag provider becomes a configuration task rather than a rewrite. And the codebase stops accumulating branches that nobody dares delete.