功能开关架构设计与审计
feature-flags-architect
在新增、下线或审计功能开关(Feature Flag)时使用。触发词包括"添加开关""通过开关发布""灰度发布计划""熔断开关""陈旧开关""开关技术债""LaunchDarkly""GrowthBook""Statsig""Unleash""Flipt",或任何渐进式交付相关问题。附带开关技术债扫描器、灰度发布规划器和熔断开关审计器(均为 Python 标准库实现)、4 份关于开关分类、供应商权衡、发布策略和生命周期的参考文档,以及一个 /flag-cleanup 斜杠命令。
- License 许可
- MIT
- 最近更新
- 2026-10-28
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- feature-flags-architect
- tags
- [ "feature-flags", "progressive-delivery", "rollout", "kill-switch", "launchdarkly", "growthbook", "statsig", "unleash", "flipt", "release-engineering" ]
- author
- claude-code-skills
- context
- fork
- license
- MIT
- version
- 2.9.0
- description
- Use when adding, retiring, or auditing feature flags. Triggers on "add a flag", "ship behind a flag", "rollout plan", "kill switch", "stale flags", "flag debt", "LaunchDarkly", "GrowthBook", "Statsig", "Unleash", "Flipt", or any progressive-delivery question. Ships flag debt scanner, rollout planner, and kill-switch auditor (all stdlib Python), 4 references on flag taxonomy + provider trade-offs + rollout strategies + lifecycle, plus a /flag-cleanup slash command.
- compatible_tools
- [ "claude-code", "codex-cli", "cursor", "antigravity", "opencode", "gemini-cli" ]
02 资源文件 9
- 资产文件assets/flag_request_template.md1.7 KB
- 参考文档references/flag_lifecycle.md5.7 KB
- 参考文档references/flag_taxonomy.md4.4 KB
- 参考文档references/provider_comparison.md5.0 KB
- 参考文档references/rollout_strategies.md4.9 KB
- 脚本scripts/flag_debt_scanner.py4.7 KB
- 脚本scripts/kill_switch_audit.py4.9 KB
- 脚本scripts/rollout_planner.py4.4 KB
- 其他tools.sdn555 B
03 SKILL.md 正文
Feature Flags Architect
End-to-end discipline for feature flags: classify them, ship them, ramp them, and retire them. Most teams treat flags as throwaway if-statements; this skill treats them as a controlled lifecycle with measurable debt.
When to use
- Adding a new flag and need a rollout plan
- Auditing a codebase for stale or orphaned flags
- Choosing a flag provider (LaunchDarkly vs GrowthBook vs Statsig vs Unleash vs Flipt vs build-your-own)
- Designing a kill-switch path for a risky launch
- Cleaning up flag debt before a release freeze
- Reviewing whether a feature should ship behind a flag at all
Core principle: flags are a lifecycle, not an if
request → design → ship → ramp → cleanup → archive
Flags that skip cleanup become debt: dead branches, stale defaults, untested code paths, unbounded blast radius. The three scripts in this skill enforce the lifecycle.
Quick start
# 1. Audit the repo for flag debt
python scripts/flag_debt_scanner.py --repo . --max-age-days 90
# 2. Plan a progressive rollout for a new flag
python scripts/rollout_planner.py --population 100000 --target-percent 100 --duration-days 14 --strategy ring
# 3. Verify every flag has a documented kill switch
python scripts/kill_switch_audit.py --repo . --flag-doc docs/feature-flags.md
The 4 flag types (taxonomy)
Different flag types have different lifespans and ownership. Misclassifying creates debt.
| Type | Purpose | Typical lifespan | Owner | Cleanup trigger |
|---|---|---|---|---|
| Release | Hide unfinished features in production | days–weeks | Eng | 100% rollout reached |
| Experiment | A/B test variants | weeks | Product/Marketing | Test concluded; winner picked |
| Operational | Circuit breakers, perf toggles, kill switches | months–years | Eng/SRE | Replaced by autoscaling/feature retirement |
| Permission | Entitlements per user/account/plan | years (permanent) | Product | Plan/role removed |
Only Release and Experiment flags should be on a debt-scanner watchlist. Operational and Permission flags are by design long-lived. See references/flag_taxonomy.md for decision tree.
The 3 Python tools
All three are stdlib-only. Run with --help.
flag_debt_scanner.py
Finds flags older than --max-age-days with low usage, suggesting candidates for cleanup.
python scripts/flag_debt_scanner.py --repo . --max-age-days 90 --format text
python scripts/flag_debt_scanner.py --repo . --max-age-days 60 --format json > debt.json
Detection heuristic:
- Walk
--repofor code references matching common flag-call patterns:flag("..."),isFlagEnabled("..."),featureFlag("..."),getFlag("...")client.variation("...", ...),unleash.isEnabled("..."),growthbook.feature("...")
- For each unique flag identifier, find the oldest commit that introduced it (
git log --diff-filter=A -S <name>). - Flag as DEBT if introduced >
--max-age-daysago AND used in ≤--min-usesplaces.
Outputs flag name, age in days, file references, suggested action. JSON mode is CI-friendly.
rollout_planner.py
Generates a phased rollout schedule from population size, target percent, duration, and strategy.
python scripts/rollout_planner.py --population 100000 --target-percent 100 --duration-days 14 --strategy ring
python scripts/rollout_planner.py --population 50000 --target-percent 25 --duration-days 7 --strategy linear
python scripts/rollout_planner.py --population 1000000 --target-percent 100 --duration-days 30 --strategy log
Strategies:
ring: 1% → 5% → 25% → 50% → 100%, evenly spaced. Default for risky launches.linear: constant rate per day. Default for medium-risk.log: rapid early, slow tail. Default for low-risk launches with confidence.cohort: by named cohort (internal → beta → free → paid → all).
Outputs a markdown table with date, percent, expected user count, abort criteria, and verification step per phase.
kill_switch_audit.py
Cross-references code-discovered flags against documentation to verify each has a kill switch path written down.
python scripts/kill_switch_audit.py --repo . --flag-doc docs/feature-flags.md
python scripts/kill_switch_audit.py --repo . --flag-doc runbooks/flags.md --format json
What it checks:
- Every code-discovered flag has an entry in
--flag-doc - Each entry declares: owner, type, kill-switch trigger, monitoring dashboard
- Reports flags missing documentation (FAIL) or missing fields (WARN)
Use as a pre-merge gate before any new flag ships.
Provider chooser (5 + DIY)
| Provider | Best for | Pricing model | Lock-in risk | OSS option |
|---|---|---|---|---|
| LaunchDarkly | Enterprise, complex targeting, audit/compliance | Per-MAU, expensive | High | No |
| GrowthBook | Mid-market, A/B testing focused, OSS-friendly | Per-MAU + OSS | Low | Yes (self-host) |
| Statsig | Growth/product teams, advanced experimentation | Free tier + per-MAU | Medium | No |
| Unleash | OSS-first, self-hosted, dev-friendly | OSS + Enterprise | Low | Yes |
| Flipt | Lightweight, k8s-native, simple needs | OSS-only | None | Yes |
| DIY | <100 flags, no targeting, full control | None | None | N/A |
Decision rules:
- <50 flags + no targeting → DIY with config file or env vars
- Need analytics + experimentation → Statsig or GrowthBook
- Compliance/SOC2 audit logs required → LaunchDarkly
- Self-hosting required (data residency / air-gapped) → Unleash or Flipt
- See
references/provider_comparison.mdfor detail.
Workflows
Workflow 1: Ship a new feature behind a flag
1. Classify: which of the 4 flag types?
→ Release (most common for engineering work)
2. Run rollout_planner.py to design the ramp
3. Add flag entry to docs/feature-flags.md BEFORE writing code:
- name, owner, type, kill-switch trigger, dashboard URL
4. Write the code with the flag
5. Run kill_switch_audit.py — must pass before merge
6. Deploy at 0%; verify kill switch works
7. Execute rollout schedule; abort if abort criteria met
8. At 100% for 7+ days: remove flag, delete dead branch, archive doc entry
Workflow 2: Quarterly flag cleanup
1. Run flag_debt_scanner.py --repo . --max-age-days 90 > debt.md
2. For each flagged item:
a. Confirm it reached 100% (or was killed)
b. Find the issue/PR that introduced it; verify owner agrees to remove
c. Delete dead branches; remove flag config
d. Run kill_switch_audit.py — should now show one fewer flag
3. Update CHANGELOG: "Removed N stale flags"
Workflow 3: Choose a provider
1. Estimate flag count (current + 12-month projection)
2. Required features:
- Targeting rules (user, account, geo, %)?
- A/B testing + stats?
- Audit log / SOC2?
- Self-hosting / data residency?
3. Pricing budget (MAU * cost-per-MAU)
4. See provider_comparison.md decision tree
5. Build a 30-day proof-of-concept before signing
Workflow 4: Design a kill switch
1. Identify the failure modes:
- Latency spike (which threshold?)
- Error rate spike (which threshold?)
- Business metric regression (which threshold?)
2. Wire each to an abort:
- Manual: dashboard link + on-call playbook
- Automated: alert threshold flips flag back to 0%
3. Test the kill switch in staging BEFORE production rollout
4. Document in flag-doc; pass kill_switch_audit.py
References
references/flag_taxonomy.md— 4 types, decision tree, ownership, lifespanreferences/provider_comparison.md— LaunchDarkly / GrowthBook / Statsig / Unleash / Flipt / DIY trade-offsreferences/rollout_strategies.md— ring / linear / log / cohort / geo, abort criteria, monitoringreferences/flag_lifecycle.md— request → design → ship → ramp → cleanup → archive
Slash command
/flag-cleanup — Run the full cleanup workflow on the current repo: scan for debt, generate a removal plan, audit kill switches.
Asset templates
assets/flag_request_template.md— fill-in form for new flag requests (name, owner, type, kill switch, rollout plan)
Anti-patterns
- Permanent flag with
if (FLAG_FOO)50 places — should be a Permission flag with a runtime config, not a Release flag - Flag with no owner — when the original engineer leaves, no one cleans it up
- No kill switch documented — when the feature breaks, no one knows how to disable it
- A/B test that ran 6 months — pick a winner; running indefinitely is debt
- Flags as feature toggles for cosmetic changes — ship via deploy, not flag
Verifiable success
A team using this skill should achieve:
- 100% of new flags pass
kill_switch_audit.pyat merge time flag_debt_scanner.py --max-age-days 90returns ≤5 stale flags repo-wide- Every flag has a documented owner, type, and kill switch
- Mean time to retire a Release flag: <60 days from 100% rollout
04 同仓库更多 Skills
课程大纲阅读清单生成
syllabus
使用 Consensus 学术搜索从任意课程大纲生成精选的补充阅读清单。在任何搜索运行之前,进行'拷问式'信息收集(syllabus 输入格式 + 课程受众 + 年份范围)以及分组强制选项检查点——以确保阅读清单匹配课程的层次和时效性需求。解析大纲以提取主题和学习成果,针对每个主题在 Consensus 中搜索近期同行评审论文,并生成专业排版的 .docx 文档,包含可点击的 Consensus 链接、按受众层次校准的通俗语言摘要,以及与课程学习目标关联的布鲁姆(Bloom)高阶层次讨论问题。当用户上传课程大纲、课程概要或课程文档并希望获得补充阅读材料时使用(例如'create a reading list from this syllabus'、'find recent papers for my course')——即使是附带大纲的随意提及也应触发此技能。
话题动态多源调研
pulse
多源近期研究技能,可在可配置的近期时间窗口(默认 30 天)内,跨 Reddit、Hacker News、开放网络以及可选的 X/Twitter 把握任意话题的动态。强制信息收集(intake)会在搜索前明确话题的具体性、角度(趋势/情绪/问题/机会/对比)、时间窗口和平台范围。返回一份综合简报,包含引用来源、互动指标和跨平台模式分析。当用户请求对某话题进行多源近期情报调研时使用(例如'pulse on [topic]'、'what's happening with [topic]'、'what are people saying about [topic]'、'current conversation about [topic]'、'take the pulse of [topic]'、'trending: [topic]'、'find me info on [topic]'),也适用于竞品研究、趋势发现、工具对比和受众情绪分析。
专利现有技术检索分析
patent
专利现有技术检索与专利景观情报技能——并非通用专利助手。在任何检索运行之前,通过强制问询确定五种子用例之一(新颖性检索 / 自由实施 FTO / 竞争景观 / 收购尽调 / 诉讼现有技术)。检索 Google Patents、Espacenet、USPTO,并可选检索 Lens.org 以获取引文图谱信号。输出为可编辑的 Word 文档(.docx),包含结论、按相关度排序的最接近现有技术(附提取的权利要求文本)、考虑 CPC 分类的景观分析、经家族解析的命中结果、地域覆盖、适用时的 FTO 标记、策略建议以及完整审计日志。当用户要求进行专利检索或分析时使用(例如“针对 [invention] 的现有技术检索”“针对 [product] 的自由实施分析”)。产出的是检索信号而非法律建议——在提交申请或许可决策前始终建议咨询专利律师。商标、版权和商业秘密问题不在范围内。
NotebookLM 笔记本自动化管理
notebooklm
用于控制 Google NotebookLM 的浏览器自动化技能。当用户希望在 NotebookLM 中完成任何操作时使用(例如“打开 NotebookLM”“查看我的 [name] 笔记本”“向我的笔记本询问 X”“将 [source] 添加到 NotebookLM”“从我的笔记本生成视频概览”“使用 NotebookLM Studio”)。可处理读取与查询笔记本、添加来源(URL、文本、文件、YouTube 链接、合成内容)、生成 Studio 输出(音频/视频概览、思维导图、报告,包括简报文档/学习指南/FAQ、抽认卡、测验、幻灯片、信息图——需从实时 Studio 面板发现确切的输出集合;其 UI 迭代很快),以及创建新笔记本。需要浏览器自动化环境——不可用时优雅降级。
学术文献综述指南
litreview
学术文献导向技能,默认通过免费、无需密钥的API(PubMed E-utilities + OpenAlex)检索论文——连接后可将Consensus MCP作为可选的增强通道——使用PICO(默认)或SPIDER / Decomposition / hybrid作为后备来构建战略检索计划,并将发现综合成格式化的Word(.docx)研究指南。在侦察性检索(recon search)前进行Grill-me式信息收集(研究问题的具体程度+框架提示+初步深度);在Phase 2之后设置第二个强制检查点,先确认框架+子领域+深度,再让检索消耗预算。可配置的深度(5/10/20次查询)用于控制覆盖面与速度。输出是一个'起点'(launching pad)——让研究者能自信地深入展开的方向性指南,而非已完成的综述。当用户开始文献导向的研究时使用(例如'litreview on [topic]'、'literature review on [topic]'、'I'm starting a literature review on X'、'I'm writing a paper on X'、'help me research X'、'I'm doing research on X'、'can you help me research X')。不要用于只想快速获得列表的单个一次性论文检索——那属于普通的PubMed/OpenAlex(或Consensus)查询。
NIH科研基金申请
grants
面向临床研究人员的NIH科研基金申请技能。Grill-me式信息收集(研究想法+职业阶段+初步数据+研究环境+提交姿态+已知的目标研究所)会在任何检索开始前锁定资助策略。运行5个维度的Consensus定位分析(含起草的Significance/Innovation措辞),通过RePORTER将研究映射到合适的NIH研究所(institutes)与研究部门(study sections),查找NOSIs及已获资助的重叠项目,并生成可编辑的Word文档(.docx),包含考虑预算与范围的机制推荐、提交时间线以及必须给出的项目官员(program officer)推荐。当用户询问研究资助或提出任何与基金申请相关的请求时使用(例如'[某主题]的基金'、'为我的研究想法找基金'、'哪些基金与我的研究匹配'、'帮我找NIH资助'、'我研究的基金机会')。仅限NIH范围——非NIH资助方(PCORI、DOD CDMRP、VA、基金会)不在范围内,并会在信息收集(intake)时予以提示。