Feature flag removal

From nwjs/chromium.src · View interactive version

Feature flag removal is an AI agent skill from the GitHub repository nwjs/chromium.src. Use when removing a `base::Feature` and its associated code

How to use this skill

Skill file

Your task is to clean up a base::Feature flag and its associated code.

<checklist>

  1. Determine flag's default state:

(either ENABLED_BY_DEFAULT or DISABLED_BY_DEFAULT).

ask the user to clarify which should be considered the final state.

//third_party/blink/renderer/platform/runtime_enabled_features.json5,

which is a config that generates base::Features at build time. Treat the

"stable" status as ENABLED_BY_DEFAULT and all other statuses as

DISABLED_BY_DEFAULT.

(e.g., force-disabled) for specific platforms via runtime overrides, bring

this discrepancy to the user's attention before cleaning it up.

  1. Remove C++ flag enablement checks:

takes the form of base::FeatureList::IsEnabled(kFeature) calls or a free

Is<X>Enabled() helper function that wraps the former.

Usually, you will need to delete one branch of an if-else condition and

dedent the other.

true or false in a larger boolean expression should be simplified as

much as possible.

  1. Remove obsolete base::FeatureParams:

flag.

Improve readability by using a constant (if the same value needs to be

shared in multiple places) or a named call parameter (e.g.,

FunctionCall(/*param=*/67)).

  1. Remove obsolete C++ test coverage:

the default state.

relevant.

permanent disabled behavior (instead of deleting them, if the test

covers general functionality).

of feature-specific events safely (e.g., check for null pointers when

casting events).

  1. Clean up Java code:

constant case version of the base::Feature name (e.g., FOO_BAR for

kFooBar).

parameters, tests).

  1. Clean up WebUI frontend code:

with AddBoolean("isFooEnabled", base::FeatureList::IsEnabled(kFoo))),

clean up isFooEnabled flags from WebUI frontend files

(TypeScript/HTML/CSS) in the same way as the C++ case.

  1. Simplify APIs and expressions:

the feature disabled, and T with the feature enabled. If the

feature-disabled case is being removed, then the parameter can just

become a value of type T.

```cpp

const auto x = base::FeatureList::IsEnabled(kFoo) ? Enum::A : Enum::B;

Bar(x);

```

... will become:

```cpp

const auto x = Enum::A;

Bar(x);

```

... if one naively removes an ENABLED_BY_DEFAULT flag kFoo, but this

can be simplified further as:

```cpp

Bar(Enum::A);

```

... since the assignment to x is adding unnecessary indirection.

  1. Remove dead code:

no longer referenced and delete their declarations and definitions. You

may need to delete entire source files.

parameters.

  1. Delete unused imports and build deps:

longer needed.

  1. Delete flag-metadata.json entry:

//ios/chrome/browser/flags/about_flags.mm, remove the corresponding

entry from //chrome/browser/flag-metadata.json. By convention, a

base::Feature declared as kFooBar has foo-bar as its about:flags

name.

  1. Clean up //testing/variations/fieldtrial_testing_config.json:
  1. Delete unused strings or resources:

IDR_ and IDS_ for resources and localized strings, respectively. In

Java, these are static members on an R class (e.g., R.string.foo

corresponds to IDS_FOO).

IDS_FOO.png.sha1 file, which references a screenshot to help

translators.

  1. Update metrics:

obsolete values in a enums.xml file under //tools/metrics/histograms/

and prepend (Obsolete) to the <int label=...>.

histograms.xml file under //tools/metrics/histograms/.

entries are still needed for decoding data in future Chrome versions.

  1. Update comments:

comments (e.g., both the C++ constant kMyFeature and the user-facing

name MyFeature) to clean up obsolete discussions, TODOs, or design

notes.

  1. Verify the build is not broken:

context, or by asking).

  1. Verify all tests still pass:

confirm the tests still pass.

  1. Format the code:

whitespace starting or ending a class or method).

</checklist>

<constraints>

constants for stylistic preference. The goal is removal and simplification,

not renaming.

related features that share a prefix, but you should only focus on the stale

feature.

</constraints>

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.