Engineering
Feature Flag Retirement Sweep
Retire stale flags before yesterday's rollout logic becomes tomorrow's haunted house.
Use when
Feature flags, experiments, or kill switches have outlived their rollout and are making code paths harder to reason about.
Intermediatedifficulty
Engineeringcategory
Mia daily expansionsource
Cadence
Monthly or after a rollout stabilizes
Verification
Each reviewed flag has an owner, purpose, current state, and retirement decision; removed flags pass tests and require approval before production config changes.
Structured loop spec
| Field | Value |
|---|---|
| Name | Feature Flag Retirement Sweep |
| Category | Engineering |
| Trigger | Monthly or after a rollout stabilizes |
| Objective | Retire stale flags before yesterday's rollout logic becomes tomorrow's haunted house. |
| Allowed inputs | Relevant files, source notes, logs, tests, screenshots, metrics, or task state for this loop |
| Allowed actions | Inventory flags from code, config, dashboards, experiment tools, and docs, then record owner, creation date, default state, and rollout status where available.; Classify each flag as active, permanent safety switch, stale candidate, unknown owner, or approval-required.; Choose one low-risk stale flag whose production state and usage are proven by telemetry, config, or owner confirmation.; Remove the dead branch, tests, docs, and config references in the smallest reversible patch.; Run focused tests and static searches; do not flip production config, delete live experiment data, or remove safety switches without explicit approval. |
| Verification | Each reviewed flag has an owner, purpose, current state, and retirement decision; removed flags pass tests and require approval before production config changes. |
| Stop condition | Stop when the verifier passes, the budget is exhausted, no progress is made, a blocker appears, or approval is required. |
| Budget | Set a time, turn, token, retry, file, or dollar cap before running the loop. |
| Approval boundary | Human approval required before publishing, sending, deleting, spending, changing accounts, touching production, or making reputational/legal/financial commitments. |
| Safe output | Pull request, patch, report, or evidence log |
| Works with | Claude Code, OpenAI Codex, Cursor, Gemini CLI, any tool-using coding agent |
Steps
- Inventory flags from code, config, dashboards, experiment tools, and docs, then record owner, creation date, default state, and rollout status where available.
- Classify each flag as active, permanent safety switch, stale candidate, unknown owner, or approval-required.
- Choose one low-risk stale flag whose production state and usage are proven by telemetry, config, or owner confirmation.
- Remove the dead branch, tests, docs, and config references in the smallest reversible patch.
- Run focused tests and static searches; do not flip production config, delete live experiment data, or remove safety switches without explicit approval.
Prompt
Run the Feature Flag Retirement Sweep loop. Inventory feature flags, experiment gates, and kill switches from code, config, dashboards, and docs. For each reviewed flag, record owner, purpose, current state, rollout status, and retirement decision. Select one low-risk stale flag with evidence, remove dead code/docs/tests/config references in a reversible patch, and verify with focused tests plus static searches. Do not change production config, delete experiment data, or remove safety switches without approval. Return the retired flag, evidence, diff summary, and remaining flag queue.Run in Claude Code
Paste this into Claude Code (or any tool-using agent) to run the loop bounded: one change per round, the same verification every round, durable state files, and explicit stop conditions.
Run the "Feature Flag Retirement Sweep" loop from AI Loop Library (https://ailooplibrary.com/loops/feature-flag-retirement-sweep/) as a bounded loop.
Goal: Retire stale flags before yesterday's rollout logic becomes tomorrow's haunted house.
Rules: one change per round; run the same verification every round (Each reviewed flag has an owner, purpose, current state, and retirement decision; removed flags pass tests and require approval before production config changes.); append each round to docs/loops/feature-flag-retirement-sweep/progress.md and update docs/loops/feature-flag-retirement-sweep/state.json; stop on verifier pass, 8 rounds, 3 consecutive failed verifications, no progress, a blocker, or anything needing human approval (money, production, outbound, deletion). Finish with a proof report: rounds used, changes made, verification output, remaining risk, and the next human decision.