Automated Feature Flag Cleanup
Use remote pipeline and stage templates to identify stale feature flags, remove them from your codebase, and open pull requests automatically.
Remote Feature Flag Cleanup templates help you identify and remove stale feature flags from your codebase. These remote templates automate feature flag cleanup by generating pull requests (PRs) with the proposed code changes.
The cleanup agent requires an Anthropic API key. The templates are maintained in the Harness Community GitHub repository.
Pipeline
Use when you want automated discovery, flag selection, and cleanup generation.
Stage
Use when you already know which feature flag should be removed and only need the cleanup workflow.
Each execution generates a single pull request for a single feature flag cleanup.
Import a template
The following templates are available for use in your Harness pipelines.
Pipeline (Harness Code)
Pipeline (GitHub)
Stage (Harness Code)
Stage (GitHub)
To import a remote template:
From the Harness FME navigation menu, navigate to Project Settings > Templates.
Click New Template.
Select either Pipeline or Stage depending on the template type you want to import.
Enter a name for the template.
Optionally, include a description and any tags for the template.
Add a version label for the template.
Optionally, upload a logo for the template.
Select where you'd like to save the template to:
Project,Organization, orAccount.Select Remote under
How do you want to set up your template?.Select Third-party Git provider and specify a Git connector, repository, Git branch, and the YAML path.
CLONE AND CUSTOMIZE BEFORE IMPORTING
The community templates hardcode
projectIdentifierandorgIdentifieron lines 6–7 of each YAML file.Before importing, clone the Harness Community GitHub repository and update those values to match your own account, organization, and project. Then, point your Git connector to your cloned copy.
Click Start.
Save the template and reference it in your Harness pipeline.
Required inputs
The following runtime inputs are required when configuring the remote templates:
Selection criteria
FEATURE_FLAG_SELECTION_CRITERIA defines which feature flags should be considered eligible for cleanup. Write the criteria as a short, explicit sentence describing the desired cleanup conditions.
Use a pipeline template
Use a pipeline template when you want the workflow to discover and suggest cleanup candidates automatically.
Import a pipeline template.
Configure the required runtime inputs.
Run the pipeline.
Select a feature flag from the generated candidate list.
Review and merge the generated pull request.
Cleanup behavior
The cleanup agent attempts to remove feature flag conditionals, inline the selected treatment, and remove unused feature flag references.
For example:
Each execution generates a new branch, a single commit, and a pull request containing the code changes and the reason for cleanup.
Use a stage template
Stage templates are useful when feature flag cleanup is part of a larger engineering workflow. You can provide the required cleanup inputs directly, including FEATURE_FLAG, TREATMENT, REASON, and more.
Common use cases include removing flags after a rollout reaches 100%, cleaning up flags after an experiment concludes, removing flags during migrations from another feature flag provider, and adding cleanup to scheduled technical debt workflows.
Import a stage template.
Configure the required runtime inputs.
Run the stage.
Review and merge the generated pull request.
Cleanup behavior
The stage template follows the same cleanup workflow used by the pipeline template, but skips feature flag discovery, candidate generation, and manual feature flag selection. Because the feature flag is already identified, the workflow proceeds directly to cleanup and pull request generation.
Each execution generates a new branch, a single commit, and a pull request containing the code changes and the reason for cleanup.
Last updated
Was this helpful?