first-flag

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create first feature flag

创建首个功能标志

The SDK is connected. Now help the user create their first feature flag and see it work end-to-end.
This skill is nested under LaunchDarkly onboarding; the parent Step 6 is first flag. Prior: Apply code changes.
Optional -- Flag Create skill already installed: If the
launchdarkly-flag-create
skill from github.com/launchdarkly/ai-tooling is available in the session (install with
npx skills add launchdarkly/ai-tooling --skill launchdarkly-flag-create -y --agent <agent>
), you may use it for creating the flag and choosing evaluation code that matches the repo. You must still complete default off -> verify OFF -> toggle on -> verify ON (Steps 3-5 below). Do not require that skill: this page stays the full fallback when it is missing or MCP-only flows conflict with the user's setup.
SDK已连接。现在帮助用户创建他们的首个功能标志并验证其端到端运行效果。
本技能隶属于LaunchDarkly 入门流程;父级流程的第6步为「创建首个标志」。前置步骤:应用代码变更
可选——已安装Flag Create技能: 如果会话中已存在来自github.com/launchdarkly/ai-tooling的**
launchdarkly-flag-create
技能(可通过
npx skills add launchdarkly/ai-tooling --skill launchdarkly-flag-create -y --agent <agent>
安装),你可以使用它来
创建标志选择与代码库匹配的评估代码**。但你仍需完成「默认关闭→验证关闭状态→切换开启→验证开启状态」(以下步骤3-5)。不要强制要求使用该技能:当该技能缺失或MCP专属流程与用户配置冲突时,本页面将作为完整的备用方案。

Security: Credential handling

安全:凭证处理

Never substitute literal token values into commands. Use environment variable references instead:
  • Shell commands:
    $LAUNCHDARKLY_ACCESS_TOKEN
    (expanded by the shell, not visible in
    ps
    output)
  • Set the variable in your session:
    export LAUNCHDARKLY_ACCESS_TOKEN=<your-token>
This prevents tokens from appearing in process lists, shell history, and screen recordings.
切勿在命令中直接写入令牌明文值,请改用环境变量引用:
  • Shell命令:
    $LAUNCHDARKLY_ACCESS_TOKEN
    (由Shell展开,不会在
    ps
    输出中显示)
  • 在会话中设置变量:
    export LAUNCHDARKLY_ACCESS_TOKEN=<your-token>
这可防止令牌出现在进程列表、Shell历史记录和屏幕录制中。

Step 0: Consult SDK flag-key guidance

步骤0:参考SDK标志键指南

Before creating the flag or wiring evaluation code, check the Flag key behavior by SDK table below. Some SDKs transform flag keys before exposing them in application code (e.g. the React SDK camelCases kebab-case keys). The flag key you create in LaunchDarkly, the SDK/framework configuration, and the key you reference in code must all align.
  • If the SDK transforms keys (e.g. React
    useFlags()
    camelCases
    my-first-flag
    myFirstFlag
    ): generate evaluation code using the transformed key. The flag key in LaunchDarkly stays as-is (kebab-case is conventional).
  • If the SDK preserves keys as-is (most server-side SDKs): use the exact LaunchDarkly flag key string in code.
  • If the SDK supports both modes (e.g. React allows disabling camelCase via provider options): decide which mode the project uses (check existing code or provider config), then generate code that matches.
在创建标志或编写评估代码前,请查看下方的「各SDK标志键行为」表格。部分SDK会在将标志键暴露给应用代码前对其进行转换(例如React SDK会将短横线命名的键转换为驼峰命名)。你在LaunchDarkly中创建的标志键、SDK/框架配置以及代码中引用的键必须保持一致。
  • 若SDK会转换键(例如React
    useFlags()
    my-first-flag
    转换为
    myFirstFlag
    ):使用转换后的键生成评估代码。LaunchDarkly中的标志键保持原样(短横线命名为常规做法)。
  • 若SDK保留键的原始格式(大多数服务端SDK):在代码中使用LaunchDarkly标志键的精确字符串。
  • 若SDK支持两种模式(例如React允许通过provider选项禁用驼峰命名):确定项目使用的模式(检查现有代码或provider配置),然后生成匹配的代码。

Flag key behavior by SDK

各SDK标志键行为

