
Feature Flags: The Field Guide
A feature flag does one thing: it separates deploying code from releasing behavior. A field guide to the surfaces you own once a flag exists — and what it costs.
TL;DR: A feature flag does exactly one thing — it separates deploying code from releasing behavior. Every property people attribute to flags falls out of that separation: trunk-based work without long-lived branches, a reversal that, when the value is read at runtime, costs a flip instead of a deploy, a slice of traffic on the new path. This guide maps the surfaces an engineer owns once a flag exists — its type, its toggle point, its targeting, its delivery, its failure default, its removal — names the two foundations everything else inherits from, and is honest about what a flag costs and what it cannot do. Including the part that is easy to leave out of the pitch: a flag is a promise to come back, and that promise is easy to break.
A flag is one idea: deploying is not releasing
Shipping code to production and exposing behavior to a person look like the same event because, without a seam between them, they are. The build goes out and the feature is live. That coupling is what makes a release a held breath.
A flag is the seam that pulls the two apart. The code arrives in production dark — deployed, running, and doing nothing anyone can see — and a separate decision, made later and by someone who may not be the author, turns it on.
Everything the mechanism is famous for follows from that one separation. Trunk-based work becomes possible because unfinished code can live on the main branch without being reachable, which means the long-lived branch and its merge are no longer the price of not shipping early. Reversal becomes cheap because the old path is still deployed, so when the value is read at runtime, going back is a configuration change rather than a build. Staged exposure becomes possible because if the decision is made per person, it can be made for some people and not others.
None of that comes from a tool. It comes from the seam. Which is why the craft outlives the tooling: there is a decision point in code, a value that reaches it, a default for when the value does not arrive, and, unless the flag is meant to be long-lived, a day the branch has to die. Those four things were true before any flag service existed and will be true after the current ones are gone.
Four types, two axes, and why the type decides everything else
The vocabulary worth using is ten years old and still fits. Pete Hodgson's feature toggles article (martinfowler.com, first published 2016, revised 2017) sorts flags into four kinds by what they are for, and the classification describes intent rather than implementation, so it does not depend on any particular generation of tooling.
A release toggle hides work that is not finished. An experiment toggle splits traffic so paths can be compared, A/B or multivariate. An ops toggle gives an operator a switch to degrade or disable behavior when the system is under stress. A permission toggle gates behavior by entitlement or cohort.
Two axes cut across those four; Hodgson considers them two big factors that can help guide how to manage toggles, alongside other factors such as who will manage the toggle. The first is lifespan (his "longevity"): how long is this flag meant to exist — days, or years? The second is dynamism: how fast must the value change — at the next deploy, at runtime, or per request against the person asking?
The reason the type matters is that it fixes the rest. It says where the toggle point belongs in the code. It says whether the value needs to travel from somewhere at runtime or can be a constant compiled into the build. It says what has to be tested. And most consequentially, it says whether the flag has a death date at all — because a release toggle that survives its release is a defect, while a long-lived kill switch (one of the few ops toggles meant to stay) that is never thrown is a lever doing its job.
Two flags can be identical in the code — a boolean and an if — and have opposite requirements. Nothing in the language distinguishes them. Only the author can, and only at the moment of writing.
The lifecycle arc that is easy to leave unplanned
A flag has four moments. It is introduced, when the branch appears in code. It starts being evaluated, when values begin arriving. It is observed, while someone watches whether the new path behaves. And it is removed, when the branch and the flag are deleted.
The fourth moment is the one that silently fails, and the reason is structural rather than a failure of discipline.
Consider the incentives. The flag is most interesting on the day it is introduced — it is the mechanism carrying the work everyone is watching. It is least interesting on the day it should die, because by then the rollout succeeded, the feature is just the product, and attention has moved on. Nothing in the code is left pointing at the branch.
Many kinds of debt announce themselves. A missing index makes a page slow. A leak makes a process fall over. A broken test goes red. An expired flag does none of that. Both paths keep working until someone removes the flag, which does not make it harmless: Uber's Piranha documentation lists, among the drawbacks of code left behind by stale flags, that the flags can interfere with other experimental flags and that stale flags can also cause bugs. It is one of the quietest kinds of debt, which is why it tends to accumulate.
The compounding cost is not the if statement — a stale branch is cheap to read once. The cost is the state space. Every flag still live doubles the number of configurations that the next reader, the next test, and the next refactor must treat as possible. Ten forgotten flags do not cost ten branches; they cost a codebase where nobody can say with confidence what is actually running.
The surface inventory in one view
Below is what a flag owner engineers. The depth of each surface belongs to its own piece; the table is the map.
| Surface | What it decides |
|---|---|
| Toggle taxonomy | Which of the four types this is, and therefore its lifespan and required dynamism |
| Lifecycle and debt | When the flag dies, and what makes staleness detectable before a human notices |
| Toggle points | Where the branch lives in the code, and how it avoids spreading across layers |
| Targeting and context | What the code knows at the moment it asks, and who gets which answer |
| Delivery | Where the value physically comes from, and how stale it can be |
| Kill switches | What earns an operator-thrown lever, and which way it fails |
| Progressive rollout | How exposure widens, what is watched at each step, and how it reverses |
| Testing | Which combinations of flags are real enough to deserve coverage |
| Client-side evaluation | What changes when the branch runs on a machine you do not control |
| Portability | How the code talks to a flag backend without marrying it |
Two of those are foundations. The taxonomy and the lifecycle come first because every other decision inherits from what type the flag is and how long it is allowed to live. A team that gets those two right will make reasonable choices on the rest almost by default. A team that skips them will make locally sensible choices that add up to a codebase nobody can reason about.
The quiet load-bearing primitive is the evaluation context. Several surfaces above the toggle point (targeting, delivery, client-side evaluation) turn out to be questions about what the code knows at the moment it asks — which is why a flag that starts as a global boolean and later needs to answer per person is not a small change.
The recurring tension: the flag is a promise to come back
Every flag is a branch that says both paths are valid for now. That sentence is true on the day it is written. It becomes less true every day afterward, while the code goes on honoring it exactly as written.
The discipline that follows is to write the flag as a temporary object from the first line. Declare the type. State the removal condition — a date, or an event like the rollout reaching full traffic. Name an owner. Not because process demands it, but because nothing downstream can reconstruct that information later. Much later, a stale release toggle and a working permission gate are indistinguishable to everyone except the person who wrote one of them, and by then that person may have changed teams.
There is an honest counterweight, and it matters as much as the rule. Some flags are meant to be long-lived. A kill switch, the long-lived kind of ops toggle, exists to be thrown in an emergency that has not happened yet; a permission gate that limits a feature to premium users can be a product rule that stays in place for years, far longer than other flag types. Treating those as debt — deleting the lever because nobody has pulled it — is the mirror-image mistake, and it becomes a risk after a team gets religious about flag cleanup. The taxonomy is what tells the two apart. This is the whole reason it is a foundation rather than paperwork.
What flags do not solve
Flags are not free. They buy optionality and pay for it in code branches, test combinations, and a permanent reading tax on every file that carries one. That cost is real even when the flag is correct, and it is the reason the answer to "should this be behind a flag" is not always yes.
A flag does not make a release safe by itself. A flag with no signal to watch and no defined failure default is a switch nobody knows when to throw, wired to a system nobody is looking at. The mechanism gives you the ability to react; it does not supply the reason.
A flag does not tell you whether the new behavior is better. Splitting traffic is delivery. Whether the new path won, by how much, and with what confidence is experiment design — a genuinely different discipline with its own literature and its own failure modes, and one that this topic deliberately leaves alone. Conflating the two is how teams end up with a flag system that reports numbers nobody should act on.
A flag does not survive an unbounded combination space. Flags multiply against each other, not add, and the interesting question is never "have we tested all combinations" — it is which combinations actually exist.
And a flag in client code is public. The branch ships in the bundle, the evaluated value lands on a machine the reader controls even when a vendor's servers apply the targeting rules, and the flag's name is frequently a description of unreleased work. That makes a client-side flag a delivery seam and never a security boundary. Anything that must be true regardless of who is asking is enforced on the server, and the flag only decides what to draw.
The mechanism is worth its cost. It is worth it more often than a first instinct might suggest, and less often than vendor marketing implies. What makes the difference is not the tool — it is whether the flag was classified when it was written and deleted when it was done.