Helps engineering teams identify stale LaunchDarkly feature flags for cleanup.
Flags that have been serving 100% of production traffic to their "on" variation for 2+ weeks. The surrounding conditional code can be deleted and the "on" path hardcoded.
Flags that appear in LaunchDarkly but have zero references in any scanned repository. These can be deleted directly from LaunchDarkly.
A bi-weekly audit report is automatically posted to a configured Slack channel. The report highlights flags that newly crossed the 2-week rollout threshold and the 5 oldest flags still awaiting cleanup. The report schedule is configured at deploy time via the UI.
Set the following secrets before running:
| Variable | Required | Description |
|---|---|---|
LAUNCHDARKLY_API_KEY | Yes | LD REST API key with reader role |
LAUNCHDARKLY_PROJECT_KEY | No | LD project key (default: default) |
LAUNCHDARKLY_PRODUCTION_ENV | No | LD production environment key (default: production) |
GITHUB_REPO | No | Repository to search for flag code references (owner/repo) |
SLACK_NOTIFY_CHANNEL | No | Slack channel ID or name to post scheduled audit reports to |
The LaunchDarkly API key needs:
reader access to Flagsreader access to Code References (for the no-code-refs tool)Code References must be enabled in your LaunchDarkly project and at least one repository scan must have run for the orphaned-flag tool to return data.
my-flag-key"