SDKKey transformationCode key for
my-first-flag
Notes
React Web (
useFlags()
)
camelCase by default
myFirstFlag
reactOptions: { useCamelCaseFlagKeys: false }
on the provider disables this
React Native (
useFlags()
)
camelCase by default
myFirstFlag
Same
reactOptions
override available
Vue (
useLDFlag()
)
None (pass original key)
'my-first-flag'
JavaScript BrowserNone
'my-first-flag'
Node.js ServerNone
'my-first-flag'
Python ServerNone
'my-first-flag'
Go ServerNone
"my-first-flag"
Java ServerNone
"my-first-flag"
.NET ServerNone
"my-first-flag"
Ruby ServerNone
'my-first-flag'
Swift/iOSNone
"my-first-flag"
AndroidNone
"my-first-flag"
FlutterNone
'my-first-flag'
When wiring the evaluation code in Step 2 below, use the Code key column value, not the raw LaunchDarkly key, whenever the SDK applies a transformation.
SDK键转换规则
my-first-flag
对应的代码键
说明
React Web (
useFlags()
)
默认驼峰命名
myFirstFlag
在provider上设置
reactOptions: { useCamelCaseFlagKeys: false }
可禁用此功能
React Native (
useFlags()
)
默认驼峰命名
myFirstFlag
同样支持上述
reactOptions
配置覆盖
Vue (
useLDFlag()
)
无转换(保留原始键)
'my-first-flag'
JavaScript Browser无转换
'my-first-flag'
Node.js Server无转换
'my-first-flag'
Python Server无转换
'my-first-flag'
Go Server无转换
"my-first-flag"
Java Server无转换
"my-first-flag"
.NET Server无转换
"my-first-flag"
Ruby Server无转换
'my-first-flag'
Swift/iOS无转换
"my-first-flag"
Android无转换
"my-first-flag"
Flutter无转换
'my-first-flag'
在下方步骤2编写评估代码时,只要SDK会进行转换,就使用「代码键」列中的值,而非原始的LaunchDarkly键。

Step 1: Create the flag

步骤1:创建标志

REST / curl auth: Use
$LAUNCHDARKLY_ACCESS_TOKEN
as the
Authorization
header value (LaunchDarkly uses the raw token, no
Bearer
prefix). The shell expands the variable but doesn't log it.
REST / curl 认证: 使用
$LAUNCHDARKLY_ACCESS_TOKEN
作为
Authorization
头的值(LaunchDarkly使用原始令牌,无需
Bearer
前缀)。Shell会展开该变量但不会记录它。

Via MCP (preferred)

通过MCP(推荐)

If the LaunchDarkly MCP server is available, use
create-feature-flag
(or the equivalent flag-creation tool your server exposes):
  • Key:
    my-first-flag
    (or a name relevant to the user's project)
  • Name: "My First Flag"
  • Kind:
    boolean
  • Variations:
    true
    /
    false
  • Temporary:
    true
如果LaunchDarkly MCP服务器可用,使用
create-feature-flag
(或你的服务器提供的等效标志创建工具):
  • my-first-flag
    (或与用户项目相关的名称)
  • 名称:"My First Flag"
  • 类型
    boolean
  • 变体
    true
    /
    false
  • 临时标志
    true

Via LaunchDarkly API

通过LaunchDarkly API

bash
curl -s -X POST \
  "https://app.launchdarkly.com/api/v2/flags/PROJECT_KEY" \
  -H "Authorization: $LAUNCHDARKLY_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My First Flag",
    "key": "my-first-flag",
    "kind": "boolean",
    "variations": [
      {"value": true},
      {"value": false}
    ],
    "temporary": true
  }'
bash
curl -s -X POST \
  "https://app.launchdarkly.com/api/v2/flags/PROJECT_KEY" \
  -H "Authorization: $LAUNCHDARKLY_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My First Flag",
    "key": "my-first-flag",
    "kind": "boolean",
    "variations": [
      {"value": true},
      {"value": false}
    ],
    "temporary": true
  }'

Via ldcli

通过ldcli

bash
ldcli flags create \
  --access-token "$LAUNCHDARKLY_ACCESS_TOKEN" \
  --project PROJECT_KEY \
  --data '{"name": "My First Flag", "key": "my-first-flag", "kind": "boolean", "temporary": true}'
