launchdarkly-flag-cleanup

launchdarkly/agent-skills · updated Apr 8, 2026

MDX-style export adds YAML metadata + attribution linking explainx.ai and this canonical listing URL.

$npx skills add https://github.com/launchdarkly/agent-skills --skill launchdarkly-flag-cleanup
0 commentsdiscussion
summary

You're using a skill that will guide you through safely removing a feature flag from a codebase while preserving production behavior. Your job is to explore the codebase to understand how the flag is used, query LaunchDarkly to determine the correct forward value, remove the flag code cleanly, and verify the result.

skill.md

LaunchDarkly Flag Cleanup

You're using a skill that will guide you through safely removing a feature flag from a codebase while preserving production behavior. Your job is to explore the codebase to understand how the flag is used, query LaunchDarkly to determine the correct forward value, remove the flag code cleanly, and verify the result.

If you haven't already identified which flag to clean up, use the flag discovery skill first to audit the landscape and find candidates.

Prerequisites

This skill requires the remotely hosted LaunchDarkly MCP server to be configured in your environment.

Required MCP tools:

  • check-removal-readiness — detailed safety check (orchestrates flag config, cross-env status, dependencies, code references, and expiring targets in parallel)
  • get-flag — fetch flag configuration for a specific environment

Optional MCP tools:

  • archive-flag — archive the flag in LaunchDarkly after code removal
  • delete-flag — permanently delete the flag (irreversible, prefer archive)

Core Principles

  1. Safety First: Always preserve current production behavior.
  2. LaunchDarkly as Source of Truth: Never guess the forward value. Query the actual configuration.
  3. Follow Conventions: Respect existing code style and structure.
  4. Minimal Change: Only remove flag-related code. No unrelated refactors.

Workflow

Step 1: Explore the Codebase

Before touching LaunchDarkly or removing code, understand how this flag is used in the codebase.

  1. Find all references to the flag key. Search for the flag key string (e.g., new-checkout-flow) across the codebase. Check for:

    • Direct SDK evaluation calls (variation(), boolVariation(), useFlags(), etc.)
    • Constants/enums that reference the key
    • Wrapper/service patterns that abstract the SDK
    • Configuration files, tests, and documentation
    • See SDK Patterns for the full list of patterns by language
  2. Understand the branching. For each reference, identify:

    • What code runs when the flag is true (or variation A)?
    • What code runs when the flag is false (or variation B)?
    • Are there side effects, early returns, or nested conditions?
  3. Note the scope. How many files, components, or modules does this flag touch? A flag used in one if block is simpler than one threaded through multiple layers.

Step 2: Run the Removal Readiness Check

Use check-removal-readiness to get a detailed safety assessment. This single tool call orchestrates multiple checks in parallel:

  • Flag configuration and targeting state
  • Cross-environment status
  • Dependent flags (prerequisites)
  • Expiring targets
  • Code reference statistics

The tool returns a readiness verdict:

safe — No blockers or warnings. Proceed with removal.

caution — No hard blockers but warnings exist (e.g., code references in other repos, expiring targets scheduled, flag marked as permanent). Present warnings and let the user decide.

blocked — Hard blockers prevent safe removal (e.g., dependent flags, actively receiving requests, targeting is on with active rules). Present blockers — the user must resolve them first.

Step 3: Determine the Forward Value

Use get-flag to fetch the flag configuration in each critical environment. The forward value is the variation that replaces the flag in code.

Scenario Forward Value
All critical envs ON, same fallthrough, no rules/targets Use fallthrough.variation
All critical envs OFF, same offVariation Use offVariation
Critical envs differ in ON/OFF state NOT SAFE — stop and inform the user
Critical envs serve different variations NOT SAFE — stop and inform the user

Step 4: Present the Cleanup Plan

