Ab test design

From FerroxLabs/murage · View interactive version

Ab test design is an AI agent skill from the GitHub repository FerroxLabs/murage. Designs A/B tests with hypothesis, control and variant definitions, primary metric, sample size calculation, test duration, and analysis plan using experimentation methodology. Use when the user asks about A/B testing, experiment design, split testing, hypothesis testing, or controlled experiments.

How to use this skill

Skill file

A/B Test Design

When to Use

Use this skill when:

Do NOT use this skill when:


Process

Step 1: Clarify the Business Question and Change Hypothesis

Before writing anything, extract the minimum required inputs from the user. Do not proceed to design without understanding these fundamentals.


Step 2: Write a Falsifiable, Directional Hypothesis

The hypothesis is not a wish. It is a structured prediction that can be proven false.


Step 3: Define Control and Variant with Surgical Precision

Ambiguous variant definitions are the single most common source of test failure in practice.


Step 4: Select Primary Metric, Secondary Metrics, and Guardrail Metrics

Metric selection is a design choice with major consequences. Getting this wrong invalidates the entire experiment.


Step 5: Calculate Sample Size and Test Duration

This is the most technically demanding step. Walk through it explicitly -- do not skip or estimate loosely.

Inputs required:

Sample size formula for proportions (exact):

For a two-tailed test at alpha=0.05, power=0.80:

n = (z_alpha/2 + z_beta)^2 * (p1*(1-p1) + p2*(1-p2)) / (p1 - p2)^2

Where:

Practical approximation for proportions:

n ≈ 16 * p * (1-p) / d^2

Where d = absolute MDE in proportion terms. This approximation is valid when p is between 0.05 and 0.50.

For continuous metrics (revenue per user, session length):

n = 2 * (z_alpha/2 + z_beta)^2 * sigma^2 / d^2

Where sigma is the standard deviation of the metric and d is the absolute MDE. This requires historical standard deviation data, not just a mean.

Duration calculation:

Duration (days) = n_per_variant / (daily_eligible_traffic * allocation_fraction)

Duration constraints:

Novelty effect buffer: For changes to UI elements users interact with daily (navigation, feed ranking, dashboard layout), add a novelty effect observation period. Plan to analyze the first 7 days separately from subsequent days. Novelty effects manifest as an initial spike in engagement that decays to a true steady-state effect. The steady-state result is the reliable signal.


Step 6: Define Traffic Allocation and Assignment Mechanism


Step 7: Write the Pre-Registered Analysis Plan

The analysis plan must be written and locked before the test launches. Changes after seeing data are p-hacking by definition.

1. Ship variant: Primary metric improves by >= MDE with p < alpha and no guardrail violations.

2. Keep control: Primary metric shows statistically significant degradation (p < alpha in wrong direction) OR any guardrail metric violates its threshold.

3. Inconclusive -- extend: Result is not significant but sample size was not fully reached (early termination scenario). Extend by a pre-specified increment (typically 1 additional week).

4. Inconclusive -- conclude: Minimum sample size and duration were reached. Result is not significant. The test has adequate power. Conclude "no detectable effect at the specified MDE." This is a valid result -- it means the change did not produce the effect hypothesized at the specified magnitude. Do not call it "neutral" and ship anyway.


Step 8: Assemble the Test Documentation and Communication Plan


Output Format

## A/B Test Design: [Test Name]

---

### Test Overview

| Field              | Value                                      |
|--------------------|-------------------------------------------|
| Test name          | [Descriptive name: Component-Change-Goal] |
| Experiment ID      | [Internal tracking ID if applicable]      |
| Owner              | [Name / Team]                             |
| Status             | [Draft / Ready for Review / Approved / Running / Complete] |
| Target launch date | [Date]                                    |
| Results read date  | [Date = launch + estimated duration]      |
| Estimated duration | [X weeks]                                 |
| Platform           | [Web / iOS / Android / Email / Server-side] |
| Eligible audience  | [Description of eligible user population] |

---

### Business Context

[1-3 sentences on why this test is being run now. What business problem or
opportunity does it address? What will the team do with the result?]

---

### Hypothesis

**If** [specific, singular change to the experience],
**then** [named metric] will [increase/decrease] by [X% relative / X pp absolute]
(from [current baseline] to [expected variant value]),
**because** [behavioral mechanism connecting the change to the outcome].

