$npx -y skills add launchdarkly/ai-tooling --skill launchdarkly-flag-createCreate and configure LaunchDarkly feature flags in a way that fits the existing codebase. Use when the user wants to create a new flag, wrap code in a flag, add a feature toggle, or set up an experiment. Guides exploration of existing patterns before creating.
| 1 | # LaunchDarkly Flag Create & Configure |
| 2 | |
| 3 | You're using a skill that will guide you through introducing a new feature flag into a codebase. Your job is to explore how flags are already used in this codebase, create the flag in LaunchDarkly in a way that fits, add the evaluation code matching existing patterns, and verify everything is wired up correctly. |
| 4 | |
| 5 | ## Prerequisites |
| 6 | |
| 7 | This skill requires the remotely hosted LaunchDarkly MCP server to be configured in your environment. |
| 8 | |
| 9 | **Required MCP tools:** |
| 10 | - `create-flag`: create a new feature flag in a project |
| 11 | - `get-flag`: verify the flag was created correctly |
| 12 | |
| 13 | **Optional MCP tools (enhance workflow):** |
| 14 | - `list-flags`: browse existing flags to understand naming conventions and tags |
| 15 | - `update-flag-settings`: update flag metadata (name, description, tags, temporary/permanent status) |
| 16 | |
| 17 | ## Workflow |
| 18 | |
| 19 | ### Step 1: Explore the Codebase |
| 20 | |
| 21 | Before creating anything, understand how this codebase uses feature flags. |
| 22 | |
| 23 | 1. **Find the SDK.** Search for LaunchDarkly SDK imports or initialization: |
| 24 | - Look for `launchdarkly`, `ldclient`, `ld-client`, `LDClient` in imports |
| 25 | - Check `package.json`, `requirements.txt`, `go.mod`, `Gemfile`, or equivalent for the SDK dependency |
| 26 | - Identify which SDK is in use (server-side Node, React, Python, Go, Java, etc.) |
| 27 | |
| 28 | 2. **Find existing flag evaluations.** Search for variation calls to understand the patterns this codebase uses: |
| 29 | - Direct SDK calls: `variation()`, `boolVariation()`, `useFlags()`, etc. |
| 30 | - Wrapper patterns: Does this codebase abstract flags behind a service or utility? |
| 31 | - Constant definitions: Are flag keys defined as constants somewhere? |
| 32 | - See [SDK Evaluation Patterns](references/sdk-evaluation-patterns.md) for patterns by language |
| 33 | |
| 34 | 3. **Understand conventions.** Look at existing flags to learn: |
| 35 | - **Naming convention**: Are keys `kebab-case`, `snake_case`, `camelCase`? |
| 36 | - **Organization**: Are flag keys co-located with features, or centralized in a constants file? |
| 37 | - **Default values**: What defaults do existing evaluations use? |
| 38 | - **Context/user construction**: How does this codebase build the user/context object passed to the SDK? This determines which context kinds and attributes any future targeting can use — and it differs by surface (server vs client vs anonymous). See [Context Availability](../launchdarkly-flag-targeting/references/context-availability.md) before planning a rule, individual target, or rollout. |
| 39 | |
| 40 | 4. **Check LaunchDarkly project conventions.** Optionally use `list-flags` to see existing flags: |
| 41 | - What tags are commonly used? |
| 42 | - Are flags marked as temporary or permanent? |
| 43 | - What naming patterns exist in the project? |
| 44 | |
| 45 | ### Step 2: Determine the Right Flag Type |
| 46 | |
| 47 | Based on what the user needs, choose the appropriate flag configuration. See [Flag Types and Patterns](references/flag-types.md) for the full guide. |
| 48 | |
| 49 | **Quick decision:** |
| 50 | |
| 51 | | User intent | Flag kind | Variations | |
| 52 | |-------------|-----------|------------| |
| 53 | | "Toggle a feature on/off" | `boolean` | `true` / `false` | |
| 54 | | "Gradually roll out a feature" | `boolean` | `true` / `false` | |
| 55 | | "A/B test between options" | `multivariate` (string) | User-defined values | |
| 56 | | "Configure a numeric threshold" | `multivariate` (number) | User-defined values | |
| 57 | | "Serve different config objects" | `multivariate` (JSON) | User-defined values | |
| 58 | |
| 59 | **Defaults to apply:** |
| 60 | - Set `temporary: true` unless the user explicitly says this is a permanent/long-lived flag. Most flags are release flags that should eventually be cleaned up. |
| 61 | - Generate a `key` from the name if not provided (e.g., "New Checkout Flow" -> `new-checkout-flow`), but match the codebase's naming convention if one exists. |
| 62 | - Suggest relevant tags based on the feature area, team, or context the user mentions. |
| 63 | |
| 64 | ### Step 3: Create the Flag in LaunchDarkly |
| 65 | |
| 66 | Use `create-flag` with the configuration determined in Step 2. |
| 67 | |
| 68 | After creation: |
| 69 | - The flag is created with **targeting OFF** in all environments. |
| 70 | - The flag serves the `offVariation` to everyone until targeting is turned on. |
| 71 | - Remind the user they'll need to use the [flag targeting skill](../launchdarkly-flag-targeting/SKILL.md) to toggle it on and optionally set up rollout rules. |
| 72 | |
| 73 | ### Step 4: Add Flag Evaluation to Code |
| 74 | |
| 75 | Now add the code to evaluate the flag, **matching the patterns you found in Step 1**. |
| 76 | |
| 77 | 1. **Use the same SDK patterns** the codebase already uses. If there's a wrapper, use the wrapper. If there are constants, add the new key to the constants file. |
| 78 | 2. **Use an appropriate d |