How Feature Flags Work
All code (including incomplete features) continuously merges through DEV → QA → PROD. Long-running features are hidden behind runtime flags and enabled only when ready.
✅ Benefits
- No branch divergence: Code always synced across environments
- Early integration: Features tested in real production environment (just hidden)
- Simple deployment: Just flip a flag, no merge conflicts
- Gradual rollouts: Enable for 10% → 50% → 100% of users (canary releases)
- Easy rollback: Disable flag if issues found, no code deployment needed
⚠️ Risks
- Accidental exposure: Flag misconfiguration could show incomplete feature
- Hidden bugs: Code runs even when hidden, can affect performance/stability
- Dead code: Flags accumulate if not cleaned up after release
- Testing complexity: Need to test both flag ON and OFF states
🛡️ Mitigation Strategies
- Use feature flag service (LaunchDarkly, Unleash, AWS AppConfig) with environment-specific defaults
- Flags default to OFF in PROD, explicitly enabled per environment
- Automated tests run with flags both ON and OFF
- Flag cleanup policy: remove within 2 sprints of release
- Code review checklist: "Is flag condition correct? Is flag documented?"
🎯 Best For
- UI features that can be hidden from users
- Features requiring production data for realistic testing
- Gradual rollouts and A/B testing
- Teams comfortable with trunk-based development