Before modifying any code, present a summary to the user and wait for confirmation:

  1. The forward value — which variation will be hardcoded and why (based on the flag's current state).
  2. All code references found — file paths and line numbers from Step 1.
  3. Planned changes — for each reference, describe what will be removed and what will be kept.
  4. Readiness verdict — the result from check-removal-readiness (safe, caution, or blocked) and any warnings.
  5. LaunchDarkly action — confirm the flag will be archived after code changes are complete.

Do not proceed with code changes until the user explicitly confirms.

Step 5: Remove the Flag from Code

Now execute the removal using what you learned in Step 1.

  1. Replace flag evaluations with the forward value.

    • Preserve the code branch matching the forward value
    • Remove the dead branch entirely
    • If the flag value was assigned to a variable, replace the variable with the literal value or inline it
  2. Clean up dead code.

    • Remove imports, constants, and type definitions that only existed for the flag
    • Remove functions, components, or files that only existed for the dead branch
    • Check for orphaned exports, hooks, helpers, styles, and test files
    • If the repo uses an unused-export tool (Knip, ts-prune, lint rules), run it and remove any flag-related orphans
  3. Don't over-clean.

    • Only remove code directly related to the flag
    • Don't refactor, optimize, or "improve" surrounding code
    • Don't change formatting or style of untouched code

Example transformation (boolean flag, forward value = true):

// Before
const showNewCheckout = await ldClient.variation('new-checkout-flow', user, false);
if (showNewCheckout) {
  return renderNewCheckout();
} else {
  return renderOldCheckout();
}

// After
return renderNewCheckout();

Step 6: Create Pull Request

Use the template in references/pr-template.md for a structured PR description. The PR should clearly communicate:

  • What flag was removed and why
  • What the forward value is and why it's correct
  • The readiness assessment results (from check-removal-readiness)
  • What code was removed and what behavior is preserved
  • Whether other repos still reference this flag

Step 7: Verify

Before considering the job done:

  1. Code compiles and lints. Run the project's build and lint steps.
  2. Tests pass. If the flag was used in tests, the tests should be updated to reflect the hardcoded behavior.
  3. No remaining references. Search the codebase one more time for the flag key to make sure nothing was missed.
  4. PR is complete. The description covers the readiness assessment, forward value rationale, and any cross-repo coordination needed.

Edge Cases

Situation Action
Flag not found in LaunchDarkly Inform user, check for typos in the key
Flag already archived Ask if code cleanup is still needed (flag is gone from LD but code may still reference it)
Multiple SDK patterns in codebase Search all patterns: variation(), boolVariation(), variationDetail(), allFlags(), useFlags(), plus any wrappers
Dynamic flag keys (flag-${id}) Warn that automated removal may be incomplete — manual review required
Different default values in code vs LD Flag as inconsistency in the PR description
Orphaned exports/files remain after removal Run unused-export checks and remove dead files

What NOT to Do

  • Don't change code unrelated to flag cleanup.
  • Don't refactor or optimize beyond flag removal.
  • Don't remove flags still being actively rolled out.
  • Don't guess the forward value — always query LaunchDarkly.

After Cleanup

Once the PR is merged and deployed:

  1. Archive the flag in LaunchDarkly using archive-flag. Archival is reversible; deletion is not. Always archive first.
  2. Notify other teams if check-removal-readiness reported code references in other repositories.
  3. If the flag had targeting changes pending, they can be ignored — the flag is being removed.

References

  • PR Template — Structured PR description for flag removal
  • SDK Patterns — Flag evaluation patterns by language/framework
  • Flag Discovery — Find cleanup candidates before using this skill
  • Flag Targeting — If you need to change targeting instead of removing
how to use launchdarkly-flag-cleanup

How to use launchdarkly-flag-cleanup on Cursor

AI-first code editor with Composer

1

Prerequisites

Before installing skills in Cursor, ensure your development environment meets these requirements:

  • Cursor installed and configured on your development machine
  • Node.js version 16.0+ with npm package manager (verify with node --version)
  • Active project directory or workspace where you want to add launchdarkly-flag-cleanup
2

Execute installation command

Execute the skills CLI command in your project's root directory to begin installation:

$npx skills add https://github.com/launchdarkly/agent-skills --skill launchdarkly-flag-cleanup

The skills CLI fetches launchdarkly-flag-cleanup from GitHub repository launchdarkly/agent-skills and configures it for Cursor.

3

Select Cursor when prompted

The CLI will show a list of available agents. Use arrow keys to navigate and space to select Cursor:

◆ Which agents do you want to install to?
│ ── Universal (.agents/skills) ── always included ────
│ • Amp
│ • Antigravity
│ • Cline
│ • Codex
│ ●Cursor(selected)
│ • Cursor
│ • Windsurf
4

Verify installation

Confirm successful installation by checking the skill directory location:

.cursor/skills/launchdarkly-flag-cleanup

Reload or restart Cursor to activate launchdarkly-flag-cleanup. Access the skill through slash commands (e.g., /launchdarkly-flag-cleanup) or your agent's skill management interface.

Security & Verification Notice

We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.

Skills execute code in your development environment. Always verify the publisher's identity, review recent commits, and test in isolated environments before production deployment.

List & Monetize Your Skill

Submit your Claude Code skill and start earning

GET_STARTED →

Use Cases

User Story & Requirements Generation

Create detailed user stories, acceptance criteria, and feature specs

Example

Generate user stories for 'password reset feature' with acceptance criteria, edge cases, and test scenarios

Reduce spec writing time by 50%, ensure comprehensive coverage

Competitive Analysis

Research competitors, compare features, identify gaps

Example

Analyze 5 competitor products, create feature comparison matrix, suggest differentiation opportunities

Complete competitive research in 2 hours instead of 2 days

Roadmap Prioritization

Evaluate features using frameworks (RICE, ICE, Kano) and create prioritized backlogs

Example

Score 20 feature ideas using RICE framework, generate prioritized roadmap with rationale

Make data-driven prioritization decisions faster

Stakeholder Communication

Draft PRDs, status updates, and stakeholder presentations

Example

Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement

Save 3-5 hours/week on communication overhead

Implementation Guide

Prerequisites

  • Claude Desktop or compatible AI client
  • Access to product documentation and roadmap tools (Jira, Notion, etc.)
  • Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
  • Stakeholder contact information and communication channels

Time Estimate

30-60 minutes to see productivity improvements

Installation Steps

  1. 1.Install product management skill
  2. 2.Start with user story generation for known feature
  3. 3.Progress to competitive analysis: research 2-3 competitors
  4. 4.Use for roadmap prioritization: apply RICE/ICE scoring
  5. 5.Draft stakeholder communications and refine based on feedback
  6. 6.Build template library for recurring PM tasks
  7. 7.Share effective prompts with product team

Common Pitfalls

  • Not validating competitive research—verify facts before sharing
  • Accepting user stories without involving engineering team
  • Over-relying on frameworks without qualitative judgment
  • Not customizing outputs to company culture and communication style
  • Skipping stakeholder validation of generated requirements

Best Practices

✓ Do

  • +Validate research and competitive analysis with real data
  • +Collaborate with engineering when generating technical requirements
  • +Customize frameworks and templates to your company context
  • +Use skill for first drafts, refine with stakeholder input
  • +Document successful prompt patterns for PM tasks
  • +Combine AI efficiency with human judgment and intuition

✗ Don't

  • Don't publish competitive analysis without fact-checking
  • Don't finalize user stories without engineering review
  • Don't make prioritization decisions solely on AI scoring
  • Don't skip customer validation of generated requirements
  • Don't ignore company-specific context and culture

💡 Pro Tips

  • Provide context: company goals, constraints, customer feedback
  • Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
  • Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
  • Use skill for 70% generation + 30% customization to company needs

When to Use This

✓ Use When

Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.

✗ Avoid When

Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.

Learning Path

  1. 1Basic: user stories, feature specs, status updates
  2. 2Intermediate: competitive analysis, prioritization frameworks, PRDs
  3. 3Advanced: product strategy, go-to-market planning, OKR setting
  4. 4Expert: product vision, market positioning, business model innovation

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.553 reviews
  • Zaid Tandon· Dec 28, 2024

    Registry listing for launchdarkly-flag-cleanup matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Arya Martinez· Dec 28, 2024

    Registry listing for launchdarkly-flag-cleanup matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Diego Diallo· Dec 12, 2024

    launchdarkly-flag-cleanup reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Yuki Gupta· Nov 23, 2024

    Keeps context tight: launchdarkly-flag-cleanup is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Nikhil Zhang· Nov 19, 2024

    Useful defaults in launchdarkly-flag-cleanup — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Isabella Park· Nov 19, 2024

    launchdarkly-flag-cleanup is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Nikhil Chen· Nov 19, 2024

    Useful defaults in launchdarkly-flag-cleanup — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Lucas Dixit· Nov 3, 2024

    I recommend launchdarkly-flag-cleanup for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Kofi Nasser· Oct 22, 2024

    Useful defaults in launchdarkly-flag-cleanup — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Layla Okafor· Oct 14, 2024

    launchdarkly-flag-cleanup is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

showing 1-10 of 53

1 / 6