Feature Flag Lifecycle
Stages Overview
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ Creation │───▶│ Testing │───▶│ Rollout │───▶│ Retire │
│ (OFF) │ │ (Dev) │ │ (Gradual)│ │ (Cleanup)│
└──────────┘ └──────────┘ └──────────┘ └──────────┘
Stage 1: Creation
- Create flag with
enabled: false - Add to
featureFlags.tsdefinition - Implement feature behind flag check
// packages/types/src/featureFlags.ts ui: { new_feature: { name: 'ui.new_feature', type: 'boolean', defaultEnabled: false, description: 'New feature description' } }
Stage 2: Testing
- Enable in development environment
- Test all code paths (enabled/disabled)
- Enable in staging for QA
- Monitor for errors/performance issues
# Enable for dev only curl -X PATCH /api/admin/feature-flags/ui.new_feature \ -d '{"enabled": true, "environment": "dev"}'
Stage 3: Rollout
- Start with 10% of users
- Monitor metrics and errors
- Gradually increase (25%, 50%, 75%, 100%)
- Have rollback plan ready
// Percentage rollout experiment: { new_feature: { name: 'experiment.new_feature', type: 'percentage', percentage: 10, // Start at 10% description: 'Gradual rollout' } }
Stage 4: Retirement
When feature is stable at 100%:
- Remove flag checks from code
- Delete flag from definitions
- Clean up Redis state
- Update documentation
# Delete flag curl -X DELETE /api/admin/feature-flags/experiment.new_feature
Best Practices
- Never skip stages - Always test before production
- Document decisions - Record why flags were created/retired
- Set expiration dates - Flags shouldn't live forever
- Review quarterly - Clean up stale flags