用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/mikailustuner/OmniRule --skill feature-flags命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | feature-flags |
| description | Feature Flags: Gradual rollouts, A/B testing, Kill switches, Feature management, Remote config. |
| triggers | {"files":["feature-flags.json","flags.config.js"],"directories":["flags/","config/"],"keywords":["feature flag","feature toggle","launchdarkly","split.io","unleash"]} |
| auto_load_when | Implementing feature rollouts, A/B testing, or kill switches |
| agent | platform-engineer |
| tools | ["Read","Write","Bash"] |
Focus: Gradual rollouts, A/B testing, remote config
Release Flags (Kill Switches):
- Disable features without deploying
- Emergency rollbacks
- Example: Disable new payment flow
Experiment Flags (A/B Testing):
- Split traffic between variants
- Measure impact on metrics
- Example: Test new checkout flow
Operational Flags:
- Toggle features for specific users
- Percentage rollouts
- Example: Enable for 10% of users
Permission Flags:
- Enable for specific roles/users
- Internal testing
- Example: Enable beta for team
Simple Flag Hook:
import { useFeature } from './flags'
function MyComponent() {
const { enabled } = useFeature('new-checkout')
if (!enabled) {
return <OldCheckout />
}
return <NewCheckout />
}
Flag Provider:
<FeatureFlagsProvider>
<App />
</FeatureFlagsProvider>
// useFeature reads from context
export function useFeature(flag: string) {
const flags = useContext(FlagsContext)
return flags[flag]
}
Client-side Evaluation:
// Use LaunchDarkly SDK
const ld = await launchdarkly.initialize('client-id')
const showFeature = await ld.variation('feature-key')
Server-side Evaluation:
// API returns enabled features
const features = await fetch('/api/features').then(r => r.json())
Percentage Rollout:
{
"flag": "new-dashboard",
"rollout": {
"percentage": 10, // 10% of users
"sticky": true // Same user always gets same variant
}
}
Targeting Rules:
{
"flag": "beta-feature",
"rules": [
{ "attribute": "email", "operator": "endsWith", "value": "@company.com" },
{ "attribute": "country", "operator": "in", "value": ["US", "CA"] },
{ "attribute": "customAttribute", "operator": "contains", "value": "beta" }
]
}
Sticky Sessions:
- Use user ID for consistent experience
- Hash user ID to bucket
- Store bucket in cookie/session
Admin Dashboard:
- View all flags and their status
- Toggle flags on/off
- Set targeting rules
- View analytics
API Endpoints:
GET /api/flags // List all flags
POST /api/flags // Create flag
PUT /api/flags/:name // Update flag
DELETE /api/flags/:name // Delete flag
POST /api/flags/:name/evaluate // Evaluate for user
Evaluation:
{
"flags": {
"new-feature": { "enabled": true, "variant": "b" },
"beta-dashboard": { "enabled": false }
}
}
❌ Hardcoding flags in code
✅ Use config file or remote service
❌ Forgetting to clean up old flags
✅ Remove after 100% rollout
❌ No monitoring
✅ Track metrics for each flag
❌ Too many flags
✅ Keep flags to minimum necessary
❌ Not using sticky sessions
✅ Same user gets same variant
❌ Flags without documentation
✅ Document purpose and expected outcome
| Pattern | Tool | Note |
|---|---|---|
| SaaS | LaunchDarkly, Split.io | Managed service |
| Open Source | Unleash, Flagd | Self-hosted |
| Simple | JSON config file | For small projects |
| Rollout | Percentage based | Gradual release |
| A/B Test | Variants | Test variants |