بنقرة واحدة
feature-flags-patterns
Expert reference for feature flag architecture, lifecycle management, and progressive delivery
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Expert reference for feature flag architecture, lifecycle management, and progressive delivery
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Expert reference for application security — OWASP Top 10 mitigations, auth/authz, secrets management, cryptography, input validation, dependency hygiene, and secure-by-default code patterns
Expert reference for token counting, prompt compression, cost estimation, and quality preservation when optimizing prompts for Claude models
Experimentation design and A/B testing standards for product teams
Expert reference for digital accessibility — WCAG conformance, ARIA, and inclusive design patterns
Authoritative reference for agent architecture selection, multi-agent orchestration, tool design, memory systems, and failure mode prevention
Expert reference for evaluating LLM systems, RAG pipelines, and AI features in production
| name | feature-flags-patterns |
| description | Expert reference for feature flag architecture, lifecycle management, and progressive delivery |
| version | 1 |
If the flag controls a new feature rollout → it is a release flag: short-lived, percentage-based rollout, automatic cleanup after 100%. Target lifecycle: 2-4 weeks.
If the flag controls an A/B experiment → it is an experiment flag: tied to experiment lifecycle, variants matched to experiment arms, requires consistent assignment (sticky by user_id). Remove after experiment concludes and winner is shipped.
If the flag controls a kill switch or circuit breaker → it is an ops flag: permanent, boolean, default-on. Used to disable a feature if it causes an incident. Never auto-remove. Review annually.
If the flag controls access based on plan or role → it is a permission flag: permanent, driven by entitlement service data, not percentage-based. Remove only when the feature tier is retired.
If rollout percentage is being increased → establish monitoring gates: define which metrics to check before each increase (error rate, p99 latency, conversion). If any metric degrades beyond threshold, halt and investigate before continuing.
If two flags control the same code path → evaluate whether they should be merged. Nested flag evaluation creates combinatorial testing complexity: 2 flags = 4 states, 3 flags = 8 states. Avoid flag stacking.
If a flag has not been touched in >90 days → auto-notify the owner with a "review or extend" prompt. If no response in 2 weeks, escalate to the team lead.
Never use a feature flag as a configuration system. Flags control behavior (on/off, A/B). Configuration values (timeout durations, API endpoints, rate limits) belong in a configuration store, not a flag.
Never evaluate flags in a tight loop or hot path without caching. Flag evaluation should be cached in-process; SDK polling/streaming handles updates in the background.
Flag Taxonomy and Governance
Flag Type | Lifetime | Variants | Targeting | Cleanup Trigger
-------------|---------------|-----------|------------------|------------------
Release | 2-4 weeks | on/off | % rollout | 100% + 2 weeks
Experiment | Experiment | A/B/n | Sticky by userID | Experiment ends
Ops/Kill | Permanent | on/off | Global | Annual review
Permission | Permanent | plan tiers| Entitlement data | Feature retired
Progressive Rollout Gates
1% → [monitor 1h] → 5% → [monitor 4h] → 25% → [monitor 24h]
→ 50% → [monitor 24h] → 100% → [monitor 48h] → REMOVE FLAG
At each gate, check:
- Error rate: must not increase >10% relative
- p99 latency: must not increase >20%
- Business metric: must not degrade (feature-specific)
If any gate fails: roll back to previous percentage, investigate.
The Flag Lifecycle State Machine
[Created] → [Targeting configured] → [1% rollout] → [Graduated rollout]
→ [100% rollout] → [Cleanup PR opened] → [Flag removed from code]
→ [Flag archived in platform]
Anything stuck in [Graduated rollout] >30 days = flag debt. Alert owner.
| Term | Precise Meaning |
|---|---|
| Release flag | Short-lived flag controlling a gradual feature rollout |
| Experiment flag | Flag with multiple variants tied to an A/B test assignment |
| Ops flag | Permanent kill switch; enables/disables a feature in response to incidents |
| Permission flag | Entitlement-driven flag controlling feature access by plan or role |
| Sticky bucketing | Consistent variant assignment for a user across sessions (bucketed by user ID) |
| Flag evaluation | The process of determining which variant a given user/context receives |
| Targeting rule | Logic defining which users receive which variant (%, segment, attribute match) |
| Flag debt | Accumulated flags that were never removed after their purpose was served |
| Progressive delivery | Gradual feature rollout using flags, with monitoring gates between percentage increases |
| Multivariate flag | Flag with more than 2 variants (A/B/C testing or feature parameterization) |
| Flag SDK | Client library that communicates with the flag service and evaluates flags locally |
| Audit log | Record of every flag change: who changed it, what changed, when |
Mistake 1: Permanent release flags
show_new_dashboard flag created in 2022, still evaluated in every request in 2025, original owner has left the companyMistake 2: Flag stacking without tracking
new_checkout_flow = true AND new_payment_ui = true AND express_checkout = true — 8 possible states, only 2 testedMistake 3: Using flags as configuration
payment_timeout_ms flag with value "3000" — now you have a configuration system with flag governance overheadMistake 4: Live flag evaluation in tests
// BAD
const enabled = await ldClient.variation('new-feature', user, false);
// GOOD — inject mock in tests
interface FlagClient {
variation(key: string, defaultValue: boolean): boolean;
}
// Test with both variants explicitly
describe('new-feature enabled', () => {
const flags = { variation: () => true };
// test enabled behavior
});
describe('new-feature disabled', () => {
const flags = { variation: () => false };
// test disabled behavior (feature hidden, no errors)
});
Mistake 5: No rollout monitoring gates
BAD flag definition (no governance):
{
"key": "new_checkout_flow",
"type": "boolean",
"defaultValue": false
}
No owner, no expiry, no description of what it controls or when it should be removed.
GOOD flag definition:
{
"key": "new-checkout-flow",
"type": "boolean",
"description": "Controls new 3-step checkout flow replacing legacy 5-step flow",
"owner": "payments-team",
"type_classification": "release",
"created_date": "2025-04-01",
"expiry_date": "2025-05-15",
"rollout_plan": "1%→5%→25%→50%→100% with 24h monitoring at each step",
"cleanup_criteria": "Remove flag and old code path 2 weeks after 100% rollout",
"monitoring_metrics": ["checkout_completion_rate", "payment_error_rate", "checkout_p99_latency"],
"tags": ["checkout", "q2-2025"]
}