$npx -y skills add launchdarkly/ai-tooling --skill launchdarkly-flag-targetingControl LaunchDarkly feature flag targeting including toggling flags on/off, percentage rollouts, targeting rules, individual targets, and copying flag configurations between environments. Use when the user wants to change who sees a flag, roll out to a percentage, add targeting
| 1 | # LaunchDarkly Flag Targeting & Rollout |
| 2 | |
| 3 | You're using a skill that will guide you through changing who sees what for a feature flag. Your job is to understand the current state of the flag, figure out the right targeting approach for what the user wants, make the changes safely, and verify the resulting state. |
| 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 | - `get-flag`: understand current state before making changes |
| 11 | - `toggle-flag`: turn targeting on or off for a flag in an environment |
| 12 | - `update-rollout`: change the default rule (fallthrough) variation or percentage rollout |
| 13 | - `update-targeting-rules`: add, remove, or modify custom targeting rules |
| 14 | - `update-individual-targets`: add or remove specific users/contexts from individual targeting |
| 15 | |
| 16 | **Optional MCP tools:** |
| 17 | - `copy-flag-config`: copy targeting configuration from one environment to another |
| 18 | - `create-approval-request`: create an approval request when direct changes are blocked |
| 19 | - `list-approval-requests`: check on pending approval requests for a flag |
| 20 | - `apply-approval-request`: apply an already-approved approval request |
| 21 | |
| 22 | ## Core Concept: Evaluation Order |
| 23 | |
| 24 | Before making any targeting changes, understand how LaunchDarkly evaluates flags. This determines what your changes actually do: |
| 25 | |
| 26 | 1. **Flag is OFF** -> Serve the `offVariation` to everyone. Nothing else matters. |
| 27 | 2. **Individual targets** -> If the context matches a specific target list, serve that variation. Highest priority. |
| 28 | 3. **Custom rules** -> Evaluate rules top-to-bottom. First matching rule wins. |
| 29 | 4. **Default rule (fallthrough)** -> If nothing else matched, serve this variation or rollout. |
| 30 | |
| 31 | This means: if you add a targeting rule but the flag is OFF, nobody sees the change. If you set a percentage rollout on the default rule but there's an individual target, that targeted user bypasses the rollout. |
| 32 | |
| 33 | ## Workflow |
| 34 | |
| 35 | ### Step 1: Understand Current State |
| 36 | |
| 37 | Before changing anything, check what's already configured. |
| 38 | |
| 39 | 1. **Confirm the environment.** "Turn it on" without specifying an environment is ambiguous. Always confirm which environment the user means. Default to asking rather than assuming. |
| 40 | 2. **Fetch the flag.** Use `get-flag` with the target environment to see: |
| 41 | - `on`: Is targeting currently enabled? |
| 42 | - `fallthrough`: What's the default rule? (variation or percentage rollout) |
| 43 | - `offVariation`: What serves when the flag is off? |
| 44 | - `rules`: Any custom targeting rules? |
| 45 | - `targets`: Any individually targeted users/contexts? |
| 46 | - `prerequisites`: Any flags this depends on? |
| 47 | 3. **Assess complexity.** A flag with no rules and no individual targets is simple. A flag with multiple rules, targets, and prerequisites needs more care. |
| 48 | |
| 49 | ### Step 2: Determine the Right Approach |
| 50 | |
| 51 | Based on what the user wants and what you found, choose the right tool and strategy. See [Targeting Patterns](references/targeting-patterns.md) for the full reference. |
| 52 | |
| 53 | **Common scenarios:** |
| 54 | |
| 55 | | User wants | Tool | Notes | |
| 56 | |-----------|------|-------| |
| 57 | | "Turn it on" | `toggle-flag` with `on: true` | Simplest change | |
| 58 | | "Turn it off" | `toggle-flag` with `on: false` | Serves offVariation to everyone | |
| 59 | | "Roll out to X%" | `update-rollout` with `rolloutType: "percentage"` | Weights must sum to 100 | |
| 60 | | "Enable for beta users" | `update-targeting-rules`: add a rule with clause | Rules are ANDed within, ORed between | |
| 61 | | "Add specific users" | `update-individual-targets` | Highest priority, overrides all rules | |
| 62 | |
| 63 | **Before writing a rule, individual target, or percentage rollout, confirm the context supports it.** A rule that names a context kind or attribute the flag's evaluation doesn't carry silently never matches; individual targets match the context **key**, not an attribute like email; and a rollout can only bucket by a kind present where the flag is read. See [Context Availability](references/context-availability.md) to pick a context that will actually fire. |
| 64 | | "Full rollout" | `update-rollout` with `rolloutType: "variation"` | Serve one variation to everyone | |
| 65 | | "Copy from staging" | `copy-flag-config` | Promote tested config to production | |
| 66 | |
| 67 | ### Step 3: Run the Safety Checklist |
| 68 | |
| 69 | Before applying changes, especially in production, run through the [Safety Checklist](references/safety-checklist.md). The key checks: |
| 70 | |
| 71 | 1. **Right environment?** Double-check you're targeting the intended environment. |
| 72 | 2. **Ap |