Skip to main content

Manage stale flags


Stale flag management and cleanup automation is a beta feature.

Manage stale flags

Harness Feature Flags helps to identify stale flags and automates the process of removing them from your code.

Stale flags are flags that are no longer needed as the change behind them has been widely rolled out and no longer needs any control in production.

Find potentially stale flags

  • At the top of your Feature Flags overview screen, you will find a list of filters.
  • One of those filters is labeled Potentially Stale Flags.
  • Click this list to see which flags have been highlighted by Harness as potentially stale.

By seeing which flags are potentially stale, your team can choose to either manually clean them up, mark them for automated cleanup via Harness, or mark them as not being stale.

Definition of potentially stale

Harness defines potentially stale flags as follows

  • Flag has not had evaluations in the last 60 days.


  • Flags that have not had any modification to their targeting rules in longer than 60 days.


  • Flags that have been globally set to a single value for longer than 30 days.

Mark flags for cleanup

When viewing all flags marked as potentially stale, you have two options within Harness

  • Mark as not stale - this will remove the flag from the potentially stale list for a period of 60 days. If the same criteria are met after 60 days, the flag will appear in the potentially stale list again

  • Mark as Ready for Cleanup - this will change the flag’s status to ready for cleanup , which will appear in the UI and be used as a list for the flag cleanup pipeline.

Note that once a flag has been marked as ready for cleanup, you can still undo this decision by marking the flag as not stale.

A view of the Harness Feature Flags dashboard with the potentially stale flags filter selectd

Flag cleanup automation

What’s needed

In order to leverage Harness’ flag cleanup automation pipeline, you will need the following:

Languages supported for flag cleanup

At this time, the following languages are supported for flag cleanup automation:

  • Java
  • Kotlin
  • Go

Set up a flag cleanup pipeline

In order to use flag cleanup automation during the beta phase, you will need to import a pipeline template.

Training your cleanup configuration file

You will need update the rules file with the correct tree-sitter query.

Secrets configuration for Gitub

  • A Github connector to connect to the repo to clone down the code to cleanup. The demo repo is here and the branch to use is “unscripted”.

Step one of importing a pipeline template

  • A Github token to allow the creation of PRs.

Step two of importing a pipeline template

  • A Harness API key to get the list of flags marked for cleanup.

Step three of importing a pipeline template

  • A Docker connector to pull down the plugin image.

Step four of importing a pipeline template

Run the flag cleanup pipeline

Here the pipeline is set up and our flags marked for cleanup. So now all we need to do is run the pipeline to do the cleanup.

  • Select the repo for the codebase and the branch.

Step one of running the flag cleanup pipeline

  • Select the Github token, Github username, and Harness API Key.

Step two of running the flag cleanup pipeline

  • Select what code to run against. The example repo includes both Go and Java. These are the paths to run against the Go code:

Step three of running the flag cleanup pipeline

  • Select the DockerHub connector to pull down the plugin container, and then select Run.

Step four of running the flag cleanup pipeline

As the pipeline runs, logs from the plugin show it getting the flags and performing the code changes.

Output of cleanup pipline

You can then navigate to the PR and see the changes it made.