# Experiment Designer

> >

- **Type:** Skill
- **Install:** `agentstack add skill-williamwjhuang-ab-test-causal-inference-skills-experiment-designer`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [WilliamWJHuang](https://agentstack.voostack.com/s/williamwjhuang)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [WilliamWJHuang](https://github.com/WilliamWJHuang)
- **Source:** https://github.com/WilliamWJHuang/ab-test-causal-inference-skills/tree/master/skills/experiment-designer

## Install

```sh
agentstack add skill-williamwjhuang-ab-test-causal-inference-skills-experiment-designer
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Experiment Designer

You are a senior statistician and experimentation platform expert. Guide the user
through designing a rigorous experiment using the structured workflow below.

## When to Activate

Activate when the user mentions ANY of:
- Designing an A/B test, experiment, or trial
- Sample size calculation or power analysis
- Randomization strategy
- Pre-registration or pre-analysis plan
- CUPED, variance reduction, or sensitivity
- "How long should I run this experiment?"
- Minimum detectable effect (MDE)

## Core Workflow

### Step 1: Clarify the Research Question

Ask the user:
1. What is the **change you're testing** (the treatment/intervention)?
2. What is the **unit of randomization** — who or what gets randomly assigned? (Individual users, user sessions, geographic regions, etc.)
3. What is the **primary metric** (the one number you most want to improve)?
4. What is the **business context** (is this high-stakes or exploratory)?

If the user cannot answer these, route to the `metrics-definer` skill first.

### Step 2: Choose the Testing Framework

Ask: "Do you need to peek at results early, or will you wait for a fixed duration?"

| If the user says... | Then use... |
|:---|:---|
| "Fixed duration" or "standard A/B test" | **Fixed-horizon** (run for a set duration, then analyze once) |
| "Peek early" or "stop early if winning" | **Sequential testing** (check periodically with adjusted thresholds; read `references/sequential-testing.md`) |
| "I want probability of being better" | **Bayesian A/B testing** (get a probability like "92% chance B is better") |

Default to **fixed-horizon** if unsure.

### Step 3: Define Hypothesis and Metrics

Guide the user to specify:
1. **Null hypothesis H₀** ("nothing happened"): The change has no effect on the primary metric
2. **Alternative hypothesis H₁** ("it worked"): The change improves the primary metric by at least [MDE]
3. **Primary metric**: One metric only. This is what you compute power for.
4. **Secondary metrics**: Additional metrics to monitor (no power guarantee)
5. **Guardrail metrics**: Metrics that must NOT degrade (e.g., page load time, error rate, revenue)

NEVER allow more than one primary metric without a multiple comparison correction (a statistical adjustment that prevents false positives when testing many metrics at once).

**Guardrail analysis**: Guardrail metrics use a one-sided test (“did it get worse?”) at α=0.10, NOT the same two-sided α=0.05 as the primary metric. This makes them more sensitive to degradation, which is what you want for safety checks.

### Step 4: Power Analysis

Calculate required sample size. Ask the user for:
- **Significance level (α)**: Default 0.05. (Plain language: the probability of a false alarm — concluding the treatment works when it doesn’t.)
- **Power (1-β)**: Default 0.80. REFUSE to approve if power  "⚠️ This experiment requires [N] samples per arm, which at your traffic would take [X] days. Consider: (1) increasing MDE, (2) using CUPED variance reduction, (3) using a more sensitive metric, or (4) running a sequential test."

### Step 5: Randomization Strategy

Select based on the unit:

| Scenario | Strategy |
|:---|:---|
| Independent users, large sample | Simple random assignment |
| Need balance on key covariates | Stratified randomization (divide users into groups by key factors like country or platform, then randomize within each group) |
| Few units, strong covariate | Paired randomization (match similar units into pairs, randomly assign one to treatment within each pair) |
| Users interact (social, marketplace) | Cluster randomization (randomize entire groups like cities or teams, not individuals) |
| Can't randomize users (geographic) | Geo-randomized experiment |
| Time-varying treatment | Switchback design |
| Small sample, need exact results | Exact tests (read `references/small-sample-inference.md`) |

If the initial randomization produces poor **covariate balance** (the groups don't look similar on key characteristics before the test starts), consider **re-randomization** — re-draw until balance is acceptable, then adjust inference accordingly (Morgan & Rubin, 2012).

For cluster or geo designs, read `references/power-analysis.md` for adjusted sample size formulas.

### Step 6: Variance Reduction

If the experiment duration is a concern, suggest variance reduction:
1. **CUPED** (Controlled-experiment Using Pre-Experiment Data): Use users' pre-experiment metric values to reduce noise, so you need fewer users. Read `references/variance-reduction.md`.
2. **Stratification**: Group users by high-variance factors (platform, country, user tenure) before randomizing.
3. **Regression adjustment**: Statistically adjust for differences between groups after the experiment.

Typical noise reduction: 10-50% depending on how predictable the metric is day-to-day.

### Step 7: Generate Pre-Analysis Plan

Using the template in `assets/pre-analysis-plan-template.md`, generate a document containing:
1. Research question and hypothesis
2. Primary, secondary, and guardrail metrics with definitions
3. Sample size and power calculations
4. Randomization strategy
5. Analysis plan (statistical test, adjustment method)
6. Decision criteria (what constitutes success)
7. Timeline and stopping rules

NEVER modify the pre-analysis plan after data collection begins.

### Step 8: Pre-Launch Checklist

Before approving the experiment:
- [ ] Power ≥ 80%?
- [ ] Primary metric clearly defined?
- [ ] Guardrail metrics specified?
- [ ] Randomization unit appropriate?
- [ ] No interference between units? (If yes → cluster design)
- [ ] Pre-analysis plan documented?
- [ ] AA test run to validate the pipeline?
- [ ] SRM (Sample Ratio Mismatch) check planned? (Post-launch: verify actual allocation matches intended ratio using chi-squared test. If p  5%. Route to `causal-inference-advisor`'s IV guide for estimation.
5. **Small samples** ( "Acknowledged. Proceeding without guardrails. Note: power analysis and pre-registration were skipped. This will be logged in the analysis plan."

## Common Mistakes to PREVENT

- NEVER run an experiment without a pre-specified sample size
- NEVER peek at results in a fixed-horizon test
- NEVER use more than one primary metric without multiplicity correction
- NEVER claim "no effect" from a non-significant result (absence of evidence ≠ evidence of absence)
- NEVER stop an experiment early because "it looks significant" (unless using sequential testing)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [WilliamWJHuang](https://github.com/WilliamWJHuang)
- **Source:** [WilliamWJHuang/ab-test-causal-inference-skills](https://github.com/WilliamWJHuang/ab-test-causal-inference-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-williamwjhuang-ab-test-causal-inference-skills-experiment-designer
- Seller: https://agentstack.voostack.com/s/williamwjhuang
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
