Writing
Fullstack English

Feature Flags: Deploy at 4 PM, Release When Ready

Separating deploy from release with percentage rollouts, kill switches, and the flag hygiene that stops the codebase from rotting.

  • Published
  • 1 min read
On this page3 sections
  1. What a useful flag system needs
  2. The rollout ritual
  3. Flag hygiene, or the codebase rots

The safest deploys I have shipped went out mid-afternoon, because deploying had stopped being the scary part. The trick is one idea: deploy code dark, release behavior later - and a flag is the switch between them.

What a useful flag system needs

Not much. A flag has a name, an on/off state, a rollout percentage, and optional targeting:

typescript
if (flags.isOn('new-checkout', { userId, percentage: 10 })) {
  return newCheckout(cart)
}
return legacyCheckout(cart)

Bucket users by hash(flagName + userId) % 100 so the same user gets a consistent experience - a checkout that flickers between versions is worse than either version.

The rollout ritual

  1. Ship at 0%. Verify in production with internal accounts.
  2. 1% -> watch error rates and business metrics, not vibes.
  3. 10% -> 50% -> 100% over hours or days depending on blast radius.
  4. Anything scary keeps a kill switch: one click back to legacy beats one rollback deploy.

Flag hygiene, or the codebase rots

Every flag is a fork in your code. Two rules keep it sane: flags carry an owner and an expiry date in their definition, and “remove flag” goes into the sprint the moment it hits 100%. A three-year-old flag named temp_fix_v2 is not a flag - it is architecture nobody chose.