After creation, the flag starts with targeting OFF, serving the off variation (
false
) to everyone. When the project key is known, link the user to the flag's dashboard page:
https://app.launchdarkly.com/projects/{projectKey}/flags/my-first-flag
(substitute the real project key).
bash
ldcli flags create \
  --access-token "$LAUNCHDARKLY_ACCESS_TOKEN" \
  --project PROJECT_KEY \
  --data '{"name": "My First Flag", "key": "my-first-flag", "kind": "boolean", "temporary": true}'
创建完成后,标志默认处于目标关闭状态,向所有用户返回关闭变体(
false
)。当已知项目键时,将用户链接到标志的仪表盘页面:
https://app.launchdarkly.com/projects/{projectKey}/flags/my-first-flag
(替换为真实的项目键)。

Step 2: Add flag evaluation code

步骤2:添加标志评估代码

Add code to evaluate the flag in the application. Place this where it makes sense for the user's feature.
在应用中添加评估标志的代码,将其放置在适合用户功能的位置。

Server-side examples

服务端示例

javascript
// Node.js (@launchdarkly/node-server-sdk) -- ldClient is your initialized server client after waitForInitialization
const context = { kind: 'user', key: 'example-user-key', name: 'Example User' };
const showFeature = await ldClient.boolVariation('my-first-flag', context, false);

if (showFeature) {
  console.log('Feature is ON');
} else {
  console.log('Feature is OFF');
}
python
undefined
javascript
// Node.js (@launchdarkly/node-server-sdk) -- ldClient是初始化完成并调用waitForInitialization后的服务端客户端
const context = { kind: 'user', key: 'example-user-key', name: 'Example User' };
const showFeature = await ldClient.boolVariation('my-first-flag', context, false);

if (showFeature) {
  console.log('Feature is ON');
} else {
  console.log('Feature is OFF');
}
python
undefined

Python (launchdarkly-server-sdk) -- client is ldclient.get() after set_config

Python (launchdarkly-server-sdk) -- client是调用set_config后的ldclient.get()

from ldclient import Context
context = Context.builder("example-user-key").name("Example User").build() show_feature = client.variation("my-first-flag", context, False)
if show_feature: print("Feature is ON") else: print("Feature is OFF")

```go
// Go
context := ldcontext.NewBuilder("example-user-key").Name("Example User").Build()
showFeature, _ := ldClient.BoolVariation("my-first-flag", context, false)

if showFeature {
    fmt.Println("Feature is ON")
} else {
    fmt.Println("Feature is OFF")
}
from ldclient import Context
context = Context.builder("example-user-key").name("Example User").build() show_feature = client.variation("my-first-flag", context, False)
if show_feature: print("Feature is ON") else: print("Feature is OFF")

```go
// Go
context := ldcontext.NewBuilder("example-user-key").Name("Example User").Build()
showFeature, _ := ldClient.BoolVariation("my-first-flag", context, false)

if showFeature {
    fmt.Println("Feature is ON")
} else {
    fmt.Println("Feature is OFF")
}

Client-side examples

客户端示例

tsx
// React — useFlags() camelCases keys: "my-first-flag" → myFirstFlag (see Step 0 table)
import { useFlags } from 'launchdarkly-react-client-sdk';

function MyComponent() {
  const { myFirstFlag } = useFlags();

  return (
    <div>
      {myFirstFlag ? <p>Feature is ON</p> : <p>Feature is OFF</p>}
    </div>
  );
}
The React SDK's
useFlags()
hook camelCases kebab-case flag keys by default, so
my-first-flag
becomes
myFirstFlag
. If the project disables this via
reactOptions: { useCamelCaseFlagKeys: false }
on the provider, use the original key string instead. Always check the project's provider configuration before choosing which form to use — see the Flag key behavior table above.
tsx
// React — useFlags()会将键转换为驼峰命名:"my-first-flag" → myFirstFlag(见步骤0表格)
import { useFlags } from 'launchdarkly-react-client-sdk';

