Vega for flag cleanup

GitHub account required

Vega for flag cleanup requires a connected GitHub account to create pull requests. To learn how to connect GitHub, read Connecting Vega to GitHub.

Overview

Vega is LaunchDarkly’s AI-powered agent. To learn more about Vega, including eligibility and pricing, read Vega.

Vega can help you identify and remove stale feature flags from your codebase. Stale flags accumulate technical debt, and most teams don’t clean them up because the process is manual and error-prone. Vega automates safety checks and code changes, removing the main barriers to keeping flag counts manageable.

How it works

To start a flag cleanup, you can either:

  • Go to the Flags list, click the three-dot overflow menu on any flag, and select Vega cleanup.

The three-dot overflow menu on a flag, with the Vega cleanup option.

The three-dot overflow menu on a flag, with the Vega cleanup option.
  • Or, click a flag in the Flags list, and then click Start cleanup in the Vega Cleanup Status section of the sidebar.

The Vega Cleanup Status section on a flag's detail page, with the Start cleanup link.

The Vega Cleanup Status section on a flag's detail page, with the Start cleanup link.

Either option opens the Flag cleanup modal, which shows a staleness analysis and lets you start the cleanup:

The Flag cleanup modal, showing staleness analysis and the Start cleanup button.

The Flag cleanup modal, showing staleness analysis and the Start cleanup button.

Once started:

  1. The cleanup job appears under the Flag Cleanup tab.
  2. Vega checks that the flag has only a single variation being evaluated across all critical environments. If multiple variations are still active, Vega won’t proceed with the cleanup task.
  3. If the check passes, Vega creates a GitHub pull request to remove the flag from your code.

How Vega determines if a flag is safe to clean up

Vega follows this procedure to determine whether a flag is safe to remove:

  1. Queries your critical environments: Vega identifies all environments marked as critical for your project.
  2. Checks flag evaluations: Vega checks the flag’s evaluations in these environments to confirm that the flag is “stale,” meaning it serves the same variation across all critical environments.
  3. Takes action:
    • If the flag is stale, Vega proceeds with code cleanup and creates a pull request.
    • If the flag is not stale, Vega notifies you. You can still tell Vega to clean up the flag if you’d like to proceed anyway.

Tracking cleanup status

You can view a flag’s cleanup status in the Vega Cleanup Status section on the flag’s detail page sidebar:

The Vega Cleanup Status section on a flag's detail page.

The Vega Cleanup Status section on a flag's detail page.

When Vega completes a cleanup, it provides a summary including staleness analysis, code changes, and a link to the pull request:

A completed Vega flag cleanup, showing the PR history and Vega's summary.

A completed Vega flag cleanup, showing the PR history and Vega's summary.

Vega tags flags during the cleanup process. You can filter by these tags in the Flags list to track progress:

TagMeaning
vega-pr-in-progressCleanup is underway for this flag.
vega-pr-filedA pull request has been created for this flag’s cleanup.
vega-pr-attemptedVega attempted cleanup but did not file a pull request. This can happen if Vega’s pre-cleanup checks determine the flag isn’t stale, if Vega can’t find any reference to the flag in the repositories it has access to, or due to a transient error such as a change in GitHub permissions.

If Vega determines the flag is still active (multiple variations in use across critical environments), it will notify you and stop. If Vega cannot find the flag in your code repositories, it will also notify you.

Automated flag cleanup

In addition to starting cleanups manually, you can configure Vega to automatically clean up flags on a recurring schedule. When enabled, Vega periodically scans for flags that are ready for code removal and runs cleanup jobs for them.

To configure automated flag cleanup:

  1. Go to Project settings, then select Lifecycle settings.

  2. In the “Automated flag cleanup” section, check Enable automated flag cleanups.

  3. Configure the following settings:

    • Schedule frequency: Choose how often Vega runs automated cleanups. The options are 1 day, 7 days (the default), or 30 days.
    • Max cleanup jobs per run: The maximum number of flags Vega will clean up in a single scheduled run (1–20).
    • Retry unsuccessful cleanups: When checked, Vega will re-attempt cleanup on flags where a previous attempt was unsuccessful. This option is off by default.
    • GitHub repositories: Select one or more connected GitHub repositories that Vega should target for code removal. You must select at least one repository to save your settings.
    • Additional context (optional): Provide extra instructions for the cleanup agent. For example, you can specify where flags are defined in your codebase. Vega also follows instructions in your repository’s AGENTS.md file, if available.
  4. Click Save.

The Automated flag cleanup settings card on the Lifecycle settings page.

The Automated flag cleanup settings card on the Lifecycle settings page.

After you save, Vega runs cleanups automatically based on your schedule. Each run processes up to the configured maximum number of flags. You can track the progress of automated cleanups the same way as manual cleanups, using the vega-pr-in-progress, vega-pr-filed, and vega-pr-attempted tags in the Flags list.

The settings card shows a “Last configured by” indicator with the member who saved the current configuration. Automated cleanup jobs run using this member’s permissions, so Vega can only access the repositories and flags that member has access to. If that member’s permissions change or their account is deactivated, you should update the settings with a different member to ensure cleanups continue to run.

Supported version control

Vega currently supports GitHub only for creating pull requests. To learn how to connect GitHub, read Connecting Vega to GitHub.