Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

launchdarkly

БесплатноБез исполняемых скриптовНе проверен

LaunchDarkly is a hosted feature flag service: it evaluates flags in your app so you can roll features out gradually, target segments and switch features off…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

LaunchDarkly

Overview

LaunchDarkly is the industry-standard feature flag platform. Control feature rollouts, A/B tests, and entitlements without deploying new code. Supports gradual rollouts, targeting rules, and instant kill switches.

Instructions

Step 1: Setup

npm install @launchdarkly/node-server-sdk   # server (Node.js 14+), current 9.x
npm install @launchdarkly/react-sdk         # React web, current 4.x

launchdarkly-react-client-sdk (3.x) is the old name of the React package and is no longer developed; its README points to @launchdarkly/react-sdk. Its API (withLDProvider, asyncWithLDProvider) differs from the 4.x API below.

Credentials differ by SDK: the server SDK uses the environment's SDK key (secret, server only), the browser SDK uses the client-side ID (public). Never ship the SDK key to a browser. A flag used from React must have "Available on client-side SDKs" enabled in its settings, otherwise the browser never receives it.

Step 2: Server-Side Flags

Create one client per process and reuse it. Evaluation reads locally cached rules, so variation makes no network call.

// lib/flags.ts
import * as LaunchDarkly from '@launchdarkly/node-server-sdk'

const client = LaunchDarkly.init(process.env.LAUNCHDARKLY_SDK_KEY!)
// resolves when the first flag payload arrives; rejects on timeout or a bad key
await client.waitForInitialization({ timeout: 5 }).catch((err) => {
  console.error('LaunchDarkly not ready, serving defaults:', err.message)
})

export async function getFlag(flagKey: string, user: { key: string; email?: string; plan?: string }) {
  // attributes sit at the top level of a context (the old user-object `custom` map is not used)
  const context = { kind: 'user', key: user.key, email: user.email, plan: user.plan }
  return client.variation(flagKey, context, false) // false = value served if the flag is missing or the SDK is down
}

const showNewDashboard = await getFlag('new-dashboard', { key: 'user-8841', plan: 'pro' })

client.variationDetail(...) also returns the reason for a value (rule match, fallthrough, error), which helps when a flag does not behave as expected. Call await client.flush() before a short-lived process (script, serverless handler) exits so queued analytics events are sent, and client.close() on shutdown. LaunchDarkly.init(key, { offline: true }) evaluates everything to defaults without network access, useful in unit tests.

Step 3: React Client

In v4 you build a provider with createLDReactProvider at the app entry, then read flags with one hook per type. useFlags still exists but is deprecated.

// main.tsx
import { createLDReactProvider } from '@launchdarkly/react-sdk'
import { createRoot } from 'react-dom/client'
import App from './App'

const LDProvider = createLDReactProvider(import.meta.env.VITE_LD_CLIENT_SIDE_ID, {
  kind: 'user',
  key: 'user-8841',
  plan: 'pro',
})

createRoot(document.getElementById('root')!).render(
  <LDProvider>
    <App />
  </LDProvider>,
)
// Checkout.tsx
import { useBoolVariation } from '@launchdarkly/react-sdk'

export function Checkout() {
  const newCheckout = useBoolVariation('new-checkout', false)
  return newCheckout ? <NewCheckout /> : <OldCheckout />
}

Other hooks: useStringVariation, useNumberVariation, useJsonVariation, the matching ...VariationDetail variants, useLDClient() for identify/track, and useInitializationStatus() to show a loader until flags are ready. In Next.js, pass the client-side ID through a NEXT_PUBLIC_ variable and render the provider from a client component; the package also ships a /server entry for React Server Components (see the React Web SDK reference).

When the user logs in, call useLDClient()?.identify(newContext) to re-evaluate for the new context.

Step 4: Gradual Rollout

Configure in the LaunchDarkly dashboard, on the flag's targeting tab for each environment:

  • Percentage rollout in the default rule: 10% → 25% → 50% → 100% over days or weeks. Users are bucketed by the context key, so a user keeps the same variation as the percentage grows.
  • Targeting rules: match on context attributes (such as plan is pro) or segments, beta users first, then everyone.
  • Kill switch: turn the flag's targeting off; every context then gets the "off" variation within seconds, with no deploy.

Examples

Request: "Roll out the new dashboard to 10% of pro users." Create a boolean flag new-dashboard, add a rule plan is one of pro serving a 10% rollout of true, set the default rule to false. The server code from Step 2 returns true for about one in ten pro users and false for everyone else.

Request: "Add a kill switch for the recommendations widget in React." Create a flag recommendations-enabled with "Available on client-side SDKs" ticked, then:

const enabled = useBoolVariation('recommendations-enabled', true)
return enabled ? <Recomm
Полный SKILL.md на GitHub

Установить launchdarkly в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл launchdarkly?

LaunchDarkly is a hosted feature flag service: it evaluates flags in your app so you can roll features out gradually, target segments and switch features off without a deploy. Use when a user asks to implement feature flags, roll out features gradually, run an A/B test, control access by user segment, or add a kill switch, with the Node.js or React SDK.

Как установить скилл launchdarkly?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл launchdarkly запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить launchdarkly с