sdk-install

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LaunchDarkly SDK Install (onboarding)

LaunchDarkly SDK 安装(入门引导)

Installs and initializes the right LaunchDarkly SDK for the user’s project by following three nested skills in order. Do not skip ahead to feature flags here—the parent LaunchDarkly onboarding continues with Step 6: First feature flag using Create first feature flag.
通过按顺序执行三个嵌套技能,为用户的项目安装并初始化合适的LaunchDarkly SDK。请勿在此处直接跳转至功能旗标操作——父级LaunchDarkly 入门引导将继续进行第6步:创建首个功能旗标,具体请参考创建首个功能旗标

Prerequisites

前提条件

  • Project context from parent Step 1: Explore the Project (reuse it; only re-run deep detection if something is unclear)
  • SDK key / client-side ID / mobile key: Needed when you reach Apply code changes (env wiring). Do not ask the user for these during detect or plan solely because you opened this skill—follow parent onboarding: account is confirmed early; key material is collected at apply (see parent Prerequisites).
  • 来自父级第1步:探索项目的项目上下文(可复用该上下文;仅在内容不明确时重新运行深度检测)
  • SDK密钥/客户端ID/移动端密钥:进行应用代码变更(环境配置)时需要这些信息。请勿仅因打开本技能就在检测或规划阶段向用户索要这些信息——请遵循父级入门引导流程:账号会在早期确认,密钥信息将在应用阶段收集(详见父级前提条件)。

Key types (summary)

密钥类型(摘要)

SDK TypeVariable (logical)Source in LaunchDarkly
Server-side
LAUNCHDARKLY_SDK_KEY
Environments → SDK key
Client-sideClient-side ID (bundler-prefixed env names)Environments → Client-side ID
Mobile
LAUNCHDARKLY_MOBILE_KEY
Environments → Mobile key
Never hardcode keys. Full env rules, consent, and bundler tables: Apply code changes Step 2.
SDK类型逻辑变量LaunchDarkly中的获取位置
服务端
LAUNCHDARKLY_SDK_KEY
环境 → SDK密钥
客户端客户端ID(打包器前缀环境变量名)环境 → 客户端ID
移动端
LAUNCHDARKLY_MOBILE_KEY
环境 → 移动端密钥
切勿硬编码密钥。完整的环境规则、授权说明及打包器相关表格请参考:应用代码变更第2步。

Workflow — run these nested skills in order

工作流程——按顺序运行这些嵌套技能

Execute all three unless the detect decision tree short-circuits (e.g. skip to apply only). Each nested skill contains blocking decision points (marked
D<N> -- BLOCKING
) where you must call your structured question tool and wait for the user's response before continuing. Do NOT batch tool calls across these boundaries.
OrderNested skillRole
1Detect repository stackLanguage, package manager, monorepo target, entrypoint, existing LD usage
2Generate integration planSDK choice, files to change, env plan -- confirm with user before edits
3Apply code changesInstall package(s),
.env
/ secrets with consent, init code, compile check (both tracks when dual-SDK plan)
Shared references for all steps: SDK recipes, SDK snippets.
除非检测决策树触发短路逻辑(例如直接跳至应用阶段),否则需执行全部三个技能。每个嵌套技能都包含阻塞式决策点(标记为
D<N> -- BLOCKING
),此时你必须调用结构化问题工具并等待用户回复后才能继续。请勿跨这些边界批量调用工具。
顺序嵌套技能作用
1检测仓库技术栈识别语言、包管理器、单仓目标、入口点、已有的LaunchDarkly使用情况
2生成集成方案选择SDK、确定需修改的文件、制定环境配置方案——编辑前需与用户确认
3应用代码变更安装包、经授权后配置
.env
/密钥、初始化代码、编译检查(若采用双SDK方案,则需同时处理两个分支)
所有步骤的共享参考资料:SDK 参考示例SDK 代码片段

After Step 3 completes

第3步完成后

Continue with the parent skill:
  • Step 6: Create first feature flag
Do not add standalone “sample flag” evaluation in this skill unless the user explicitly needs a throwaway check; the parent flow creates the first flag in order.
继续执行父级技能:
  • 第6步创建首个功能旗标
除非用户明确需要临时验证,否则请勿在本技能中添加独立的“示例旗标”评估;父级流程会按顺序创建首个旗标。

Guidelines

指导原则

  • Match existing codebase conventions for imports, config, and style.
  • Prefer TypeScript in TypeScript projects.
  • If the project uses a shared config layer, initialize LaunchDarkly there.
  • Add
    .env.example
    entries when the project uses dotenv.
  • Dependency scope: Add only LaunchDarkly SDK package(s) from the recipe unless the user explicitly approves upgrading or adding other packages (Apply — Permission before changing other dependencies).
  • 匹配现有代码库的导入、配置及风格约定。
  • TypeScript项目优先使用TypeScript。
  • 若项目使用共享配置层,请在该层初始化LaunchDarkly。
  • 若项目使用dotenv,请添加
    .env.example
    条目。
  • 依赖范围:仅添加参考示例中的LaunchDarkly SDK包,除非用户明确批准升级或添加其他包(详见应用阶段——修改其他依赖前需获授权)。

Edge cases

边缘情况

  • Multiple environments (e.g. Next.js server + client) or user asked for frontend + backend: Use a dual-SDK plan and apply both packages and both inits—never summarize the second SDK as done without lockfile + entrypoint evidence.
  • Monorepo: Integrate the package the user chose in parent onboarding; stay within that subtree.
  • SDK already installed and initialized: Parent may skip this handoff—see parent Edge Cases and detect decision tree.
  • Unsupported or uncommon stack: Use SDK recipes and the full SDK catalog.
  • 多环境(如Next.js服务端+客户端)或用户要求同时处理前端+后端:采用双SDK方案应用两个包及对应的初始化配置——切勿在无锁文件和入口点证据的情况下声称已完成第二个SDK的集成。
  • 单仓项目:集成用户在父级入门引导中选择的包;仅在该子目录内操作。
  • SDK已安装并初始化:父级流程可能跳过本次交接——请参考父级边缘情况检测决策树
  • 不支持或罕见技术栈:使用SDK 参考示例完整SDK目录

References

参考资料

  • Detect repository stack
  • Generate integration plan
  • Apply code changes
  • SDK recipes
  • SDK snippets
  • LaunchDarkly onboarding (parent)
  • 检测仓库技术栈
  • 生成集成方案
  • 应用代码变更
  • SDK 参考示例
  • SDK 代码片段
  • LaunchDarkly 入门引导(父级)