One line of code, two decisions
A feature flag is a conditional that decides at runtime whether some behaviour is active.
if flags.enabled("new-checkout", user=user):
return new_checkout(cart)
return legacy_checkout(cart)
That is the whole mechanism. Its significance is not the branch but what the branch decouples: the code ships in one act, and the behaviour is exposed in another, at a time somebody else can choose.
What that separation unlocks, in rough order of value:
- Deploy incomplete work safely. Half-built features can live in the main branch behind an off flag, which removes the long-lived branch and the merge that comes with it.
- Release to a subset. Internal staff first, then beta users, then a percentage, then everyone.
- Turn something off without deploying. The fastest possible remediation, faster than any rollback, because nothing needs to be rebuilt or restarted.
- Time a launch. Marketing announces on Tuesday; the code has been in production for three weeks.
Key idea: the previous lesson ended by separating deployment from release. The flag is the mechanism that makes that separation real, and it converts "can we ship this?" from a deployment question into a product one.

