agentleFS
WilliamWJHuangWilliamWJHuang/ab-test-causal-inference-skills/skills/experiment-designer/SKILL.md

experiment-designer

Skill4 starsChanged 7 months agoMITView on GitHub

Design statistically rigorous experiments including A/B tests, factorial designs, and quasi-experiments. Activate when the user wants to plan an experiment, calculate sample size, run power analysis, choose a randomization strategy, set up variance reduction (CUPED/CUPAC), or create a pre-analysis plan. Covers fixed-horizon, sequential testing, and Bayesian approaches.

14 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use launch-readiness and stakeholder-update.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • pratikshadakeSkill

    launch-readiness

    Audits whether a feature or product is truly ready for launch with a structured checklist and readiness status (Ready/At Risk/Not Ready). Use before any product launch to catch critical gaps.

    Also in 3 projects that use this

  • AnthropicSkill

    stakeholder-update

    Generate a stakeholder update tailored to audience and cadence. Use when writing a weekly or monthly status for leadership, announcing a launch, escalating a risk or blocker, or translating the same progress into exec-brief, engineering-detail, or customer-facing versions.

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

23 rules. 0 are common, 21 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 21

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

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

    line 72
  2. Distinctive:

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

    line 76
  3. Distinctive:

    Default to fixed-horizon if unsure.

    line 84
  4. Distinctive:

    NEVER allow more than one primary metric without a multiple comparison correction (a statistical adjustment that prevents false positives …

    line 95
  5. Distinctive:

    Significance level (α): Default 0.05. (Plain language: the probability of a false alarm — concluding the treatment works when it doesn’t.)

    line 102
  6. Distinctive:

    Power (1-β): Default 0.80. REFUSE to approve if power < 0.80.

    line 103
  7. Distinctive:

    If the user doesn't know the variance, suggest:

    line 107
  8. Distinctive:

    Use this as the baseline variance estimate

    line 110
  9. Distinctive:

    Power Guardrail: If the computed sample size exceeds available traffic for 90 days, WARN the user:

    line 114
  10. Distinctive:

    If the initial randomization produces poor covariate balance (the groups don't look similar on key characteristics before the test starts), …

    line 131
  11. Distinctive:

    If the experiment duration is a concern, suggest variance reduction:

    line 137
  12. Distinctive:

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

    line 155
  13. Distinctive:

    Before approving the experiment:

    line 159
  14. Distinctive:

    When a user has COMPLETED an experiment and needs to analyze results, follow this workflow:

    line 171
  15. Very specific:

    Network effects / interference: Read causal-inference-advisor/references/interference-networks.md.

    line 185
  16. Distinctive:

    Unequal allocation: When treatment is costly, use unequal splits (e.g., 90/10) — adjust power analysis accordingly

    line 189
  17. Distinctive:

    Quantile treatment effects: When the effect on the mean isn't the whole story — use quantile regression to estimate effects at different …

    line 190
  18. Distinctive:

    If the user says "skip checks" or "I know what I'm doing":

    line 194
  19. Distinctive:

    NEVER run an experiment without a pre-specified sample size

    line 199
  20. Distinctive:

    NEVER peek at results in a fixed-horizon test

    line 200
  21. Distinctive:

    NEVER use more than one primary metric without multiplicity correction

    line 201
  22. Distinctive:

    NEVER claim "no effect" from a non-significant result (absence of evidence ≠ evidence of absence)

    line 202
  23. Distinctive:

    NEVER stop an experiment early because "it looks significant" (unless using sequential testing)

    line 203

“Common” is measured: kept by at least 6 in 10 of the 13 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 < 0.80. (Plain language: the probability of detecting a real effect if one exists. 80% means 1-in-5 chance of missing a real improvement.)
  • Minimum Detectable Effect (MDE): The smallest improvement that would be worth implementing. (Plain language: if the new feature only improved clicks by 0.1%, would you care? Probably not. Pick the smallest change that’s big enough to matter.)
  • Baseline metric value and variance (how much the metric bounces around day to day): From historical data

If the user doesn't know the variance, suggest:

  1. Pull 4-8 weeks of historical data for the metric
  2. Compute the standard deviation
  3. Use this as the baseline variance estimate

For detailed formulas and implementation, read references/power-analysis.md.

Power Guardrail: If the computed sample size exceeds available traffic for 90 days, WARN the user:

"⚠️ 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:

ScenarioStrategy
Independent users, large sampleSimple random assignment
Need balance on key covariatesStratified randomization (divide users into groups by key factors like country or platform, then randomize within each group)
Few units, strong covariatePaired 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 treatmentSwitchback design
Small sample, need exact resultsExact 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 < 0.001, STOP — the randomization is broken.)

Post-Experiment Analysis

When a user has COMPLETED an experiment and needs to analyze results, follow this workflow:

  1. Run SRM check — verify actual allocation matches intended ratio. If SRM detected, STOP and investigate. Read references/rct-analysis.md.
  2. Check covariate balance — verify pre-treatment covariates are balanced.
  3. Choose estimator — simple comparison of group averages (Neyman) or adjusted comparison that accounts for other factors (Lin estimator). Read references/rct-analysis.md.
  4. Handle non-compliance — if users didn't receive their assigned treatment:
    • Report ITT (intention-to-treat: the effect of being assigned to treatment, whether or not they used it) as the primary result — it's always valid.
    • Report LATE (the effect specifically on people who actually used the feature, not just those assigned to it) as secondary if non-compliance > 5%. Route to causal-inference-advisor's IV guide for estimation.
  5. Small samples (<200 per arm) — use permutation tests or exact tests instead of t-tests. Read references/small-sample-inference.md.
  6. Report results using the template in references/rct-analysis.md.

Advanced Mode

For users who say "advanced" or mention complex scenarios:

  • Network effects / interference: Read causal-inference-advisor/references/interference-networks.md. Consider cluster randomization or switchback design.
  • Marketplace / two-sided: Recommend cluster randomization on supply or demand side
  • Long-run effects: Recommend holdout groups beyond the experiment window
  • Multiple treatments: Factorial design with interaction tests
  • Unequal allocation: When treatment is costly, use unequal splits (e.g., 90/10) — adjust power analysis accordingly
  • Quantile treatment effects: When the effect on the mean isn't the whole story — use quantile regression to estimate effects at different points of the distribution

Escape Hatch

If the user says "skip checks" or "I know what I'm doing":

"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)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.