function MyComponent() {
  const { myFirstFlag } = useFlags();

  return (
    <div>
      {myFirstFlag ? <p>Feature is ON</p> : <p>Feature is OFF</p>}
    </div>
  );
}
React SDK的
useFlags()
钩子默认会将短横线命名的标志键转换为驼峰命名,因此
my-first-flag
会变为
myFirstFlag
。如果项目通过provider上的
reactOptions: { useCamelCaseFlagKeys: false }
禁用了此功能,请改用原始键字符串。在选择使用哪种形式前,请务必检查项目的provider配置——参考上方的「标志键行为表格」。

Step 3: Verify the default value

步骤3:验证默认值

With targeting OFF, the flag should evaluate to
false
. Run the application and confirm:
Feature is OFF
在目标关闭状态下,标志的评估结果应为
false
。运行应用并确认:
Feature is OFF

Step 4: Toggle the flag on

步骤4:切换标志为开启状态

Via MCP

通过MCP

The LaunchDarkly MCP server exposes
update-feature-flag
(JSON Patch), not a tool named
toggle-flag
-- use the tool names your MCP server lists.
Simplest path: Prefer ldcli or the LaunchDarkly API block below when you only need to turn the flag on once.
If using
update-feature-flag
:
Call it with
projectKey
,
featureFlagKey
, and
PatchWithComment.patch
as a JSON Patch array. Turning the flag on for an environment typically uses a
replace
operation on that environment's
on
field (confirm the exact path from
get-feature-flag
for your account if needed):
json
{
  "projectKey": "PROJECT_KEY",
  "featureFlagKey": "my-first-flag",
  "PatchWithComment": {
    "patch": [
      {
        "op": "replace",
        "path": "/environments/ENVIRONMENT_KEY/on",
        "value": true
      }
    ],
    "comment": "Onboarding: turn on my-first-flag"
  }
}
Replace
ENVIRONMENT_KEY
with the environment key for the environment you are targeting (e.g.
test
,
production
).
LaunchDarkly MCP服务器提供**
update-feature-flag
**(JSON Patch),而非名为
toggle-flag
的工具——请使用你的MCP服务器列出的工具名称。
最简路径: 当你只需要一次性开启标志时,优先使用ldcli或下方的LaunchDarkly API代码块。
若使用
update-feature-flag
传入
projectKey
featureFlagKey
以及作为JSON Patch数组的
PatchWithComment.patch
。要为某个环境开启标志,通常需要对该环境的
on
字段执行
replace
操作(如有需要,请从你的账户的
get-feature-flag
结果中确认确切路径):
json
{
  "projectKey": "PROJECT_KEY",
  "featureFlagKey": "my-first-flag",
  "PatchWithComment": {
    "patch": [
      {
        "op": "replace",
        "path": "/environments/ENVIRONMENT_KEY/on",
        "value": true
      }
    ],
    "comment": "Onboarding: turn on my-first-flag"
  }
}
ENVIRONMENT_KEY
替换为你目标环境的环境键(例如
test
production
)。

Via LaunchDarkly API

通过LaunchDarkly API

bash
curl -s -X PATCH \
  "https://app.launchdarkly.com/api/v2/flags/PROJECT_KEY/my-first-flag" \
  -H "Authorization: $LAUNCHDARKLY_ACCESS_TOKEN" \
  -H "Content-Type: application/json; domain-model=launchdarkly.semanticpatch" \
  -d '{
    "environmentKey": "ENVIRONMENT_KEY",
    "instructions": [
      {"kind": "turnFlagOn"}
    ]
  }'
bash
curl -s -X PATCH \
  "https://app.launchdarkly.com/api/v2/flags/PROJECT_KEY/my-first-flag" \
  -H "Authorization: $LAUNCHDARKLY_ACCESS_TOKEN" \
  -H "Content-Type: application/json; domain-model=launchdarkly.semanticpatch" \
  -d '{
    "environmentKey": "ENVIRONMENT_KEY",
    "instructions": [
      {"kind": "turnFlagOn"}
    ]
  }'

Via ldcli

通过ldcli

bash
ldcli flags toggle-on \
  --access-token "$LAUNCHDARKLY_ACCESS_TOKEN" \
  --project PROJECT_KEY \
  --environment ENVIRONMENT_KEY \
  --flag my-first-flag
bash
ldcli flags toggle-on \
  --access-token "$LAUNCHDARKLY_ACCESS_TOKEN" \
  --project PROJECT_KEY \
  --environment ENVIRONMENT_KEY \
  --flag my-first-flag

Step 5: Verify the toggle

