Back to Skills

launchdarkly-flag-cleanup

Safely remove a feature flag from code while preserving production behavior. Use when the user wants to remove a flag from code, delete flag references, or create a PR that hardcodes the winning variation after a rollout is complete.

17stars5forksUpdated 6/24/2026

Security Assessment

Medium Risk(50/100)

Detected risks:

Persistence([references/pr-template.md] LaunchD, [README.md] LaunchD, [README.md] launchd)
Security Score50/100

About launchdarkly-flag-cleanup

A guided workflow for safely removing a LaunchDarkly feature flag from a codebase while preserving production behavior. It is intended for when a user wants to remove a flag from code, delete flag references, or create a pull request that hardcodes the winning variation after a rollout is complete, and it suggests running the flag discovery skill first if the flag to clean up has not yet been identified. It requires the remotely hosted LaunchDarkly MCP server, using the required tools check-removal-readiness and get-flag, with optional archive-flag and delete-flag tools (archiving is preferred over irreversible deletion). Its core principles are safety first, treating LaunchDarkly as the source of truth rather than guessing the forward value, following existing conventions, and making only minimal flag-related changes.

The workflow begins by exploring the codebase to find every reference to the flag key, including direct SDK evaluation calls, constants and enums, wrapper or service patterns, and configuration, tests, and documentation, and by understanding the branching and side effects for each variation. It then runs check-removal-readiness, a single call that orchestrates parallel checks across flag configuration, cross-environment status, dependent flags, expiring targets, and code references, returning a verdict of safe, caution, or blocked. The forward value, the variation that replaces the flag in code, is determined with get-flag across critical environments: when all critical environments are on with the same fallthrough and no rules it uses the fallthrough variation, when all are off it uses the offVariation, and when environments differ in state or variation it stops and informs the user that removal is not safe.

Before any code changes the skill presents a cleanup plan (forward value and rationale, all references found, planned changes, readiness verdict, and the archive action) and waits for explicit confirmation. Removal then replaces evaluations with the forward value, preserves the matching branch, deletes the dead branch, and cleans up orphaned imports, constants, types, files, and tests, running unused-export tooling such as Knip or ts-prune where present, while avoiding any unrelated refactors. It closes by creating a structured PR from a template and verifying that the code compiles and lints, tests pass, and no references to the flag key remain. Edge cases such as dynamic flag keys, already-archived flags, and code-versus-LaunchDarkly default mismatches are called out explicitly.

FAQ

What does this skill require?

The remotely hosted LaunchDarkly MCP server. The required tools are check-removal-readiness and get-flag, with archive-flag and delete-flag as optional tools where archiving is preferred over the irreversible delete.

How is the forward value determined?

By querying get-flag across critical environments. If all are on with the same fallthrough and no rules it uses the fallthrough variation, if all are off it uses the offVariation, and if environments differ in state or served variation it stops and tells the user removal is not safe.

Does it remove code before confirming with the user?

No. It presents a cleanup plan covering the forward value, all references found, planned changes, the readiness verdict, and the archive action, and does not proceed with code changes until the user explicitly confirms.

What does the removal-readiness check cover?

A single check-removal-readiness call orchestrates parallel checks of flag configuration and targeting, cross-environment status, dependent flags, expiring targets, and code reference statistics, returning a verdict of safe, caution, or blocked.

How does it handle dynamic flag keys?

For dynamic keys such as flag-${id}, it warns that automated removal may be incomplete and that manual review is required, rather than attempting a full automatic cleanup.

All Files

5 files
marketplace.json0.5 KB
View
references/pr-template.md4.0 KB
View
README.md1.6 KB
View
SKILL.md8.7 KB
View
references/sdk-patterns.md5.5 KB
View

Install launchdarkly-flag-cleanup

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill