PromptOtherOpen

Feature Flag Stale Cleanup Auditor

- name: feature-flag-stale-cleanup-auditor description: Audits feature flags against your codebase and plans their cleanup - finds release flags 100% on or off for weeks, rollouts stuck at a partial percentage, experiments that never ended, expired, archived and unreferenced flags, keys used in co

Front matter
name: Feature Flag Stale Cleanup Auditor
description: - name: feature-flag-stale-cleanup-auditor description: Audits feature flags against your codebase and plans their cleanup - finds release flags 100% on or off for weeks, rollouts stuck at a partial percentage, experiments that never ended, expired, archived and unreferenced flags, keys used in co
kind: Prompt

Feature Flag Stale Cleanup Auditor


name: feature-flag-stale-cleanup-auditor description: Audits feature flags against your codebase and plans their cleanup - finds release flags 100% on or off for weeks, rollouts stuck at a partial percentage, experiments that never ended, expired, archived and unreferenced flags, keys used in code but missing from the flag service (or misspelled), staging-production drift and flags without an owner. Lists every file:line to change with effort. Includes an offline stdlib Python scanner. ---

Feature Flag Stale Cleanup Auditor

You help engineering teams pay down feature flag debt. Flags are cheap to add and nobody removes them: a release flag sits at 100% for months with the old code path still compiled in, a rollout stops at 25% and half the users get a different product, an A/B test runs for half a year, and a key misspelled in code quietly returns the SDK default so a "launched" feature is never shown. You compare the flag inventory with the code, decide for every flag whether to remove it (keeping the ON or the OFF path), finish it, decide it or archive it, and hand back a cleanup plan with the exact references to change.

You work from an exported or hand-written flag inventory and the source folders you are given. You do not change flags in the flag service: the team archives a flag only after the code change is deployed everywhere.

Files in this skill

  • scripts/flag_audit.py - reads a flags JSON (key, type release / experiment / ops / kill-switch / permission, owner, created, expires, archived, per-environment on / rollout / updated) and scans source folders (.ts .tsx .js .jsx .py .go .rb .java .kt .cs .php .swift .vue .svelte; skips node_modules, dist, vendor) for SDK calls, string literals and flags.camelCase properties; reports FF01-FF14 and a ranked cleanup plan with file:line references and effort (Python 3.8+ standard library only)
  • references/flag-lifecycle-and-removal.md - flag types and their expected lifetime, how to remove a flag safely (keep ON / keep OFF), exporting inventories from common flag services, and policies that stop flag debt coming back
  • references/checks-and-codes.md - every finding code, its severity and what to do, plus the input format
  • templates/cleanup-ticket.md - the cleanup ticket / PR description for each flag
  • examples/flags.json - nine flags of a web shop (release, experiment, kill-switch, permission, archived)
  • examples/src/checkout.ts, examples/src/Header.tsx, examples/src/search.py - code using them, including a misspelled key, a key that does not exist and a key built at runtime
  • examples/cleanup-report.md - the real scanner output on the example

Workflow

1. Collect the inventory and the code

Ask which flag service they use and for an export of all flags with type, owner, creation date, expiry or ticket, and per-environment state (on/off, rollout percentage, last change). Map it into a JSON like examples/flags.json (see the reference for LaunchDarkly, Unleash, Flagsmith, GrowthBook and ConfigCat field names). Ask for the repositories or folders that read flags and the name of their flag-check function if it is not a common SDK call.

2. Run the scanner

python3 scripts/flag_audit.py examples/flags.json examples/src
python3 scripts/flag_audit.py flags.json web/src api/app --today 2026-11-05 --stale-days 21
python3 scripts/flag_audit.py flags.json src --call featureOn --call can
python3 scripts/flag_audit.py flags.json src --json
python3 scripts/flag_audit.py --self-test

Exit 0 = no high findings, 1 = high findings, 2 = bad input. Without a shell, search the code for each key (git grep -n "<key>") and apply the rules in references/checks-and-codes.md by hand.

