Feature Flag Lifecycle Management
Manage the complete lifecycle of feature flags from creation to cleanup. Prevent flag debt by defining ownership, expiration, and removal processes.
Best Practices
Detailed Explanation
Feature Flag Lifecycle
Feature flags are not permanent. Without lifecycle management, codebases accumulate "flag debt" -- hundreds of stale flags that complicate the code, slow down flag evaluation, and confuse team members.
Flag Lifecycle Stages
DRAFT → ACTIVE → ROLLED OUT → DEPRECATED → REMOVED
| | | | |
| Targeting 100% of users Cleanup Code
| rules for 2+ weeks scheduled branches
| defined removed
|
Flag created,
not yet enabled
Configuration with Metadata
{
"new-onboarding-flow": {
"name": "New Onboarding Flow",
"description": "Redesigned first-time user experience",
"type": "boolean",
"enabled": true,
"defaultValue": false,
"targeting": [
{ "type": "percentage-rollout", "percentage": 100 }
],
"_metadata": {
"owner": "growth-team",
"createdDate": "2025-01-15",
"targetRemovalDate": "2025-03-15",
"jiraTicket": "GROW-1234",
"lifecycle": "rolled-out",
"tags": ["temporary", "onboarding", "q1-initiative"]
}
}
}
Flag Categories by Lifetime
| Category | Lifetime | Example |
|---|---|---|
| Release flags | Days to weeks | New feature rollout |
| Experiment flags | 2-4 weeks | A/B tests |
| Ops flags | Permanent | Kill switches, circuit breakers |
| Permission flags | Long-lived | Premium features |
Cleanup Process
- Identify: Flag is at 100% for 2+ weeks with no incidents
- Create ticket: File a cleanup task with the flag key
- Remove from code: Delete all branches referencing the flag
- Remove from config: Delete the flag definition
- Update tests: Remove flag-related test cases
- Verify: Deploy and monitor
Flag Debt Warning Signs
- More than 50 active flags at once
- Flags older than 6 months still in "active" state
- Team members don't know what a flag does
- Multiple flags controlling the same feature
- Flags with no documented owner
Preventing Flag Debt
- Mandatory expiration dates on all release flags
- Weekly flag review in team standup
- Automated alerts for flags past their target removal date
- Flag dashboard showing age, status, and owner of each flag
- Linting rules that warn about deprecated flags in code
Use Case
A engineering team has accumulated 200+ feature flags over two years, with many stale flags cluttering the codebase. They implement a lifecycle policy: every flag must have an owner and a target removal date. A weekly automated report highlights flags past their expiration. Within three months, they reduce to 60 active flags.