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.

referencessdk-patterns.md

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

SDK Patterns Reference

Common flag evaluation patterns by SDK and language. Search for these patterns when finding flag references.

JavaScript/TypeScript (Node.js)

// Standard evaluation
ldClient.variation('flag-key', context, defaultValue);
ldClient.boolVariation('flag-key', context, false);
ldClient.stringVariation('flag-key', context, 'default');
ldClient.numberVariation('flag-key', context, 0);
ldClient.jsonVariation('flag-key', context, {});

// With details (includes reason)
ldClient.variationDetail('flag-key', context, defaultValue);
ldClient.boolVariationDetail('flag-key', context, false);

// All flags
ldClient.allFlagsState(context);

JavaScript/TypeScript (Browser/React)

// React SDK hooks
const { flags } = useFlags();
const flagValue = flags['flag-key'];
const flagValue = flags.flagKey; // camelCase access

// useLDClient hook
const ldClient = useLDClient();
ldClient.variation('flag-key', defaultValue);

// withLDConsumer HOC
this.props.flags['flag-key']
this.props.ldClient.variation('flag-key', defaultValue);

// Direct client usage
LDClient.variation('flag-key', defaultValue);

Python

# Standard evaluation
ld_client.variation('flag-key', context, default_value)
ld_client.bool_variation('flag-key', context, False)
ld_client.string_variation('flag-key', context, 'default')
ld_client.int_variation('flag-key', context, 0)
ld_client.float_variation('flag-key', context, 0.0)
ld_client.json_variation('flag-key', context, {})

# With details
ld_client.variation_detail('flag-key', context, default_value)
ld_client.bool_variation_detail('flag-key', context, False)

# All flags
ld_client.all_flags_state(context)

Go

// Standard evaluation
ldClient.BoolVariation("flag-key", context, false)
ldClient.StringVariation("flag-key", context, "default")
ldClient.IntVariation("flag-key", context, 0)
ldClient.Float64Variation("flag-key", context, 0.0)
ldClient.JSONVariation("flag-key", context, ldvalue.Null())

// With details
ldClient.BoolVariationDetail("flag-key", context, false)
ldClient.StringVariationDetail("flag-key", context, "default")

// All flags
ldClient.AllFlagsState(context)

Java/Kotlin

// Standard evaluation
ldClient.boolVariation("flag-key", context, false);
ldClient.stringVariation("flag-key", context, "default");
ldClient.intVariation("flag-key", context, 0);
ldClient.doubleVariation("flag-key", context, 0.0);
ldClient.jsonValueVariation("flag-key", context, LDValue.ofNull());

// With details
ldClient.boolVariationDetail("flag-key", context, false);
ldClient.stringVariationDetail("flag-key", context, "default");

// All flags
ldClient.allFlagsState(context);

Ruby

# Standard evaluation
ld_client.variation('flag-key', context, default_value)
ld_client.bool_variation('flag-key', context, false)
ld_client.string_variation('flag-key', context, 'default')
ld_client.number_variation('flag-key', context, 0)
ld_client.json_variation('flag-key', context, {})

# With details
ld_client.variation_detail('flag-key', context, default_value)

# All flags
ld_client.all_flags_state(context)

.NET (C#)

// Standard evaluation
ldClient.BoolVariation("flag-key", context, false);
ldClient.StringVariation("flag-key", context, "default");
ldClient.IntVariation("flag-key", context, 0);
ldClient.FloatVariation("flag-key", context, 0.0f);
ldClient.DoubleVariation("flag-key", context, 0.0);
ldClient.JsonVariation("flag-key", context, LdValue.Null);

// With details
ldClient.BoolVariationDetail("flag-key", context, false);
ldClient.StringVariationDetail("flag-key", context, "default");

// All flags
ldClient.AllFlagsState(context);

Common Wrapper Patterns

Many teams create abstraction layers. Search for these patterns too:

// Service wrappers
featureFlagService.isEnabled('flag-key');
featureFlagService.getValue('flag-key');
featureFlagService.getFlag('flag-key');
FeatureFlags.isEnabled('flag-key');

// Constants/enums
FLAGS.NEW_CHECKOUT_FLOW
FeatureFlag.NEW_CHECKOUT_FLOW
FEATURE_FLAGS['flag-key']

// Decorator patterns (Python/Java)
@feature_flag('flag-key')
@FeatureFlag("flag-key")

// Configuration files
feature_flags:
  flag-key: true

Search Strategies

When searching for flag references, use multiple patterns:

# Exact string match
grep -r "'flag-key'" .
grep -r '"flag-key"' .

# Case variations (kebab-case to camelCase)
grep -r "flagKey" .

# Partial matches for wrapper usage
grep -r "flag-key\|flagKey\|FLAG_KEY" .

# Check constants files
grep -r "flag-key" . --include="*.constants.*"
grep -r "flag-key" . --include="*flags*"

Removal Patterns

Boolean flag (forward value = true)

// Before
if (ldClient.variation('flag-key', user, false)) {
  doNewThing();
} else {
  doOldThing();
}

// After
doNewThing();

Boolean flag (forward value = false)

// Before
if (ldClient.variation('flag-key', user, false)) {
  doNewThing();
} else {
  doOldThing();
}

// After
doOldThing();

String/multivariate flag

// Before
const variant = ldClient.variation('flag-key', user, 'control');
switch (variant) {
  case 'new':
    return renderNew();
  case 'experimental':
    return renderExperimental();
  default:
    return renderControl();
}

// After (forward value = 'new')
return renderNew();

Early return pattern

// Before
const enabled = ldClient.variation('flag-key', user, false);
if (!enabled) {
  return null;
}
return <NewFeature />;

// After (forward value = true)
return <NewFeature />;

// After (forward value = false)
return null;

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.