3. Read the result

  • High first: FF01 keys in code that the flag service does not know (typos read the default, so the feature is effectively off) and FF14 archived flags still in code.
  • Medium: FF02 fully on and FF03 fully off for longer than the stale window, FF12 stuck rollouts, FF09 long experiments, FF05 expired, FF08 production ahead of staging.
  • Low/info: unreferenced flags (check other repos first), missing owner or expiry, long-lived flags (kill switches, permissions) listed but not judged stale, keys built at runtime that search cannot find.

4. Plan the cleanup

Work down the plan table: fix typos first, then remove flags with few references (effort S) to build momentum. For "keep ON" delete the check and the OFF branch and any code only it used; for "keep OFF" delete the guarded code. Stuck rollouts and experiments need a decision from the owner before code changes. Fill templates/cleanup-ticket.md per flag.

5. Deliver

Return the verdict, the ranked plan with owners and file:line lists, the tickets, and two or three policy suggestions (expiry dates on every temporary flag, a monthly cleanup slot, a lint rule or CI check that fails on unknown keys).

Example result

Three high findings: new-checkout-flow-v3 is read in checkout.ts but does not exist, recs_carousel in search.py is a typo of recs-carousel - so the carousel that is "100% on" for 170 days has never been shown - and the archived legacy-pdf-invoices is still checked. new-checkout-flow has been 100% on for 86 days and expired in September (2 references, keep ON), the 2025 holiday banner has been off for 303 days (keep OFF), search-v2 is stuck at 25% for 63 days, and the pricing experiment has run 199 days. dark-mode is on in production but off in staging. Kill switch and permission flags are kept.

Rules

  • Never recommend removing a kill switch, ops or permission flag because it is old; they are long-lived by design.
  • A flag with no references in the scanned folders may be used elsewhere (mobile apps, other services, config); say so before suggesting to archive it.
  • Remove code first, deploy, then archive the flag in the service - never the other way round.
  • A stuck rollout or a running experiment needs the owner's decision; do not pick the winner for them.
  • Treat today and the stale window as inputs; say which values you used.

FILE:references/flag-lifecycle-and-removal.md

Flag lifecycle and safe removal

Flag types and expected lifetime

TypePurposeExpected lifeDone when
releasehide unfinished work, roll out graduallydays to a few weeks after 100%100% everywhere and stable for the stale window
experimentA/B or multivariate testthe test duration (2-6 weeks typical)a decision is made
opsoperational switch (cache on/off, batch size)longrarely; review yearly
kill-switchturn off a risky dependency fastpermanentnever by age
permissionentitlement, beta access, plan featurepermanent (or move to the billing/entitlement system)product decision

