All skills
launchdarkly avatar

/launchdarkly-flag-cleanup

@be58859 official

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.

Use this Skill: https://skilld.dev/gh/launchdarkly/agent-skills/launchdarkly-flag-cleanup

This session only. Nothing lands on disk.

referencespr-template.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

PR Template for Flag Removal

Use this template when creating pull requests for flag cleanup.

## Flag Removal: `{flag-key}`

### Removal Summary
- **Forward Value**: `{variation value being preserved}`
- **Critical Environments**: {list environments}
- **Status**: ✅ Ready for removal / ⚠️ Proceed with caution / ❌ Not ready

### Removal Readiness Assessment

**Configuration Analysis:**
| Environment | State | Serving | Rules | Targets |
|-------------|-------|---------|-------|---------|
| production | ON/OFF | `{value}` | none/present | none/count |
| {other env} | ON/OFF | `{value}` | none/present | none/count |

**Lifecycle Status:**
| Environment | Status | Evaluations (7d) |
|-------------|--------|------------------|
| production | launched/active/inactive/new | {count} |
| {other env} | launched/active/inactive/new | {count} |

**Code References:**
- Repositories with references: `{count}`
- This PR addresses: `{current repo}`
- Other repos requiring cleanup: `{list if any}`

### Changes Made
- Removed flag evaluation calls: `{count}` occurrences
- Files modified: `{list files}`
- Preserved behavior: `{describe what code now does}`
- Cleaned up: `{list dead code removed}`

### Risk Assessment

{Explain why this change is safe. Address:}
- Why the forward value is correct
- Any edge cases considered
- Impact on other environments (if any)

### Reviewer Checklist

- [ ] Forward value matches production behavior
- [ ] All flag references removed
- [ ] No unrelated changes included
- [ ] Tests pass (if applicable)
- [ ] Dead code properly removed

### Post-Merge Actions

- [ ] Archive flag in LaunchDarkly (after deployment confirmed)
- [ ] Notify other teams if they have code references

Example: Ready for Removal

## Flag Removal: `new-checkout-flow`

### Removal Summary
- **Forward Value**: `true`
- **Critical Environments**: production, prod-eu
- **Status**: ✅ Ready for removal

### Removal Readiness Assessment

**Configuration Analysis:**
| Environment | State | Serving | Rules | Targets |
|-------------|-------|---------|-------|---------|
| production | ON | `true` | none | none |
| prod-eu | ON | `true` | none | none |

**Lifecycle Status:**
| Environment | Status | Evaluations (7d) |
|-------------|--------|------------------|
| production | launched | 142,531 |
| prod-eu | launched | 89,203 |

**Code References:**
- Repositories with references: 2
- This PR addresses: `checkout-service`
- Other repos requiring cleanup: `mobile-app`

### Changes Made
- Removed flag evaluation calls: 3 occurrences
- Files modified: `CheckoutController.ts`, `CheckoutService.ts`, `checkout.test.ts`
- Preserved behavior: Always renders new checkout experience
- Cleaned up: Removed `renderOldCheckout()` function and related imports

### Risk Assessment

This change is safe because:
- Both production environments serve `true` to 100% of traffic
- Flag has been at 100% for 47 days with no issues
- No targeting rules or individual overrides exist
- The new checkout flow has been fully validated

### Post-Merge Actions

- [ ] Archive flag in LaunchDarkly (after deployment confirmed)
- [ ] Create follow-up ticket for mobile-app cleanup

Example: Proceed with Caution

## Flag Removal: `legacy-api-endpoint`

### Removal Summary
- **Forward Value**: `false`
- **Critical Environments**: production
- **Status**: ⚠️ Proceed with caution

### Removal Readiness Assessment

**Configuration Analysis:**
| Environment | State | Serving | Rules | Targets |
|-------------|-------|---------|-------|---------|
| production | OFF | `false` | none | none |

**Lifecycle Status:**
| Environment | Status | Evaluations (7d) |
|-------------|--------|------------------|
| production | inactive | 0 |

⚠️ **Warning**: Zero evaluations in the last 7 days. This flag may be:
- Dead code that's safe to remove
- Used by a batch job or infrequent process
- Referenced but never called

**Recommendation**: Verify with the team that this code path is truly unused before merging.

Source: SKILL.md on GitHub

1 warning16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides a secure, structured workflow for automating feature flag cleanup using LaunchDarkly. It incorporates mandatory user confirmation steps before code modifications and relies on official vendor-hosted tools for data accuracy.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    3/5 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at be58859. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 days ago.

Activeupdated 6 months ago
compatibility
Requires the remotely hosted LaunchDarkly MCP server
metadata
{
  "author": "launchdarkly",
  "version": "1.0.0-experimental"
}

README badge

README badge for launchdarkly/agent-skills/launchdarkly-flag-cleanup

Safely removes a feature flag from code while preserving production behavior by querying LaunchDarkly to determine the correct forward value, finding all flag references, and replacing conditional branches with hardcoded variations. Targets teams using LaunchDarkly's MCP server and requires the remotely hosted LaunchDarkly service for the `check-removal-readiness` and `get-flag` tools.

Generated from the current SKILL.md.

Does this skill work with any LaunchDarkly SDK or only specific ones?
The skill handles multiple SDK patterns (variation(), boolVariation(), useFlags(), etc.) across different languages and frameworks. See the SDK Patterns reference for the full list of supported patterns.
What happens if the flag is configured differently across environments?
If critical environments differ in ON/OFF state or serve different variations, the skill will not proceed with removal. You must resolve the inconsistency in LaunchDarkly first.
Can this skill delete the flag from LaunchDarkly after code removal?
The skill can archive the flag (reversible) using archive-flag, or permanently delete it using delete-flag. Archival is preferred because deletion is irreversible.
What if code references the flag with a dynamic key like flag-${id}?
Automated removal may be incomplete with dynamic flag keys. The skill will flag this as needing manual review.
Does this skill require internet connectivity to LaunchDarkly?
Yes. The skill requires the remotely hosted LaunchDarkly MCP server to be configured in your environment to query flag state and perform removal readiness checks.

Generated from the current SKILL.md. These answers refresh after source changes.