一键导入
feature-flags
Feature flag strategies, rollout patterns, kill switches and flag lifecycle management
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Feature flag strategies, rollout patterns, kill switches and flag lifecycle management
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
**Architecture Decision Record (ADR) — Philosophy-First**: Creates well-structured ADRs using a 3-phase process: (1) Define the architectural philosophy and identity of the system, (2) Explore options through the lens of that philosophy, (3) Adversarial review by a devil's advocate agent. Use this skill whenever the user wants to document a technical decision, create an ADR, record why a technology or approach was chosen, compare architectural alternatives, or mentions 'ADR', 'architecture decision', 'decision record', 'technical decision', 'why did we choose', or 'document this decision'. Also trigger when the user is evaluating trade-offs between technical approaches and wants to formalize the reasoning.
**AI/ML Engineering Review**: Reviews AI/ML systems for production readiness — model serving, MLOps pipelines, LLM integration patterns, prompt engineering, evaluation frameworks, and responsible AI. Covers model deployment, feature stores, experiment tracking, monitoring/drift detection, and AI safety. Use when the user mentions ML, AI, machine learning, model, LLM, GPT, Claude, embeddings, RAG, fine-tuning, MLOps, model serving, feature store, or any AI/ML infrastructure.
**API Documentation & Design (OpenAPI/Swagger)**: Helps write and review API documentation, generate OpenAPI/Swagger specs, design RESTful APIs, and document GraphQL schemas. Use whenever the user mentions 'API docs', 'Swagger', 'OpenAPI', 'API specification', 'API design', 'REST API', 'endpoint documentation', 'API contract', 'API versioning', 'GraphQL schema', 'API reference', or asks to document their API, generate a Swagger spec, design API endpoints, or review API contracts for consistency.
API Gateway design patterns including rate limiting, authentication, versioning, BFF and circuit breaking
ARB process design, RFC governance, decision log and technical review workflows
**Backend Code Review (Node.js, Java, Microservices)**: Expert review of backend code focusing on Node.js, Java, Clean Architecture, SOLID principles, microservices patterns, SQL/database design, messaging (Kafka, SQS, SNS), and payment flows. Use whenever the user wants a review of backend code, API design, service architecture, database queries, or mentions Node, Java, Spring, NestJS, Express, microservices, REST API, gRPC, or asks to review server-side code. Also trigger for database schema reviews, query optimization, and message queue patterns.
| name | feature-flags |
| description | Feature flag strategies, rollout patterns, kill switches and flag lifecycle management |
| category | operational |
| preferred-model | sonnet |
| min-confidence | 0.8 |
| depends-on | [] |
| estimated-tokens | 3000 |
| triggers | {"frameworks":["launchdarkly","flagsmith","unleash"]} |
| tags | ["feature-flags","rollout","kill-switch"] |
| Type | Purpose | Lifespan | Example |
|---|---|---|---|
| Release | Control feature rollout | Short (days-weeks) | ENABLE_NEW_BILLING_UI |
| Experiment | A/B testing | Medium (weeks) | EXPERIMENT_CHECKOUT_V2 |
| Ops | Kill switch | Permanent | ENABLE_EXTERNAL_PAYMENTS |
| Permission | Per-customer features | Permanent | PREMIUM_ANALYTICS |
// Feature flags from environment/config
const FLAGS = {
ENABLE_NEW_BILLING: process.env.FF_NEW_BILLING === 'true',
ENABLE_DARK_MODE: process.env.FF_DARK_MODE === 'true',
};
// Usage
if (FLAGS.ENABLE_NEW_BILLING) {
return this.newBillingService.process(order);
} else {
return this.legacyBillingService.process(order);
}
@Entity('feature_flags')
class FeatureFlag {
@PrimaryColumn()
key: string; // 'ENABLE_NEW_BILLING'
@Column({ default: false })
enabled: boolean; // Global toggle
@Column({ type: 'int', default: 0 })
rollout_percentage: number; // 0-100
@Column({ type: 'simple-array', nullable: true })
allowed_tenants: string[]; // Specific tenants
@Column({ type: 'simple-array', nullable: true })
allowed_users: string[]; // Specific users
@Column({ type: 'timestamp', nullable: true })
expires_at: Date; // Auto-disable date
}
@Injectable()
export class FeatureFlagService {
constructor(
@InjectRepository(FeatureFlag) private repo: Repository<FeatureFlag>,
private cache: CacheManager,
) {}
async isEnabled(
key: string,
context: { userId?: string; tenantId?: string },
): Promise<boolean> {
const flag = await this.getFlag(key);
if (!flag || !flag.enabled) return false;
// Check expiration
if (flag.expires_at && flag.expires_at < new Date()) return false;
// Check specific tenant
if (flag.allowed_tenants?.includes(context.tenantId)) return true;
// Check specific user
if (flag.allowed_users?.includes(context.userId)) return true;
// Check percentage rollout (deterministic by userId)
if (flag.rollout_percentage > 0 && context.userId) {
const hash = this.hashUserId(context.userId);
return (hash % 100) < flag.rollout_percentage;
}
// No specific rules + globally enabled
return flag.allowed_tenants?.length === 0 && flag.allowed_users?.length === 0;
}
private hashUserId(userId: string): number {
let hash = 0;
for (let i = 0; i < userId.length; i++) {
hash = ((hash << 5) - hash) + userId.charCodeAt(i);
hash |= 0;
}
return Math.abs(hash);
}
}
10% → 25% → 50% → 100%
│ │ │ │
└─ Monitor metrics for 24h at each stage
If error rate increases → rollback to previous %
If stable → advance to next %
enabled: falseCreated → Testing → Canary → Rollout → Full → CLEANUP
│
└── Remove flag code
Remove from database
Delete from config
CRITICAL: Flags without cleanup become tech debt!
Schedule cleanup date at creation.
if (flagA && flagB && !flagC))