步骤5:验证切换效果

After toggling the flag on, the application should now show:
Feature is ON
For server-side SDKs using streaming (the default), the change should be reflected within seconds. For client-side SDKs, the change appears on the next page load or when the SDK polls for updates.
切换标志为开启状态后,应用应显示:
Feature is ON
对于使用流式传输(默认配置)的服务端SDK,变更应在数秒内生效。对于客户端SDK,变更会在下次页面加载或SDK轮询更新时显示。

Step 6: Add an interactive demo

步骤6:添加交互式演示

Now that the flag works, add a visible, interactive element so the user can see the flag in action -- not just a console log. This creates a "wow" moment and gives the user a tangible proof point they can show others.
Choose the right demo based on what you detected:
App typeWhat to addUser experience
Frontend (React, Vue, SPA)A banner, badge, or button gated by the flagToggle flag in dashboard → refresh page → element appears/disappears
Backend API (Node, Python, Go, etc.)A
/launchdarkly-demo
endpoint that returns flag state as JSON
curl
the endpoint → toggle flag →
curl
again → response changes
Full-stack (Next.js SSR, Rails, etc.)Both: an API endpoint + a UI element that displays the flag stateToggle flag → see both API and UI reflect the change
CLI / scriptA
--feature-demo
flag or distinct output mode
Run script → toggle flag → run again → output changes
现在标志已正常工作,添加一个可见的交互式元素,让用户可以直观看到标志的运行效果——而不仅仅是控制台日志。这会创造一个“惊喜时刻”,为用户提供一个可以展示给他人的切实验证点。
根据检测到的应用类型选择合适的演示方式:
应用类型需添加的内容用户体验
前端(React、Vue、SPA)由标志控制的横幅、徽章或按钮在仪表盘中切换标志→刷新页面→元素显示/隐藏
后端API(Node、Python、Go等)返回标志状态JSON的
/launchdarkly-demo
端点
curl
该端点→切换标志→再次
curl
→响应内容变更
全栈(Next.js SSR、Rails等)同时添加:API端点 + 显示标志状态的UI元素切换标志→查看API和UI均反映变更
CLI / 脚本
--feature-demo
标志或独特的输出模式
运行脚本→切换标志→再次运行→输出内容变更

Frontend demo example (React)

前端演示示例(React)

Add a component or element that's visually obvious when the flag is on:
tsx
// Add to an existing page component
import { useFlags } from 'launchdarkly-react-client-sdk';

function FeatureFlagDemo() {
  const { myFirstFlag } = useFlags();

  if (!myFirstFlag) return null;

  return (
    <div style={{
      padding: '12px 20px',
      backgroundColor: '#405BFF',
      color: 'white',
      borderRadius: '8px',
      margin: '16px 0',
      fontWeight: 500
    }}>
      LaunchDarkly is working — this banner is controlled by a feature flag
    </div>
  );
}
Place it somewhere visible (e.g., at the top of the main page or in a dashboard/header area).
添加一个在标志开启时视觉上非常明显的组件或元素:
tsx
// 添加到现有页面组件中
import { useFlags } from 'launchdarkly-react-client-sdk';

function FeatureFlagDemo() {
  const { myFirstFlag } = useFlags();

  if (!myFirstFlag) return null;

  return (
    <div style={{
      padding: '12px 20px',
      backgroundColor: '#405BFF',
      color: 'white',
      borderRadius: '8px',
      margin: '16px 0',
      fontWeight: 500
    }}>
      LaunchDarkly 已生效 — 此横幅由功能标志控制
    </div>
  );
}
将其放置在显眼位置(例如主页顶部或仪表盘/页眉区域)。

Backend demo example (Node.js/Express)

后端演示示例(Node.js/Express)