**Hypothesis type:** [Optimization / Exploratory / Defensive]
**Test directionality:** [Two-tailed (default) / One-tailed (justify reason)]

---

### Variants

| Variant        | Description                                  | Implementation Notes       |
|----------------|----------------------------------------------|---------------------------|
| Control (A)    | [Current production experience -- precise description] | [Engineering notes] |
| Variant (B)    | [Modified experience -- precise description] | [Engineering notes]        |

**Single variable changed:** [Exactly one element that differs between A and B]

**What is explicitly NOT changed:** [List of elements confirmed identical]

---

### Metrics

| Type        | Metric Name                    | Measurement Method         | Baseline Value | Target / Threshold        |
|-------------|-------------------------------|---------------------------|----------------|--------------------------|
| PRIMARY     | [Metric name]                  | [Event name / query]       | [X%]           | [+X% relative / +X pp]   |
| Secondary   | [Metric name]                  | [Event name / query]       | [X]            | [Direction: increase]     |
| Secondary   | [Metric name]                  | [Event name / query]       | [X]            | [Direction: increase]     |
| GUARDRAIL   | [Metric name]                  | [Event name / query]       | [X]            | Must not exceed [X]       |
| GUARDRAIL   | [Metric name]                  | [Event name / query]       | [X]            | Must not degrade > X%     |

---

### Sample Size and Duration Calculation

| Parameter                      | Value                                      |
|-------------------------------|-------------------------------------------|
| Baseline conversion rate       | [X%]                                      |
| Minimum detectable effect      | [X% relative] = [X pp absolute]           |
| Expected variant rate          | [X%]                                      |
| Significance level (alpha)     | 0.05 (two-tailed)                         |
| Statistical power              | 0.80                                      |
| Required sample per variant    | [N users]                                 |
| Total required sample          | [2N users]                                |
| Daily eligible traffic         | [X users/day]                             |
| Traffic allocation per variant | [50%] = [X users/day per variant]         |
| Raw duration                   | [X days]                                  |
| **Adjusted duration (full weeks)** | **[X weeks] (rounded up to [Y days])** |
| Test start date                | [Date]                                    |
| First valid analysis date      | [Date = start + adjusted duration]        |

**Sample size calculation method:** [Two-proportion z-test / formula used]
**Variance reduction:** [CUPED applied / Not applied -- reason]

---

### Traffic Allocation

| Setting                 | Value                                              |
|------------------------|----------------------------------------------------|
| Allocation method       | [User ID hash / Session ID / Device ID]            |
| Traffic split           | [50% Control (A) / 50% Variant (B)]                |
| Sticky assignment       | Yes -- same user always sees same variant           |
| Ramp-up plan            | [None / Ramp: 10% variant for 48h, then 50/50]     |
| Exclusions              | [Internal employees, bots, users in Experiment X]  |
| Mutual exclusivity      | [Confirm no overlapping experiments on same surface]|

---

### Pre-Registered Analysis Plan

**Primary statistical test:** [Two-proportion z-test / Two-sample t-test / Mann-Whitney U]
**Analysis date:** [Date -- minimum sample size AND minimum duration satisfied]
**Peeking policy:** No analysis before the analysis date. No metric review before this date.

**Decision rules (pre-registered):**

| Outcome                     | Condition                                                  | Action                               |
|-----------------------------|-----------------------------------------------------------|--------------------------------------|
| Ship variant                | Primary metric >= MDE, p < 0.05, no guardrail violations   | Ramp variant to 100%                 |
| Keep control                | Primary metric significantly degrades (p < 0.05, wrong direction) OR any guardrail violation | Revert / stop test immediately |
| Inconclusive -- extend      | Sample size not yet reached at planned read date           | Extend by [X] days, re-read at [date]|
| Inconclusive -- conclude    | Sample size reached, result not significant                | No ship. Conclude no detectable effect at specified MDE. Document learnings. |

**Novelty effect check:** Compare primary metric for days 1-7 vs. days 8+ within variant group.

**Pre-registered segment analyses (if any):**
- [Segment name]: [Metric] by [Segment definition]

**Post-hoc segment results** (not pre-registered) will be treated as hypotheses for future tests only.

---

### Logging and Implementation Verification

