AI flag cleanup (Beta)

Tackling feature flag clean-up is an annoying part of using flags. Because it’s such a nuisance, cleanup frequently gets pushed aside. Then old feature flags linger, which clutter your codebase and make it more difficult to work with.

Most solutions to this just highlight flag references in your code. But that doesn't actually solve the problem, you still need to do the refactoring work.

At Bucket, we want you to spend your time building quality features, not cleaning up stale flags. So today we’ve released AI flag cleanup in beta for React.

AI flag cleanup works as a GitHub integration. By clicking a button in Bucket, we generate a pull request in your repository to remove no longer needed flag code for you.

Under the hood, the GitHub integration continuously checks the codebase against the feature keys in Bucket whenever a commit is pushed to the repository. When the AI clean-up bot operates, it searches for usage of the Bucket SDK in your codebase and identifies where specific feature keys are used. LLMs are employed to intelligently refactor the code to remove the flag and eliminate codepaths that become unreachable.

For React, this usually corresponds to the useFeature hook, like in this contrived example:

function StartHuddleButton() {
  const { isEnabled } = useFeature("huddle");
  if (!isEnabled) {
    return null;
  }
  return <button onClick={track}>Start huddle!</button>;
}

When the bot cleans up the file, it removes the hook and only retains the codepath remaining after assuming isEnabled=true:

function StartHuddleButton() {
  return <button onClick={track}>Start huddle!</button>;
}

If you're using ESLint and/or Prettier in GitHub Actions for code formatting, there's a GitHub Action workflow to use so that your setup is applied when generating PRs.

This is the first feature we’re announcing this week to bring you closer to zero maintenance feature flagging. Check out our launch week page for what’s new each day this week.

To get started using AI flag cleanup, connect the GitHub integration, or check out the docs for more details.