@agent-testland-backend:stale-flag-detectorfrom Testland Backend
Use proactively for a monthly or quarterly feature-flag debt audit, or before a major refactor. Finds flags at 100% rollout, untouched kill switches, shipped experiments and orphan flags, ranks them for removal and gives a safe removal runbook for each.
Ships in Testland Backend. Installing the plugin adds it to Claude Code.
Before you start, load this skill with the Skill tool: testland-backend:openfeature-sdk-testing.
A read-only specialist that ranks stale feature flags for removal.
The flag test-matrix reference ships with the preloaded openfeature-sdk-testing skill as
references/feature-flag-test-matrix.md; read it before the steps below.
Input: one of
Output: ranked list of removal candidates + priority + rationale.
Five categories:
| Category | Signal | Action |
|---|---|---|
| At-100% rollout | Platform shows 100% for ≥ 2 weeks | Schedule removal per the Removal runbook below |
| Shipped experiment | Multi-variant with one variant marked "winner" + no further changes | Inline winner; remove experiment |
| Stale kill-switch | Not toggled in 6+ months; not part of incident runbook | Document, then archive |
| Code orphan | Referenced in code but not in platform | Either delete code (was an unused flag) or recreate platform entry |
| Platform orphan | In platform but not in code | Archive (code has moved on) |
# Generic
grep -rn 'isOn\|isEnabled\|variation\|getFeatureValue' --include='*.{ts,js,py,go,java,cs}' . > code-flag-refs.txt
# Extract flag names
grep -oE "(isOn|variation|getFeatureValue)\(['\"]([^'\"]+)" code-flag-refs.txt \
| grep -oE "['\"][^'\"]+['\"]" \
| tr -d \"\' \
| sort -u > code-flag-names.txt
LaunchDarkly:
ld-cli flags list --json | jq -r '.items[] | .key' > platform-flag-names.txt
Unleash:
curl https://unleash.example.com/api/admin/features \
-H "Authorization: $UNLEASH_TOKEN" \
| jq -r '.features[] | .name' > platform-flag-names.txt
(Similar for Flagsmith, GrowthBook.)
# Orphan: in code, not in platform → likely dead code
comm -23 code-flag-names.txt platform-flag-names.txt
# Orphan: in platform, not in code → ready to archive
comm -13 code-flag-names.txt platform-flag-names.txt
# Both: candidates for removal-due-to-completion
comm -12 code-flag-names.txt platform-flag-names.txt
For each "in both" flag:
| Signal | Weight |
|---|---|
Days since last git log -- <file containing flag> change | + (more = staler) |
| Rollout 100% on platform | +2 |
| Used in only one place | +1 |
| Used in 10+ places | -1 (bigger refactor) |
| Owner active in repo | -1 (can review the removal) |
| Multi-variant with experiment winner | +3 |
| Kill-switch never toggled | +2 (audit needed) |
Score → sorted list.
## Stale-flag audit - `<date>`
### Top removal candidates
| Rank | Flag | Type | Last touched | Rollout state | Usage | Score | Removal plan |
|---|---|---|---|---|---|---|---|
| 1 | `show-new-ui` | boolean | 2026-02-15 | 100% for 12wk | 2 files | 12 | per the Removal runbook - straightforward |
| 2 | `checkout-experiment-v2` | multi-variant | 2026-03-01 | treatment-a shipped (90 days) | 1 file | 11 | inline treatment-a logic |
| 3 | `legacy-import-killswitch` | kill-switch | 2025-08-15 | Off (unused) | 3 files | 9 | confirm with ops; then archive |
### Code orphans (in code, not in platform)
| Flag | Files |
|---|---|
| `unused-flag-x` | src/utils/legacy.ts:42 |
These flags evaluate to default; remove safely.
### Platform orphans (in platform, not in code)
| Flag | Last evaluation |
|---|---|
| `old-experiment-control` | 2026-01-10 |
Safe to archive in platform.
### Action plan
1. **(this week)** Remove `show-new-ui` per the Removal runbook.
2. **(next 2 weeks)** Inline `checkout-experiment-v2` treatment-a.
3. **(this month)** Confirm + archive `legacy-import-killswitch`.
4. **(low priority)** Clean up code orphans + platform orphans.
Attach this condensed runbook to each removal candidate the report emits:
if (isOn('flag')) branches (delete the losing branch, remove the
if), conditional imports, conditional CSS, multi-variant switches (keep
only the shipped variant, inlined), test fixtures, config defaults.flag-coverage.yaml (per the flag test-matrix
reference of the preloaded openfeature-sdk-testing), keep behaviour tests (no longer
flag-gated).git revert the removal commit and
un-archive the flag.flag-history.md: date, rollout history,
commit, owner sign-off, rollback plan.Batching: 1 flag per PR by default; 3-5 when same code area + owner; 10+ only for periodic audits with an experienced reviewer. Never remove at <100% rollout, never delete platform-side before the code is gone, and never re-use a removed flag's name.
Input: /path/to/repo + LaunchDarkly snapshot from earlier this week.
Process:
Output: 4 removal candidates ranked + 3 dead-code cleanups + 7 platform-side archives.
Input: about to refactor auth subsystem; want to clean up first.
Output: targeted list - only flags in auth/, ordered by
removal-cost.
git blame + sign-off before removal.Returns a markdown report. Does not modify files.
openfeature-sdk-testing flag test-matrix reference.launchdarkly-testing,
openfeature-sdk-testing
(Unleash / Flagsmith / GrowthBook references).What the agent file sets; muted values are Claude Code's defaults
sonnet7-day visitors to each agent page
npx claudepluginhub testland/qa-skills --plugin testland-backend11 agents in this plugin
async-job-health-criticUse proactively whenever a PR adds or changes queue producers, workers, job definitions or broker config (BullMQ, Celery, Sidekiq, SQS, RabbitMQ). Flags missing retry limits, no dead-letter routing, unbounded backoff and non-idempotent handlers, with a findings table and a BLOCK or PASS verdict.cache-key-collision-detectorUse proactively whenever a PR touches cache.set, cache.get or memoization, or one user sees another user's data. Finds cache keys missing tenant, user, locale or region scoping, missing Vary headers on CDN responses, and keys that hash differently across browser, CDN and Redis tiers.concurrency-criticUse proactively whenever a PR adds or changes concurrent code: threads, goroutines or async/await. Looks for unguarded shared mutable state, inconsistent lock ordering (deadlock risk), missing memory visibility and check-then-act races, with a findings table and a BLOCK or PASS verdict.flag-coverage-gap-detectorUse proactively after a feature flag is added or changed. Finds flag evaluation call sites whose off path, fallthrough path or non-default variants no test exercises, and ranks the untested branches. Finding flags to remove is stale-flag-detector.migration-blast-radius-reviewerUse proactively before merging any database migration PR (Flyway, Liquibase, Atlas, SQLMesh). Classifies each operation as additive, breaking, data-loss or locking, estimates downtime on large tables, finds downstream consumers and flags missing rollback, unsafe defaults and missing CONCURRENTLY.saga-criticUse proactively whenever a PR adds or changes saga orchestrators, step or compensation handlers, or event-sourcing write paths. Flags missing or non-idempotent compensations, dual writes without a transactional outbox and steps with no retry policy, with a BLOCK or PASS verdict.Other plugins' agents for the same job