| Check                     | Verified By     | Date Verified |
|--------------------------|-----------------|---------------|
| Assignment logging confirmed | [Name]       | [Date]        |
| Primary metric event firing  | [Name]       | [Date]        |
| Guardrail metric events firing | [Name]     | [Date]        |
| Sticky assignment verified (query) | [Name] | [Date]        |
| SRM check scheduled (48h post-launch) | [Name] | [Date]   |
| Internal users excluded      | [Name]       | [Date]        |

---

### Risks and Mitigations

| Risk                                  | Likelihood | Mitigation                                   |
|---------------------------------------|-----------|----------------------------------------------|
| [e.g., Seasonality during test window]| Medium    | [Extend to capture full cycle, note in results]|
| [e.g., Overlapping experiment]        | Low       | [Confirmed mutex with Experiment Y]          |
| [e.g., Low traffic -- long duration]  | High      | [Increased MDE to 15% to reduce to 4 weeks] |

Rules

  1. Never change the primary metric, MDE, or stopping rules after seeing any data, even partial data. This is p-hacking regardless of intent. If the team feels compelled to change the metric after seeing preliminary results, stop the test, treat it as null, and redesign. The pre-registered analysis plan is a contract.
  1. Change exactly one variable between control and variant without exception. If engineering "also fixed a small bug" in the variant, the test is contaminated and cannot be analyzed as a clean A/B test. If multiple changes must go out together, ship them as one unit of change and accept that the test measures the bundle effect.
  1. Always check for Sample Ratio Mismatch (SRM) before analyzing results. Run a chi-squared test on observed group sizes vs. expected sizes. If p < 0.01 for the SRM test, the assignment mechanism is broken. Do not analyze business metrics until SRM is resolved. Common SRM causes: bot traffic, caching bugs, redirect logic affecting one variant differently, logging failures.
  1. Never run a test without first confirming that all metric events are logging correctly in production. Verify the primary metric event fires correctly by running an A/A test (same experience in both groups) for 24-48 hours pre-launch and confirming no statistically significant difference. An A/A test also serves as a calibration check on the randomization mechanism.
  1. Always specify guardrail metrics with quantitative thresholds, not qualitative direction. "Page load time should not increase" is unenforceable. "P95 page load time must not increase by more than 200ms from baseline (baseline: 1,800ms -- threshold: 2,000ms)" is enforceable and enables automated alerting.
  1. Test duration must cover a minimum of 7 days, and must be extended to the nearest full week above the calculated raw duration. A test that runs 10 days includes one full weekend but only one Monday and one Friday. A 14-day test (2 full weeks) is the minimum for reliable results in most product contexts. This is non-negotiable even if the sample size is reached in 5 days.
  1. Assignment must be user-level and sticky for any experiment involving multi-session user behavior. Session-level assignment is permissible only for single-session, anonymous contexts (e.g., landing page A/B test for paid traffic with no login). For any logged-in product, a user who sees variant B on Monday and control A on Wednesday is contaminated -- they will introduce noise that biases results toward null.
  1. The sample size calculation must use the actual daily eligible traffic, not total daily traffic. If 10,000 users visit the site daily but only 3,000 visit the pricing page, the sample size for a pricing page experiment accrues at 3,000/day (or 1,500/day per variant at 50/50). Using the wrong denominator will underestimate test duration by 3x and produce a massively underpowered test.
  1. Do not use statistical significance alone as the decision criterion. A result can be statistically significant and practically meaningless (0.1% absolute improvement on a 2% conversion rate with a sample of 2,000,000 users). Always evaluate: (a) Is the effect size above the MDE? (b) Is the confidence interval entirely above zero and above the practical significance threshold? (c) Are secondary and guardrail metrics directionally consistent? All three must be satisfied to ship.
  1. If the team is running more than one test simultaneously on the same surface or same downstream metric, enforce mutual exclusivity or use an interaction test design. Two tests on the same onboarding page will have interaction effects. If a user sees Variant B from Test 1 and Variant B from Test 2, neither test can cleanly attribute effects. A mutual exclusivity layer routes each user into at most one experiment per surface. If mutual exclusivity is not technically feasible, document the overlap and adjust expected power accordingly.
  1. Distinguish between "no statistically significant effect" and "no effect." An underpowered test that finds p=0.12 does not mean the change is neutral -- it means the test was not large enough to detect an effect at the specified MDE. Report results with the confidence interval: "We could not detect a difference greater than [MDE] with 80% power. Effects smaller than [MDE] remain possible." Do not ship based on this reasoning, but do not incorrectly characterize the result as proof of neutrality either.
  1. Never set up a test without a pre-specified "kill switch" rule. Define in advance the condition under which the test will be stopped early due to harm: "If the checkout error rate exceeds 3% (versus baseline 0.5%), or if revenue per user drops more than 15% relative in a rolling 24-hour window, pause the test immediately and revert." This rule should be automated via monitoring alerts where possible.