Add an endpoint that returns the flag state:
javascript
// Add to your Express app (or equivalent for other frameworks)
app.get('/launchdarkly-demo', async (req, res) => {
  const context = { kind: 'user', key: 'demo-user' };
  const flagValue = await ldClient.boolVariation('my-first-flag', context, false);
  
  res.json({
    flag: 'my-first-flag',
    enabled: flagValue,
    message: flagValue 
      ? 'LaunchDarkly is working — the flag is ON'
      : 'LaunchDarkly is working — the flag is OFF'
  });
});
Tell the user to test with:
curl http://localhost:PORT/launchdarkly-demo
添加一个返回标志状态的端点:
javascript
// 添加到你的Express应用中(其他框架可参考等效实现)
app.get('/launchdarkly-demo', async (req, res) => {
  const context = { kind: 'user', key: 'demo-user' };
  const flagValue = await ldClient.boolVariation('my-first-flag', context, false);
  
  res.json({
    flag: 'my-first-flag',
    enabled: flagValue,
    message: flagValue 
      ? 'LaunchDarkly is working — the flag is ON'
      : 'LaunchDarkly is working — the flag is OFF'
  });
});
告知用户使用以下命令测试:
curl http://localhost:PORT/launchdarkly-demo

Backend demo example (Python/Flask)

后端演示示例(Python/Flask)

python
@app.route('/launchdarkly-demo')
def launchdarkly_demo():
    context = Context.builder("demo-user").build()
    flag_value = ld_client.variation("my-first-flag", context, False)
    
    return jsonify({
        "flag": "my-first-flag",
        "enabled": flag_value,
        "message": "LaunchDarkly is working — the flag is ON" if flag_value 
                   else "LaunchDarkly is working — the flag is OFF"
    })
python
@app.route('/launchdarkly-demo')
def launchdarkly_demo():
    context = Context.builder("demo-user").build()
    flag_value = ld_client.variation("my-first-flag", context, False)
    
    return jsonify({
        "flag": "my-first-flag",
        "enabled": flag_value,
        "message": "LaunchDarkly is working — the flag is ON" if flag_value 
                   else "LaunchDarkly is working — the flag is OFF"
    })

Full-stack demo

全栈演示

For apps with both server and client (e.g., Next.js, Remix, Rails with frontend):
  1. Add the API endpoint (backend example above)
  2. Add a UI component that either calls the endpoint or uses the client SDK directly
  3. The user can verify both paths work
对于同时包含服务端和客户端的应用(例如Next.js、Remix、带前端的Rails):
  1. 添加API端点(参考上方后端示例)
  2. 添加一个调用该端点或直接使用客户端SDK的UI组件
  3. 用户可验证两种路径均正常工作

Guidelines

指南

  1. Match existing patterns -- use the same routing style, component conventions, and code style as the rest of the app
  2. Make it obvious -- use color, position, or text that clearly indicates this is the LaunchDarkly demo
  3. Keep it removable -- add a brief comment like
    // LaunchDarkly demo - safe to remove
    so the user knows they can delete it later (or keep it as a template)
  4. Don't over-engineer -- this is a demo, not a production feature; a few lines of code is ideal
  1. 匹配现有模式——使用与应用其余部分相同的路由风格、组件约定和代码风格
  2. 确保醒目——使用颜色、位置或文本清晰表明这是LaunchDarkly演示内容
  3. 便于移除——添加简短注释,例如
    // LaunchDarkly demo - safe to remove
    ,让用户知道他们以后可以删除这段代码(或保留作为模板)
  4. 避免过度设计——这只是演示,不是生产功能;几行代码即可

Walk the user through it

引导用户完成演示

After adding the demo element:
  1. Tell the user where you added it and how to see it (URL, page location, command)
  2. Have them verify it shows the current flag state
  3. Ask them to toggle the flag in the dashboard (provide the deep link:
    https://app.launchdarkly.com/projects/{projectKey}/flags/my-first-flag
    )
  4. Have them refresh/re-run to see the change
  5. Celebrate the successful integration
