Skip to content

Feature flags instead of code branches

Without flags, every deploy waits on a coordinated release.

react-platform-feature-flags-not-branches

Why it matters

Failure modes if this rule is ignored
StakeIf ignored
Hard to change
  • No feature flags — every partial feature waits for a coordinated release train.
  • Long-lived feature branches — merge conflicts and drift until nobody trusts main.
Unsafe to delete
  • Scattered feature ifs — nobody knows which flags are dead code safe to delete.

How to fix

A new capability ships behind a flag. The flag is controlled from outside (configuration, not code). When the capability is mature — delete the flag, do not leave it "just in case".

Examples

Bad
ts
function generateResponse(prompt: string) {
  if (process.env.NEW_PROMPT_FORMAT === 'true') return newFormat(prompt);
  if (window.location.hostname.includes('staging')) return experimentalFormat(prompt);
  return legacyFormat(prompt);
}
Good
ts
// libs/shared/feature-flags/src/lib/flags.ts
export const flags = {
  newPromptFormat: isEnabled('new-prompt-format'),
};

// usage
import { flags } from '@acme/shared/feature-flags';
function generateResponse(prompt: string) {
  return flags.newPromptFormat ? newFormat(prompt) : legacyFormat(prompt);
}

Contribute

Released under the MIT License.

esc