Edge Cases

Very Low Traffic (Fewer Than 1,000 Daily Eligible Users)

When daily eligible traffic is below 1,000 users, standard frequentist A/B testing requires test durations that are impractical (often 3-6 months).

Revenue or High-Variance Continuous Metric as Primary

Revenue per user, order value, and lifetime value metrics have highly skewed distributions (a small number of high-value users drive disproportionate variance). This has major implications.

Tests Involving Network Effects (Social Products, Marketplace Products)

Standard A/B testing assumes the Stable Unit Treatment Value Assumption (SUTVA): a user's outcome is not affected by the variant assignment of other users. This assumption is violated in social networks, two-sided marketplaces, and communication tools.

Tests Interrupted by External Events

Seasonality, competitor announcements, major news events, or product outages that occur during the test window can contaminate results.

Multi-Platform Experiments (Web + iOS + Android)

Many product experiments need to run across multiple platforms simultaneously, but baseline conversion rates, user behavior, and population composition differ by platform.

Novelty Effects and Learning Effects

Some changes produce short-term behavioral changes that do not reflect the long-run steady-state effect.

Experiment Holdback for Long-Term Effect Measurement

For features that are shipped and expected to have compounding long-term effects (onboarding changes, habit-forming features, pricing tier changes), a single A/B test measuring 2-4 weeks of behavior may not capture the full effect.


Example

Input: "We redesigned the onboarding empty state for our project management app. Right now, new users see a blank dashboard with just a 'Create your first project' button. We want to test showing a template gallery (3 featured project templates with preview cards) instead. We think it'll improve activation. We have about 800 new user signups per day, and our current 'first project created within 7 days' rate is 22%. We're targeting B2B teams."


Output:

A/B Test Design: Onboarding Empty State -- Template Gallery vs. Blank CTA


Test Overview

| Field | Value |

|------------------------|----------------------------------------------------------------|

| Test name | Onboarding Empty State -- Template Gallery vs. Blank CTA |

| Experiment ID | EXP-2024-047 |

| Owner | Product Manager, Onboarding Squad |

| Status | Draft |

| Target launch date | [Date TBD pending engineering verification] |

| Results read date | Launch date + 28 days |

| Estimated duration | 4 weeks |

| Platform | Web (logged-in new users, first session post-signup) |

| Eligible audience | New registered users (account age <= 24 hours) on first dashboard visit |


Business Context

New user activation is the primary growth lever for the product: users who create their first project within 7 days have a 3.4x higher 30-day retention rate than those who do not (per cohort analysis). The current blank empty state provides no scaffolding for users who do not know where to start. The hypothesis is that a template gallery reduces the "blank page problem" -- the cognitive friction of starting from zero -- and increases the proportion of users who activate. The team will use this result to determine whether to invest further in a full template library or to focus activation efforts elsewhere.


Hypothesis

If new users see a template gallery (3 featured project templates with preview cards) on their first dashboard visit instead of a blank dashboard with a single CTA button,

then the 7-day first-project-creation activation rate will increase by at least 15% relative (from 22.0% to 25.3%),

because the template gallery reduces the cognitive overhead of starting from a blank state by providing concrete examples, lowers the perceived effort of setup, and activates a "completion" motivation when users see a partially-defined project structure they can adopt.

Hypothesis type: Optimization

Test directionality: Two-tailed (the template gallery could plausibly distract users or create choice paralysis, producing a negative result)


Variants

| Variant | Description | Implementation Notes |

|----------------|----------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|

| Control (A) | Current empty state: blank dashboard area with single "Create your first project" button (primary button, center-aligned, blue) | No changes required. Production state as of [date]. |

| Variant (B) | Template gallery empty state: header text "Start with a template or build from scratch," 3 template preview cards (Marketing Campaign, Product Roadmap, Sprint Planning), each card shows template name, 3-line description, and "Use this template" button. Below the gallery: "Or start from scratch" text link. | New component: <TemplateGallery />. Cards link to pre-populated project creation flow. "Start from scratch" link replicates current CTA behavior. |