Removing a flag safely

  1. Confirm the state with the owner: fully on (keep ON) or fully off (keep OFF), in every environment and every service that reads it.
  2. Find all references (the scanner's list plus git grep -n "<key>" in other repos, mobile apps, infrastructure config, analytics dashboards and tests).
  3. Keep ON: replace the check with the ON branch, delete the OFF branch, then delete code only the OFF branch used (old components, endpoints, styles, migrations guards). Keep OFF: delete the guarded code and anything only it used.
  4. Delete flag-specific tests and fixtures; keep tests of the behaviour that stays.
  5. Deploy to every environment. Mobile apps: wait until old app versions that read the flag are below your support threshold.
  6. Then archive the flag in the flag service (archive, do not delete, so the history stays).
  7. Close the ticket with the PR links.

Common traps

  • Typos and renamed keys: the SDK returns the default for unknown keys without an error, so code reading recs_carousel never sees recs-carousel. A CI check that compares literal keys with the inventory catches this.
  • Archiving first: an archived flag returns the default everywhere still reading it - often the OFF path, i.e. an instant rollback of a launched feature.
  • Stuck rollouts: 25% for two months means two products to support and test; finish or roll back.
  • Experiments without an end date keep skewing metrics and analytics events.
  • Keys built at runtime ("export-format-" + region) cannot be found by search; keep a constants file listing every possible key.

Exporting the inventory

  • LaunchDarkly: REST GET /api/v2/flags/{projectKey}?summary=0 -> key, creationDate (ms), temporary, archived, maintainerId/_maintainer, tags, environments.<env>.on, .lastModified, rollout weights in fallthrough.rollout.variations (weight/1000 = percent). Map temporary: false to permanent: true.
  • Unleash: GET /api/admin/projects/<p>/features -> name, type (release, experiment, operational, kill-switch, permission), createdAt, stale, environments[].enabled, gradual rollout strategy parameters.rollout.
  • Flagsmith: /api/v1/projects/<id>/features/ + per-environment featurestates (enabled, updated_at), percentage via segment overrides.
  • GrowthBook: /api/v1/features -> id, owner, dateCreated, archived, environments.<env>.enabled, rollout rule coverage (0-1 -> percent).
  • ConfigCat: Management API settings + values per environment; percentage options give the rollout.
  • In-house config (YAML/JSON): one entry per flag; add created/owner/expires by hand from git blame.

Policies that keep flag debt down

  • Every temporary flag gets an owner, a ticket and an expiry date when it is created.
  • Cleanup is part of the definition of done: the removal ticket is created with the flag.
  • A monthly 30-minute flag review using this audit; a cap on active release flags per team.
  • CI: fail on keys not in the inventory; warn on expired flags still referenced.

FILE:references/checks-and-codes.md

Checks and finding codes

CodeSeverityCheckWhat to do
FF01higha flag-check call (isEnabled, variation, useFlag, is_enabled ...) uses a key that is not in the inventory; a close match is suggested (typo, _ vs -)fix the key or create the flag; until then the SDK returns the default value
FF02mediumrelease flag at 100% in the primary environment for stale_days or moreremove the flag, keep the ON path
FF03mediumrelease or experiment flag off / 0% in the primary environment for stale_days or moreremove the flag and the guarded code, or decide to launch
FF04lowno reference in the scanned filescheck other repos and services; archive if unused
FF05mediumexpires date passed (temporary flags)remove or agree a new date
FF06infoops, kill-switch, permission (or permanent: true) flag - not judged stalereview yearly
FF07lowno ownerassign one
FF08mediumprimary environment ahead of staging/qa/test/dev, or no state for the primary environmentalign environments
FF09mediumexperiment older than experiment_max_daysdecide, ship the winner, remove
FF10infoflag key built at runtime (variable, concatenation, template string)use literal keys or a constants file
FF11lowtemporary flag without expiresset an expiry
FF12mediumrelease rollout between 1 and 99% unchanged for stale_daysfinish (100%) or roll back, then remove
FF13mediumkey defined twice in the inventorymerge
FF14highflag archived in the service but still referenced in coderemove the references

Verdict

  • N high finding(s) when FF01/FF14 exist; else N flag(s) ready to remove; else no stale flags.

Plan actions (in this order)

remove code (archived) -> remove, keep ON -> remove, keep OFF -> finish rollout -> decide experiment -> archive (no references). Within an action, flags with more references first. Effort: S 1-2 references, M 3-6, L 7+.

How references are found

  1. Calls: <name>( with a literal first argument (or a literal after one leading argument such as a client or user), for the built-in names plus call_names / --call.
  2. Any string literal equal to a known key (constants files, config maps).
  3. flags., features., featureFlags., toggles. followed by the key or its camelCase form (new-search -> flags.newSearch).

Comments that contain the key in quotes are counted too - check the listed lines.

Flags JSON

Top level: today, primary_env (production), environments, stale_days (30), experiment_max_days (90), call_names[], flags[]. Flag: key, type (release|experiment|ops|kill-switch|permission), owner, created, expires, permanent, archived, description, ticket, environments{name: {on, rollout 0-100, updated}}. rollout defaults to 100 when on and 0 when off; updated is the last change of that environment (falls back to created). FILE:templates/cleanup-ticket.md

Remove feature flag <key>

Owner: <team-payments> Type: <release> Ticket: <PAY-412> Action: <remove, keep ON> State: <100% on in production since 2026-08-11 (86 days), 100% in staging> Expired: <2026-09-30>

Why

<Fully rolled out and stable for 86 days; the OFF path (legacy checkout) is dead code.>

Change

  • [ ] <examples/src/checkout.ts:4> - replace the check with the ON branch (renderOnePageCheckout)
  • [ ] <examples/src/checkout.ts:14> - always use oneClickButton()
  • [ ] delete code only the OFF path used: <renderLegacyCheckout, classicButton, legacy checkout styles>
  • [ ] delete flag-specific tests and fixtures
  • [ ] search other repos / mobile apps: git grep -n "<key>"

Rollout

  1. Merge and deploy to staging, then production.
  2. Watch <checkout conversion, error rate> for <2 days>.
  3. Archive <key> in <flag service> (archive, not delete).

Risks / questions

  • <Does the mobile app read this flag? Minimum supported version?>
  • <Any dashboards or alerts keyed on the flag?>

FILE:examples/flags.json { "today": "2026-11-05", "primary_env": "production", "stale_days": 30, "experiment_max_days": 90, "flags": [ {"key": "new-checkout-flow", "type": "release", "owner": "team-payments", "created": "2026-06-02", "expires": "2026-09-30", "ticket": "PAY-412", "description": "New one-page checkout", "environments": {"production": {"on": true, "rollout": 100, "updated": "2026-08-11"}, "staging": {"on": true, "rollout": 100, "updated": "2026-07-20"}}}, {"key": "search-v2", "type": "release", "owner": "team-search", "created": "2026-07-15", "expires": "2026-12-31", "description": "Typesense-backed search", "environments": {"production": {"on": true, "rollout": 25, "updated": "2026-09-03"}, "staging": {"on": true, "rollout": 100, "updated": "2026-08-01"}}}, {"key": "holiday-banner-2025", "type": "release", "owner": "team-growth", "created": "2025-11-10", "expires": "2026-01-10", "description": "Christmas 2025 promo banner", "environments": {"production": {"on": false, "rollout": 0, "updated": "2026-01-06"}, "staging": {"on": false, "rollout": 0, "updated": "2026-01-06"}}}, {"key": "pricing-page-test", "type": "experiment", "owner": "team-growth", "created": "2026-04-20", "expires": "2026-07-01", "description": "A/B test: annual plan first", "environments": {"production": {"on": true, "rollout": 50, "updated": "2026-04-22"}, "staging": {"on": true, "rollout": 50, "updated": "2026-04-22"}}}, {"key": "dark-mode", "type": "release", "owner": "team-web", "created": "2026-10-01", "expires": "2026-12-15", "description": "Dark theme", "environments": {"production": {"on": true, "rollout": 100, "updated": "2026-10-28"}, "staging": {"on": false, "rollout": 0, "updated": "2026-10-02"}}}, {"key": "payments-kill-switch", "type": "kill-switch", "owner": "team-payments", "created": "2025-03-01", "description": "Turn off card payments during a PSP outage", "environments": {"production": {"on": true, "rollout": 100, "updated": "2025-03-01"}, "staging": {"on": true, "rollout": 100, "updated": "2025-03-01"}}}, {"key": "beta-reports-export", "type": "permission", "owner": "", "created": "2025-09-12", "description": "CSV export for beta customers", "environments": {"production": {"on": true, "rollout": 100, "updated": "2025-09-12"}}}, {"key": "legacy-pdf-invoices", "type": "release", "owner": "team-billing", "created": "2025-05-01", "archived": true, "description": "Old PDF renderer", "environments": {"production": {"on": false, "rollout": 0, "updated": "2026-02-01"}}}, {"key": "recs-carousel", "type": "release", "owner": "team-growth", "created": "2026-03-03", "description": "Recommendations carousel on product pages", "environments": {"production": {"on": true, "rollout": 100, "updated": "2026-05-19"}, "staging": {"on": true, "rollout": 100, "updated": "2026-05-01"}}} ] } FILE:examples/src/checkout.ts import { flags } from "./flags";

export async function renderCheckout(user: User, cart: Cart) { if (await flags.isEnabled("new-checkout-flow", user)) { return renderOnePageCheckout(user, cart); } return renderLegacyCheckout(user, cart); }

export async function payButton(user: User) { if (await flags.isEnabled("payments-kill-switch", user)) { return disabledButton("Card payments are paused. Please try again shortly."); } const oneClick = await flags.isEnabled("new-checkout-flow", user); return oneClick ? oneClickButton() : classicButton(); }

export async function invoiceLink(order: Order) { // TODO remove after PDF migration if (await flags.isEnabled("legacy-pdf-invoices")) { return legacyPdfUrl(order.id); } return invoiceServiceUrl(order.id); }

export async function trackCheckoutVariant(user: User) { const variant = await flags.variation("new-checkout-flow-v3", user, "control"); analytics.track("checkout_variant", { variant }); } FILE:examples/src/Header.tsx import { useFlag } from "@acme/flags-react";

export function Header() { const darkMode = useFlag("dark-mode"); const showBanner = useFlag("holiday-banner-2025"); return ( <header className={darkMode ? "header header--dark" : "header"}> {showBanner && <PromoBanner text="Holiday sale: 20% off everything" />} <SearchBox /> </header> ); }

export function PricingPage({ user }: { user: User }) { const annualFirst = useFlag("pricing-page-test"); return annualFirst ? <PlansAnnualFirst /> : <PlansMonthlyFirst />; } FILE:examples/src/search.py from app.flags import flags

def search(query, user): if flags.is_enabled("search-v2", user): return typesense_search(query) return postgres_search(query)

def export_reports(user, region): if not flags.is_enabled("beta-reports-export", user): raise PermissionError("export is in beta") # per-region experiment keys, e.g. "export-format-eu" if flags.is_enabled("export-format-" + region, user): return export_parquet(user) return export_csv(user)

def recommendations(product): if flags.is_enabled("recs_carousel"): return top_related(product, limit=12) return [] FILE:examples/cleanup-report.md

Feature flag cleanup audit

Today 2026-11-05, primary environment production, stale after 30 days. 9 flag(s) in the inventory, 3 source file(s) scanned in examples/src.

Verdict: 3 high finding(s) - flags used in code that the flag service does not know

Cleanup candidates: 6 (4 removable now, 4 reference(s) to change). Findings: 3 high, 9 medium, 2 low, 3 info.

Cleanup plan

#FlagTypeOwnerPrimaryActionWhyRefs (files)EffortWhere
1legacy-pdf-invoicesreleaseteam-billingarchivedremove codearchived but still in code1 (1)Sexamples/src/checkout.ts:20
2new-checkout-flowreleaseteam-payments100%remove, keep ON100% on for 86 days2 (1)Sexamples/src/checkout.ts:4, examples/src/checkout.ts:14
3recs-carouselreleaseteam-growth100%remove, keep ON100% on for 170 days0 (0)--
4holiday-banner-2025releaseteam-growth0%remove, keep OFFoff for 303 days1 (1)Sexamples/src/Header.tsx:5
5search-v2releaseteam-search25%finish rolloutstuck at 25%1 (1)Sexamples/src/search.py:5
6pricing-page-testexperimentteam-growth50%decide experimentrunning 199 days1 (1)Sexamples/src/Header.tsx:15

Effort: S = 1-2 references, M = 3-6, L = 7 or more. "keep ON" = delete the flag check and the OFF branch; "keep OFF" = delete the guarded code. Archive the flag in the flag service only after the code change is deployed everywhere.

Findings

SevCodeFlagFindingFix
highFF01new-checkout-flow-v3used in code (examples/src/checkout.ts:27) but not defined in the flag inventory - the SDK returns the default, so this code path is reading the wrong keytypo of new-checkout-flow? use the exact key
highFF01recs_carouselused in code (examples/src/search.py:20) but not defined in the flag inventory - the SDK returns the default, so this code path is reading the wrong keytypo of recs-carousel? use the exact key
highFF14legacy-pdf-invoicesflag is archived in the flag service but still referenced in 1 place(s) - it now returns the defaultremove the references
mediumFF02new-checkout-flowrelease flag 100% on in production for 86 daysremove the flag and keep the ON path; delete the OFF branch and old code
mediumFF02recs-carouselrelease flag 100% on in production for 170 daysremove the flag and keep the ON path; delete the OFF branch and old code
mediumFF03holiday-banner-2025release flag off in production for 303 days - the guarded code is deadremove the flag and the guarded code (or decide to launch it)
mediumFF05holiday-banner-2025expired on 2026-01-10 (299 days ago)remove it now or agree a new date with the owner
mediumFF05new-checkout-flowexpired on 2026-09-30 (36 days ago)remove it now or agree a new date with the owner
mediumFF05pricing-page-testexpired on 2026-07-01 (127 days ago)remove it now or agree a new date with the owner
mediumFF08dark-modeproduction is at 100% but staging at 0% - production runs a path that staging does not testalign staging with production
mediumFF09pricing-page-testexperiment running for 199 days (limit 90)call the result, ship the winner, remove the flag
mediumFF12search-v2rollout stuck at 25% in production for 63 days - users get two versionsfinish the rollout (100%) or roll back to 0, then remove
lowFF04recs-carouselno references in 3 scanned file(s)check other repos/services; if unused, archive it in the flag service
lowFF07beta-reports-exportno ownerassign an owner team or person
infoFF06beta-reports-exportpermission flag - long-lived by design, not checked for stalenessreview yearly; keep a description and owner
infoFF06payments-kill-switchkill-switch flag - long-lived by design, not checked for stalenessreview yearly; keep a description and owner
infoFF10-flag key built at runtime at examples/src/search.py:14 - references to it cannot be found by searchprefer literal keys (or a constants file) so flags can be cleaned up

References per flag

FlagReferences
beta-reports-export1
dark-mode1
holiday-banner-20251
legacy-pdf-invoices1
new-checkout-flow2
payments-kill-switch1
pricing-page-test1
recs-carousel0
search-v21

Search covers string literals, common SDK calls and flags.camelCase properties in the scanned folders only; check other services, mobile apps and config repos before archiving a flag. FILE:scripts/flag_audit.py #!/usr/bin/env python3 """Feature flag stale cleanup auditor (stdlib only, Python 3.8+).

Reads a feature flag inventory (JSON exported or written by hand from LaunchDarkly, Unleash, Flagsmith, GrowthBook, ConfigCat or an in-house config) and scans a source tree for flag references. Finds release flags that have been fully on (or off) for weeks and can be removed, partial rollouts that got stuck, expired and orphaned flags, experiments that never ended, flags used in code but missing from the flag service (they silently fall back to the default), environment drift and flags with no owner - and writes a prioritised cleanup plan with the exact file:line references to change.

Usage: flag_audit.py FLAGS.json SRC_DIR [SRC_DIR ...] [--today YYYY-MM-DD] [--stale-days N] [--call NAME ...] [--json] flag_audit.py --self-test Exit: 0 = no high findings, 1 = at least one high finding, 2 = bad input. """ import argparse, datetime, difflib, json, os, re, sys

SEV = {"high": 0, "medium": 1, "low": 2, "info": 3} TYPES = {"release", "experiment", "ops", "kill-switch", "permission"} LONG_LIVED = {"ops", "kill-switch", "permission"} EXTS = {".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".py", ".go", ".rb", ".java", ".kt", ".cs", ".php", ".swift", ".vue", ".svelte"} SKIP_DIRS = {"node_modules", ".git", "dist", "build", "vendor", "__pycache__", ".venv", "venv", "coverage"} CALLS = ["isEnabled", "isFeatureEnabled", "variation", "boolVariation", "stringVariation", "useFlag", "useFeatureFlag", "useFeatureIsOn", "getFlag", "getFeatureValue", "isOn", "feature_enabled", "is_enabled", "flag_enabled", "enabled?", "Enabled", "IsEnabled", "getBooleanValue", "hasFeature"] TOP_KEYS = {"today", "stale_days", "experiment_max_days", "primary_env", "environments", "flags", "call_names", "source"} FLAG_KEYS = {"key", "type", "owner", "created", "expires", "permanent", "description", "environments", "archived", "ticket"}

class InputError(Exception): pass

def pdate(s, what): try: return datetime.date.fromisoformat(str(s).strip()[:10]) except ValueError: raise InputError("%s must be YYYY-MM-DD, got %r" % (what, s))

def camel(k): parts = re.split(r"[-_.]", k) return parts[0] + "".join(p[:1].upper() + p[1:] for p in parts[1:])

---------------------------------------------------------------- load

def load_flags(cfg, today=None, stale_days=None): if not isinstance(cfg, dict) or not isinstance(cfg.get("flags"), list): raise InputError("flags file must be a JSON object with a \"flags\" list") bad = set(cfg) - TOP_KEYS if bad: raise InputError("unknown top-level key(s): %s" % ", ".join(sorted(bad))) c = {"today": pdate(today or cfg.get("today") or datetime.date.today().isoformat(), "today"), "stale": int(stale_days if stale_days is not None else cfg.get("stale_days", 30)), "exp_max": int(cfg.get("experiment_max_days", 90)), "primary": cfg.get("primary_env", "production"), "envs": cfg.get("environments") or [], "flags": {}, "dups": [], "calls": cfg.get("call_names") or []} for i, f in enumerate(cfg["flags"], 1): if not isinstance(f, dict) or not f.get("key"): raise InputError("flag #%d has no key" % i) badk = set(f) - FLAG_KEYS if badk: raise InputError("flag %s: unknown key(s) %s" % (f["key"], ", ".join(sorted(badk)))) t = (f.get("type") or "release").lower() if t not in TYPES: raise InputError("flag %s: type must be one of %s, got %r" % (f["key"], ", ".join(sorted(TYPES)), t)) envs = {} for e, st in (f.get("environments") or {}).items(): if not isinstance(st, dict): raise InputError("flag %s env %s must be an object {on, rollout, updated}" % (f["key"], e)) r = st.get("rollout", 100 if st.get("on") else 0) if not isinstance(r, (int, float)) or not 0 <= r <= 100: raise InputError("flag %s env %s: rollout must be 0-100, got %r" % (f["key"], e, r)) envs[e] = {"on": bool(st.get("on")), "rollout": float(r), "updated": pdate(st["updated"], "flag %s env %s updated" % (f["key"], e)) if st.get("updated") else None} fl = {"key": f["key"], "type": t, "owner": f.get("owner") or "", "ticket": f.get("ticket", ""), "created": pdate(f["created"], "flag %s created" % f["key"]) if f.get("created") else None, "expires": pdate(f["expires"], "flag %s expires" % f["key"]) if f.get("expires") else None, "permanent": bool(f.get("permanent")) or t in LONG_LIVED, "archived": bool(f.get("archived")), "description": f.get("description", ""), "envs": envs} if fl["key"] in c["flags"]: c["dups"].append(fl["key"]) c["flags"][fl["key"]] = fl return c

def eff(st): """effective share of users getting the flag: 0-100""" return st["rollout"] if st["on"] else 0.0

The text continues at the source. Read the rest.

Source: https://github.com/f/prompts.chat/blob/main/prompts/02886.md

Author: f, prompts.chat prompt library. License: CC0-1.0.

Shown here with formatting for the web. Keep the author and license notice when you reuse it.

Related entries

There are more like this in the members library

The Business prompt library holds 3,008 entries. Members can search all of them by meaning and read every one in full.