Agents write more code. Humans still decide what stays. Feature flags are one of the few runtime signals that answer that with production evidence instead of a design-doc argument.
A flag that never graduates becomes permanent branching. A flag that graduates and never gets deleted becomes dead control flow. Both slow the next change, whether a person or an agent makes it.
This is an OSS walkthrough of that problem on Grafana's JavaScript and TypeScript frontend. Grafana is mid-migration from legacy config.featureToggles reads to OpenFeature. The patterns are public. The tooling below is for any team stuck in the same dual-API stretch, Grafana included if it helps.
Follow the live numbers on the OpenFeature Usage Compliance Insights board for grafana/grafana, and grab the OpenFeature packages on the Codemod Registry — compliance mining and stale-flag cleanup — if you want to run the same loop on your own tree.
Feature flags matter more when shipping gets cheaper
When code is expensive, teams debate features in advance. When code is cheap, they ship variants and let reality pick.
Flags keep that experiment reversible. They hide unfinished work, gate canaries, degrade a hot path, and show which behavior users actually hit. In an AI-heavy workflow that produces more diffs per week, that runtime vote is often the cleanest answer to "what should we keep building?"
Then the operational mess shows up. Flags pile up. Evaluation APIs fork after a vendor change or an internal rewrite. Tests pin the old helper. Lint suppressions paper over the gap. Six months later nobody trusts a text search for featureToggles, and agents walk into the same fog.
If flags are how you learn what to ship, the evaluation surface has to stay coherent enough that people and tools can inventory it.
OpenFeature is the evaluation contract that survives vendor changes
OpenFeature is a CNCF incubating project: a vendor-agnostic API for feature flagging that sits in front of commercial providers, open source systems, or an in-house backend.
Teams migrate to it for concrete reasons, not branding:
Benefit | Why it shows up in real migrations |
Vendor-neutral evaluation API | Application code talks to one SDK shape. Providers swap underneath without a repo-wide rewrite. |
Multi-provider consolidation | Mergers and platform teams can keep several backends behind one interface while they consolidate. |
Shared evaluation context | User, tenant, and request attributes travel with the evaluation instead of ad hoc globals. |
Hooks and events | Telemetry, validation, and cache invalidation plug into the evaluation lifecycle instead of every call site. |
Language coverage with one model | Frontend and backend can share flag names and semantics even when the SDKs differ. |
Community providers and extensions | You inherit integrations instead of rebuilding every vendor adapter in-house. |
Adopting OpenFeature does not delete legacy reads. It adds a second, correct path while the old one still compiles. That dual period is where migrations stall.
Grafana's frontend already runs two feature-flag APIs side by side
Grafana's contributor docs are blunt about why the legacy path is unsafe. config.featureToggles is a static bootData snapshot. On the multi-tenant frontend service that map can be empty, so reads resolve to false even when the OpenFeature value is enabled. Reading the old map is not "legacy but fine." It can disagree with production.
The recommended JS/TS path is generated OpenFeature surfaces: React hooks such as useFlagPlaylistsRBAC(), or getFeatureFlagClient().getBooleanValue(...) for non-React code. Tests should move from testWithFeatureToggles to setTestFlags. Flags can keep both LegacyFrontend and React generation targets while call sites migrate.
Point the compliance miner at that tree and the dual stack becomes a dashboard, not a hunch. On grafana/grafana, OpenFeature Usage Compliance currently shows about 2,068 flag usages: roughly 1,687 OpenFeature-compliant and 381 still on the legacy path, owned mostly by feature squads rather than a single platform team. Those are mined openfeature_flag_usage hits, not a claim about Grafana's roadmap.
A single module can already mix both worlds:
import { config } from "@grafana/runtime";
import { FlagKeys, getFeatureFlagClient, useFlagPlaylistsRBAC } from "@grafana/runtime/internal";
export function routes() {
const legacy = config.featureToggles.suggestedDashboards;
const modern = getFeatureFlagClient().getBooleanValue(FlagKeys.PlaylistsRBAC, false);
const hook = useFlagPlaylistsRBAC();
return legacy || modern || hook;
}If your migration plan is "grep for featureToggles and open PRs," you will miss compliant sites, mis-count progress, and leave tests on the helper that no longer gates the migrated read.
Mine compliance before you rewrite call sites
The first useful automation is read-only.
openfeature-compliance-mining is a Codemod Registry package that scans TypeScript and TSX, classifies each evaluation site as OpenFeature-compliant or legacy, and emits an openfeature_flag_usage metric. It does not rewrite files. Migration progress is a measurement problem before it is a transform problem.
The miner knows Grafana-shaped patterns on purpose:
Compliance | Pattern | Example |
Compliant | Generated React hook |
|
Compliant | Client evaluation |
|
Compliant | React SDK helper |
|
Compliant | OpenFeature test helper |
|
Non-compliant | Legacy boot map |
|
Non-compliant | Legacy test helper |
|
Each hit carries compliance, pattern, flag_key, scope (production vs test), file, line, and enclosing symbol. That is enough to build a burndown, split work by CODEOWNER, and keep agents from "fixing" files that are already on the new API.
Run it with the Codemod CLI:
npx codemod run openfeature-compliance-mining -t /path/to/grafana --dry-run --reportWire the same metric into Codemod Insights if you want a board instead of a one-off report. On Grafana's frontend the board makes the dual period concrete: KPI tiles for total / compliant / non-compliant, then CODEOWNER tables that show who still owns legacy reads.

