feature-flags
Feature Flags
Documentation
This skill has comprehensive documentation:
- Production Examples - Real-world code examples from the codebase
- API Reference - Complete API documentation with official links
- Implementation Patterns - Best practices and anti-patterns
Core Principles
Always use feature flag constants instead of hardcoded strings. Feature flag keys must be defined as constants in FEATURE_FLAG_KEYS objects (ProfileServiceModuleFeatureFlagKeys, StoreModuleFeatureFlagKeys, etc.) with SCREAMING_SNAKE_CASE naming. Never hardcode feature flag strings directly in useFeatureIsEnabled calls.
Always handle async initialization loading states. useFeatureIsEnabled returns false initially until the feature flag SDK initializes. For UI-critical decisions, implement loading states or use timeouts to prevent flashing the wrong UI variant while initializing.
Use custom wrapper hooks for reusable feature flag checks. Create named hooks like useIsShortShippingEnabled() that encapsulate feature flag logic with constants. This provides better discoverability, type safety, and prevents duplicate feature flag checks across components.