Feature flags decouple deployment from release: code ships dark, then you enable behavior for a cohort without a second redeploy.
Kinds of flags
- Release toggle: hide unfinished UI until ready.
- Ops/kill switch: turn off expensive paths during incidents.
- Experiment: A/B metrics with cohort targeting.
Rollout mechanics
Percentage of requests, allowlists of user ids, segments by region or plan. Evaluate server-side for security-sensitive logic.
Tech choices
Config env vars for rare ops toggles; hosted flag services or open-source engines when many flags and audits matter.
Hygiene
Flags rot: schedule removal after full launch. Branches riddled with if (flag) become unreadable — prefer strategies or small modules.
Testing
Run CI matrix with flag on/off for critical paths.