The timeseries view is what you staff from after the inventory. Compliant climbs when call sites move. Non-compliant falls when a squad finishes a slice. Team lines tell you whether the leftover debt is concentrated or spread.

Migration work starts when legacy and compliant counts share one schema.
Migration is call-site work, not a single SDK swap
Grafana's own guidance matches what the miner assumes. Keep the flag name. Add OpenFeature generation next to the legacy frontend target. Move reads to the generated hook or client. Update tests to setTestFlags and reset them in afterEach. Leave Go and backend clients out of the JS/TS inventory unless you are ready to mine those separately.
That is why a compliance miner beats a blind rewrite. Many "migrations" fail because someone automated the mechanical edit before they could prove which sites still disagreed with production. The miner makes the dual period visible. Humans (or agents with a scoped task) still own the semantic move: React rules about hooks, default-value flips for default-on flags, and test suites that suddenly take the new path.
If you are adapting this outside Grafana, keep the same split. Teach the miner your legacy API and your OpenFeature shapes first. Only then write the transform that turns a non-compliant site into a compliant one.
Stale flags are the second half of the same maintenance loop
Migrating the evaluation API does not remove flags that already won.
Once a flag is permanently on or off, every remaining evaluation is debt. Branching stays. Dead imports stay. Agents keep reading both arms of an if that production never takes. Humans pay review cost on code that should not exist.
openfeature-remove-stale-flag targets that cleanup on JS/TS OpenFeature call sites. You pass the flag key and the permanent boolean. The codemod replaces getBooleanValue, useBooleanFlagValue, useFlag(...).value, and generated useFlagXxx() call sites, then folds the leftover control flow when it is safe.
Against a local Grafana frontend checkout, a dry run for grafana.visualDesignRefresh with value=true would modify 5 files out of ~10k scanned:
npx codemod openfeature-remove-stale-flag \
-t /path/to/grafana \
--param flagKey=grafana.visualDesignRefresh \
--param value=true \
--dry-run --report
The same run emits openfeature_stale_flag_removed. The report Metrics tab aggregates by pattern and outcome. Full keys are easier to read in a table than in the truncated UI columns:
Flag key | Outcome | Pattern | Value | Count |
|
|
|
| 21 |
|
|
|
| 2 |
|
|
|
| 1 |
|
|
|
| 1 |
|
|
|
| 1 |
Five rewrites landed. Twenty-one generated_hook hits were skipped_escaped — mostly the hook definition and sites where the boolean escapes into props or callbacks. That split is the safety story: rewrite the folded call sites, leave the ambiguous ones for a human.
It skips escaped results (exports, object properties, callback args) and leaves generated hook definitions alone. You want that bar before a campaign or an agent runs it across a large tree.
We wrote earlier about automatic feature flag removal for provider-specific SDKs. The OpenFeature package is the same idea on the portable API: delete the evaluation, then simplify what the boolean was protecting.
Cleanup is not hygiene theater. It is how you keep the codebase legible after the product decision is already made.
This walkthrough is scoped on purpose
This article only covers Grafana's JS/TS surfaces. The miner ignores generated OpenFeature sources and Go clients. Grafana's backend OpenFeature work is a separate inventory.
It is also an OSS analysis, not a partnership announcement. The registry packages are public so other teams can run the same measurement and cleanup loop on their own trees. If Grafana engineers find the miner useful, that is a bonus. The design goal is the loop itself: learn from flags, standardize evaluation on OpenFeature, measure the dual period, then delete what already shipped.
Keep the signal, delete the scaffolding
Feature flags are how modern teams learn what to build when shipping is cheap. OpenFeature is how that learning stays portable across vendors and services. Codemods are how you keep the intermediate state honest: mine compliance while two APIs coexist, migrate call sites with evidence, and remove stale evaluations so humans and agents are not navigating permanent temporary code.
The Grafana frontend is a useful proof because the dual API is already in the open. Start with the map. The rewrite is easier when you can see it.