Single variable changed: The empty state component on the new user dashboard (first visit only).

What is explicitly NOT changed: Navigation bar, top header, sidebar, account setup checklist (if present), onboarding tooltip sequence, email sequence, project creation flow after the user clicks any CTA, button color scheme, or any other dashboard element.


Metrics

| Type | Metric Name | Measurement Method | Baseline Value | Target / Threshold |

|-------------|-------------------------------------------|-----------------------------------------------------------------------------|----------------|------------------------------------------|

| PRIMARY | 7-day first-project-creation rate | % of new users (cohorted by signup date) who create >= 1 project within 7 days of first login | 22.0% | >= 25.3% (+15% relative / +3.3pp absolute) |

| Secondary | 3-day first-project-creation rate | % of cohort who create >= 1 project within 3 days | 14.5% (est.) | Directional increase |

| Secondary | Template adoption rate (Variant B only) | % of Variant B users who click "Use this template" (vs. "start from scratch") | N/A | Informational -- expected 40-60% |

| Secondary | Day-14 retention rate | % of cohort who log in at least once during days 8-14 | 31.0% (est.) | Directional increase |

| GUARDRAIL | Time-to-first-project (among activators) | Median minutes from first dashboard view to first project created | 8.2 min | Must not increase by more than 50% (threshold: 12.3 min) |

| GUARDRAIL | Dashboard page error rate | HTTP 5xx errors on dashboard page route | 0.3% | Must not exceed 1.0% |

| GUARDRAIL | 30-day trial-to-paid conversion rate | % of new trial users who convert to paid by day 30 | 11.5% | Must not decrease by more than 2pp (threshold: 9.5%) |


Sample Size and Duration Calculation

| Parameter | Value |

|-----------------------------------|------------------------------------------------------------|

| Baseline conversion rate | 22.0% (0.220) |

| Minimum detectable effect | 15% relative = 3.3 percentage points absolute |

| Expected variant rate | 25.3% (0.253) |

| Significance level (alpha) | 0.05 (two-tailed) |

| Statistical power | 0.80 |

| z_alpha/2 | 1.96 |

| z_beta | 0.842 |

| Required sample per variant | n = (1.96 + 0.842)^2 * (0.2200.780 + 0.2530.747) / (0.033)^2 = ~1,620 users |

| Total required sample | ~3,240 users |

| Daily eligible traffic | 800 new signups/day |

| Traffic allocation per variant | 50% = 400 new users/day per variant |

| Raw duration | 1,620 / 400 = 4.05 days (minimum sample) + 7-day metric window = 11 days minimum |

| Adjusted duration | 28 days (4 full weeks) -- extended to capture 4 full business cycles and the full 7-day metric observation window for the final cohort |

| Test start date | [Date] |

| First valid analysis date | Start date + 28 days |

Important duration note: Although the minimum sample size is reached in approximately 4 days of exposure, the primary metric (7-day first-project-creation rate) requires a 7-day observation window after each user's first visit. Users who are assigned on day 21 of the test will not have their 7-day window complete until day 28. Therefore, the minimum valid analysis date is day 28 regardless of when the sample target is reached.

Sample size calculation method: Two-proportion z-test (exact formula above).

Variance reduction: CUPED not applicable (new users have no pre-experiment behavioral data).


Traffic Allocation

| Setting | Value |

|--------------------------|----------------------------------------------------------------------|

| Allocation method | User ID hash: variant = SHA256(user_id + "EXP-2024-047") % 100 < 50 → Control; else Variant |

| Traffic split | 50% Control (A) / 50% Variant (B) |

| Sticky assignment | Yes -- assignment computed deterministically from user ID, stable across sessions |

| Ramp-up plan | Ramp: 10% variant (vs. 90% control) for first 48 hours post-launch while monitoring dashboard error rate and guardrail metrics. If error rate < 1% and no guardrail violations at 48h, ramp to 50/50. Data from ramp period (first 48h) excluded from final analysis. |

| Exclusions | Internal employees (email domain @[company].com), QA automation accounts (tagged in user table), users who signed up via SSO enterprise provisioning flow (different activation path), bot accounts (session duration < 5 seconds on first visit) |

| Mutual

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.