experiment-design
Design scientific experiments including sample size calculation, randomization, control groups, blinding, and study protocols. Covers RCTs, quasi-experiments, factorial designs, A/B tests, survey design, and observational studies. Use when user asks to design an experiment, calculate sample size, plan a study, set up controls, or create a research protocol. Triggers on "design experiment", "sample size", "power analysis", "study design", "control group", "randomization", "A/B test", "factorial design", "survey design".
Best use case
experiment-design is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Design scientific experiments including sample size calculation, randomization, control groups, blinding, and study protocols. Covers RCTs, quasi-experiments, factorial designs, A/B tests, survey design, and observational studies. Use when user asks to design an experiment, calculate sample size, plan a study, set up controls, or create a research protocol. Triggers on "design experiment", "sample size", "power analysis", "study design", "control group", "randomization", "A/B test", "factorial design", "survey design".
Teams using experiment-design should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/experiment-design/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How experiment-design Compares
| Feature / Agent | experiment-design | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Design scientific experiments including sample size calculation, randomization, control groups, blinding, and study protocols. Covers RCTs, quasi-experiments, factorial designs, A/B tests, survey design, and observational studies. Use when user asks to design an experiment, calculate sample size, plan a study, set up controls, or create a research protocol. Triggers on "design experiment", "sample size", "power analysis", "study design", "control group", "randomization", "A/B test", "factorial design", "survey design".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Experiment Design
Scientific experiment planning, power analysis, and protocol development.
## Design Selection Guide
| Research Question | Recommended Design |
|---|---|
| Does X cause Y? | RCT (gold standard) |
| Does X cause Y? (can't randomize) | Quasi-experiment, natural experiment |
| How do factors interact? | Factorial design |
| Which version performs better? | A/B test |
| What is the prevalence/association? | Cross-sectional survey |
| How does outcome change over time? | Longitudinal / cohort study |
| What is the lived experience? | Qualitative (interviews, ethnography) |
| Does intervention work in practice? | Pragmatic trial |
## Power Analysis & Sample Size
```python
source /Users/zhangmingda/clawd/.venv/bin/activate
python3 << 'EOF'
from scipy import stats
import numpy as np
# --- Two-sample t-test ---
def sample_size_ttest(effect_size, alpha=0.05, power=0.80):
"""Cohen's d effect sizes: small=0.2, medium=0.5, large=0.8"""
from scipy.stats import norm
z_alpha = norm.ppf(1 - alpha/2)
z_beta = norm.ppf(power)
n = 2 * ((z_alpha + z_beta) / effect_size) ** 2
return int(np.ceil(n))
# --- Chi-square test ---
def sample_size_chi2(effect_size, alpha=0.05, power=0.80, df=1):
"""Cohen's w effect sizes: small=0.1, medium=0.3, large=0.5"""
from scipy.stats import norm, chi2
z_beta = norm.ppf(power)
z_alpha = norm.ppf(1 - alpha)
n = ((z_alpha + z_beta) / effect_size) ** 2
return int(np.ceil(n))
# --- Correlation ---
def sample_size_correlation(r, alpha=0.05, power=0.80):
from scipy.stats import norm
z_alpha = norm.ppf(1 - alpha/2)
z_beta = norm.ppf(power)
z_r = 0.5 * np.log((1+r)/(1-r)) # Fisher's z
n = ((z_alpha + z_beta) / z_r) ** 2 + 3
return int(np.ceil(n))
# Examples
print(f"t-test (d=0.5): n={sample_size_ttest(0.5)} per group")
print(f"t-test (d=0.3): n={sample_size_ttest(0.3)} per group")
print(f"Chi-square (w=0.3): n={sample_size_chi2(0.3)}")
print(f"Correlation (r=0.3): n={sample_size_correlation(0.3)}")
EOF
```
## Key Design Principles
### Controls
- **Positive control**: Known to produce effect (validates method works)
- **Negative control**: Known to produce no effect (validates baseline)
- **Placebo control**: Inert treatment (controls for expectation effects)
- **Active control**: Existing standard treatment (for superiority/non-inferiority)
### Randomization
- **Simple**: Coin flip / random number
- **Block**: Ensures equal groups per block
- **Stratified**: Randomize within strata (age, sex, severity)
- **Cluster**: Randomize groups, not individuals
### Blinding
- **Single-blind**: Participants don't know assignment
- **Double-blind**: Participants and researchers don't know
- **Triple-blind**: Participants, researchers, and analysts don't know
### Bias Mitigation
| Bias | Mitigation |
|------|-----------|
| Selection bias | Random sampling, clear inclusion criteria |
| Allocation bias | Random assignment, concealed allocation |
| Performance bias | Blinding, standardized protocols |
| Detection bias | Blinded outcome assessment |
| Attrition bias | ITT analysis, minimize dropout |
| Reporting bias | Pre-registration, analysis plan |
## Study Protocol Template
```markdown
# Study Protocol: [Title]
## 1. Background & Rationale
## 2. Objectives & Hypotheses
- Primary:
- Secondary:
## 3. Study Design
- Type: [RCT / quasi-experiment / observational / ...]
- Duration:
## 4. Participants
- Population:
- Inclusion criteria:
- Exclusion criteria:
- Sample size: N = [calculated], power = 0.80, α = 0.05
## 5. Intervention / Exposure
## 6. Outcome Measures
- Primary:
- Secondary:
## 7. Randomization & Blinding
## 8. Data Collection Procedures
## 9. Statistical Analysis Plan
- Primary analysis:
- Secondary analyses:
- Handling of missing data:
## 10. Ethical Considerations
- IRB/Ethics approval:
- Informed consent:
- Data privacy:
## 11. Timeline
## 12. Budget
```
## Pre-registration
Recommend pre-registration for confirmatory studies:
- **OSF**: osf.io (general)
- **ClinicalTrials.gov**: clinical trials
- **PROSPERO**: systematic reviews
- **AsPredicted**: aspredicted.org (quick)
## Tips
- Always justify sample size with power analysis
- Pre-register hypotheses and analysis plan
- Plan for 10-20% attrition in sample size calculation
- Document all deviations from protocol
- Consider pilot study for novel methodsRelated Skills
experimental-design
Design rigorous scientific experiments with power analysis and controls. Use when: user needs to plan an experiment, calculate sample sizes, or set up controls. NOT for: running experiments or analyzing collected data.
xurl
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
xlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.
writing
No description provided.
world-bank-data
World Bank Open Data API for development indicators. Use when: user asks about GDP, population, poverty, health, or education statistics by country. NOT for: real-time financial data or stock prices.
wikipedia-search
Search and fetch structured content from Wikipedia using the MediaWiki API for reliable, encyclopedic information
wikidata-knowledge
Query Wikidata for structured knowledge using SPARQL and entity search. Use when: (1) finding structured facts about entities (people, places, organizations), (2) querying relationships between entities, (3) cross-referencing external identifiers (Wikipedia, VIAF, GND, ORCID), (4) building knowledge graphs from linked data. NOT for: full-text article content (use Wikipedia API), scientific literature (use semantic-scholar), geospatial data (use OpenStreetMap).
weather
Get current weather and forecasts via wttr.in or Open-Meteo. Use when: user asks about weather, temperature, or forecasts for any location. NOT for: historical weather data, severe weather alerts, or detailed meteorological analysis. No API key needed.
wacli
Send WhatsApp messages to other people or search/sync WhatsApp history via the wacli CLI (not for normal user chats).
voice-call
Start voice calls via the OpenClaw voice-call plugin.
visualization
Create publication-quality scientific figures and plots using Python (matplotlib, seaborn, plotly). Supports bar charts, scatter plots, heatmaps, box plots, violin plots, survival curves, network graphs, and more. Use when user asks to plot data, create figures, make charts, visualize results, or generate publication-ready graphics. Triggers on "plot", "chart", "figure", "graph", "visualize", "heatmap", "scatter plot", "bar chart", "histogram".
video-frames
Extract frames or short clips from videos using ffmpeg.