creating-experiments

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Creating experiments

创建实验

This skill walks through the 3-step flow for creating a new A/B test experiment.
本Skill引导完成创建新A/B测试实验的三步流程。

Core principle: draft first, iterate on details

核心原则:先起草,再细化细节

Create the experiment as a draft quickly, then iterate on metrics and configuration. The user gets a tangible draft immediately and can refine it.
快速将实验创建为草稿,然后迭代优化指标和配置。用户可立即获得一个有形的草稿,并对其进行完善。

The 3-step creation flow

三步创建流程

Step 1: What are we testing?

步骤1:我们要测试什么?

Gather these before calling
experiment-create
:
  • Experiment name — descriptive, inferred from context when possible
  • Hypothesis — what you expect to happen (goes in
    description
    )
  • Feature flag key — kebab-case. Ask if they want a new flag or to reuse an existing one. The flag is auto-created — do NOT create one separately.
  • Type — leave empty (will internally default to
    "product"
    . The
    "web"
    value is reserved for no-code experiments configured visually with the PostHog toolbar in a browser; it cannot be meaningfully driven via MCP. If a user asks for a no-code/toolbar experiment, point them to the PostHog UI instead of creating one here.)
If the user gives enough context to infer these, don't ask — just proceed.
在调用
experiment-create
之前,收集以下信息:
  • 实验名称 —— 描述性名称,尽可能从上下文推断
  • 假设 —— 您预期会发生的情况(填入
    description
    字段)
  • 功能标识键(Feature flag key) —— 使用短横线分隔格式(kebab-case)。询问用户是要创建新标识还是复用现有标识。标识会自动创建——请勿单独创建。
  • 类型 —— 留空(内部默认值为
    "product"
    "web"
    值专为通过浏览器中的PostHog工具栏可视化配置的无代码实验保留;无法通过MCP有效驱动。如果用户要求创建无代码/工具栏实验,请引导他们使用PostHog UI,而非在此处创建。)
如果用户提供的上下文足够推断这些信息,无需询问,直接继续。

Step 2: Who sees what variant?

步骤2:哪些用户会看到哪个变体?

This is about rollout configuration.
Before asking any rollout question, load
configuring-experiment-rollout
.
The disambiguation wording, recommendations, and post-answer branches live there — do not formulate rollout questions yourself, and do not assume an example you remember covers the user's path.
Key decision points (covered in detail by
configuring-experiment-rollout
):
  • Variant split (how many variants, what percentage each)
  • Overall rollout percentage (what % of all users enter the experiment)
  • Whether to persist the flag across authentication steps
If the user doesn't mention rollout specifics, use defaults: 50/50 control/test, 100% rollout.
这部分涉及发布配置。
在询问任何发布相关问题之前,请加载
configuring-experiment-rollout
歧义消除措辞、建议以及回答后的分支逻辑都在该Skill中——请勿自行设计发布相关问题,也不要假设您记得的示例能覆盖用户的所有路径。
关键决策点(
configuring-experiment-rollout
中有详细说明):
  • 变体分配比例(有多少个变体,每个变体的占比)
  • 整体发布比例(有多少百分比的所有用户会进入实验)
  • 是否在身份验证步骤之间保留标识
如果用户未提及发布细节,使用默认值:对照组/测试组各50%,100%发布。

Step 3: How to measure impact?

步骤3:如何衡量影响?

This is about analytics and metrics. Load the
configuring-experiment-analytics
skill
for guidance.
Do NOT configure metrics on creation. Metrics are not passed to
experiment-create
— they are added afterwards via
experiment-update
. This keeps the creation call lightweight.
When the user specifies metrics upfront, acknowledge them and add them immediately after creation. When they don't, create the draft and then guide them through metric setup as a follow-up.
这部分涉及分析和指标。加载
configuring-experiment-analytics
Skill获取指导。
请勿在创建时配置指标。 指标不会传递给
experiment-create
——而是在创建后通过
experiment-update
添加。这样可以让创建调用更轻量化。
如果用户预先指定了指标,请确认并在创建后立即添加。如果未指定,先创建草稿,然后引导他们后续完成指标设置。

How to create

创建方法

Call
experiment-create
with:
json
{
  "name": "Descriptive experiment name",
  "feature_flag_key": "kebab-case-key",
  "description": "Hypothesis: [what you expect to happen]",
  "parameters": {
    "feature_flag_variants": [
      { "key": "control", "name": "Control", "split_percent": 50 },
      { "key": "test", "name": "Test", "split_percent": 50 }
    ],
    "rollout_percentage": 100
  }
}
Two different percentages — do NOT mix them up:
  • feature_flag_variants[].split_percent
    — how users inside the experiment are split across variants (must sum to 100, recommended to have an even split).
  • parameters.rollout_percentage
    — what fraction of all users enter the experiment at all (0-100, defaults to 100).
Key details:
  • First variant must have key
    "control"
    . Minimum 2, maximum 20 variants.
  • rollout_percentage
    defaults to 100 if omitted.
  • Stats default to Bayesian. Only set
    stats_config
    if the user requests Frequentist.
调用
experiment-create
时传入以下参数:
json
{
  "name": "Descriptive experiment name",
  "feature_flag_key": "kebab-case-key",
  "description": "Hypothesis: [what you expect to happen]",
  "parameters": {
    "feature_flag_variants": [
      { "key": "control", "name": "Control", "split_percent": 50 },
      { "key": "test", "name": "Test", "split_percent": 50 }
    ],
    "rollout_percentage": 100
  }
}
注意两个不同的百分比——请勿混淆:
  • feature_flag_variants[].split_percent
    —— 实验内用户在各变体间的分配比例(总和必须为100,建议平均分配)。
  • parameters.rollout_percentage
    —— 所有用户中进入实验的比例(0-100,默认值为100)。
关键细节:
  • 第一个变体的键必须为
    "control"
    。变体数量最少2个,最多20个。
  • 如果省略
    rollout_percentage
    ,默认值为100。
  • 统计方法默认采用贝叶斯法。仅当用户要求使用频率主义法时,才设置
    stats_config

After creation

创建后操作

  1. Always show the experiment URL. The
    experiment-create
    response includes
    _posthogUrl
    — always display this link so the user can view and configure the experiment in the UI.
  2. Remind the user to implement the feature flag in code. Link to the experiment page and say "implement the flag as shown here" — the experiment detail page shows implementation snippets for the user's SDK.
  3. Guide through metrics if not yet configured — load the
    configuring-experiment-analytics
    skill.
  4. Launch when ready — use the
    experiment-launch
    tool.
  1. 始终展示实验URL。
    experiment-create
    的响应包含
    _posthogUrl
    ——务必显示此链接,以便用户在UI中查看和配置实验。
  2. 提醒用户在代码中实现功能标识。 链接到实验页面并说明“按此处所示实现标识”——实验详情页面会显示适用于用户SDK的代码片段。
  3. 如果尚未配置指标,引导用户完成设置——加载
    configuring-experiment-analytics
    Skill。
  4. 准备就绪后启动实验——使用
    experiment-launch
    工具。