添加演示元素后:
  1. 告知用户你添加的位置以及查看方式(URL、页面位置、命令)
  2. 让他们验证元素显示了当前标志状态
  3. 让他们在仪表盘中切换标志(提供深度链接:
    https://app.launchdarkly.com/projects/{projectKey}/flags/my-first-flag
  4. 让他们刷新/重新运行应用以查看变更
  5. 庆祝集成成功

Congratulations

恭喜

The user has successfully:
  1. Installed the LaunchDarkly SDK
  2. Connected it to LaunchDarkly
  3. Created a feature flag
  4. Evaluated it in code
  5. Toggled it and seen the result
  6. Added an interactive demo they can show others
This is the "proof point" moment -- the user has a working feature flag they can toggle in real-time. The demo element makes it tangible and shareable.
Encourage the next skill: Suggest they install or enable the
launchdarkly-flag-create
skill from github.com/launchdarkly/ai-tooling (
npx skills add launchdarkly/ai-tooling --skill launchdarkly-flag-create -y --agent <agent>
) so future work -- creating flags that match repo conventions, wrapping features, and verifying wiring -- has a dedicated playbook. Offer to help them add it if they are unsure how.
用户已成功完成以下操作:
  1. 安装LaunchDarkly SDK
  2. 将SDK连接到LaunchDarkly
  3. 创建功能标志
  4. 在代码中评估标志
  5. 切换标志并查看结果
  6. 添加可展示给他人的交互式演示
这是“验证点”时刻——用户拥有了一个可实时切换的功能标志。演示元素让整个流程变得切实可感且便于分享。
推荐下一步技能: 建议用户安装或启用来自github.com/launchdarkly/ai-tooling的**
launchdarkly-flag-create
**技能(命令:
npx skills add launchdarkly/ai-tooling --skill launchdarkly-flag-create -y --agent <agent>
),以便后续工作——创建符合代码库约定的标志、封装功能以及验证连接——有专门的操作手册。如果用户不确定如何安装,可主动提供帮助。

Error handling

错误处理

Authorization errors

授权错误

If any step returns a 401 or 403:
D9 -- BLOCKING: Call your structured question tool now.
  • question: "I received an authorization error ([specific status code and message]). This requires your action to resolve -- I cannot retry automatically."
  • options:
    • "I'll re-authenticate -- run ldcli login or refresh my token"
    • "Let me check my access token and try again"
    • "I don't have an account -- help me sign up"
    • "The project or environment doesn't exist -- help me create one"
  • STOP. Do not write the question as text. Do not retry authorization errors automatically -- they always require user action. Do not continue until the user selects an option.
如果任何步骤返回401403错误:
D9 -- 阻塞: 立即调用结构化问题工具。
  • 问题:"我收到了授权错误([具体状态码和消息])。这需要你进行操作才能解决——我无法自动重试。"
  • 选项:
    • "我将重新认证——运行ldcli login或刷新我的令牌"
    • "让我检查我的访问令牌并重试"
    • "我没有账户——帮我注册"
    • "项目或环境不存在——帮我创建"
  • 停止操作。不要将问题以文本形式写出。不要自动重试授权错误——这类错误始终需要用户操作。在用户选择选项前,不要继续执行后续步骤。

Other errors

其他错误

For non-auth errors (flag creation failures, SDK key mismatches, flags returning fallback values, etc.), diagnose the issue using the error output, application logs, and your understanding of the project.
Next steps to suggest:
  • Install
    launchdarkly-flag-create
    from github.com/launchdarkly/ai-tooling if it is not already available -- this onboarding flow only covers a first boolean flag; that skill guides real-world flag creation aligned with existing code patterns (requires LaunchDarkly MCP per that skill's prerequisites).
  • Use
    launchdarkly-flag-targeting
    from the same distribution to set up percentage rollouts and targeting rules
  • Read the LaunchDarkly docs for advanced topics like contexts, experimentation, and metrics

Upon completion, continue with: Onboarding summary and Editor rules and skills (default follow-through in the parent onboarding skill -- not MCP setup, which is Step 4). For MCP install or troubleshooting, use mcp-configure and MCP Config Templates.
对于非授权错误(标志创建失败、SDK键不匹配、标志返回 fallback 值等),使用错误输出、应用日志以及你对项目的理解来诊断问题。
建议的下一步:
  • 如果尚未安装,安装来自github.com/launchdarkly/ai-tooling的**
    launchdarkly-flag-create
    **——本入门流程仅涵盖首个布尔型标志;该技能会引导创建符合现有代码模式的真实场景标志(需满足该技能的前置条件LaunchDarkly MCP)。
  • 使用同一分发版本中的**
    launchdarkly-flag-targeting
    **设置百分比发布和目标规则
  • 阅读LaunchDarkly 文档了解上下文、实验和指标等进阶主题

完成后,继续进行: 入门总结编辑器规则与技能(父级入门技能中的默认后续流程——不是MCP设置,MCP设置为步骤4)。如需MCP安装或故障排除,请使用mcp-configureMCP配置模板