Guide · Agent skill
How to use the Statistical Power & Sample Size agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The statistical-power skill lets an AI agent plan how many participants, samples or replicates a study needs, and check what effect size a fixed sample could detect. It is aimed at researchers writing grants, IRB protocols or pre-registrations, students learning how sample size, effect size, alpha and power relate, and analysts who need a minimum detectable effect or a power curve. After reading this guide you will know how to install the skill, how to ask for a power analysis in plain language, and what the skill needs and cannot do.
Quick start
- 1Download the ZIP. Download the statistical-power skill ZIP from this page.
- 2Install the skill. Unzip it into ~/.claude/skills/ or a project's .claude/skills/ folder, or upload the ZIP under Settings → Capabilities → Skills in the Claude apps.
- 3Set up Python. Create a separate environment with Python 3.12 or newer and install statsmodels, SciPy, NumPy, pandas and matplotlib.
- 4Ask in plain language. Describe the test, expected or meaningful effect size, alpha and desired power, for example 'how many per group for d = 0.5 at 80% power'.
- 5Check the effect size. Ask the agent where the effect size comes from and request a sensitivity range across plausible values.
- 6Review the output. Confirm the sample size, rechecked power after rounding and any saved power curve before using them in a protocol.
What is an agent skill and what does this one do?
An agent skill is a folder containing instructions (a SKILL.md file), reference notes and helper scripts that an AI agent can read and use when a request matches the skill's description. This skill is named statistical-power and covers the four quantities that are linked in any test: sample size, effect size, significance level (alpha) and power (1 minus beta).
When triggered, the agent can calculate sample size for a given effect size, find the minimum detectable effect (MDE) for a fixed sample, and produce power curves. It uses standard formulas for t-tests, ANOVA, proportions, correlations, chi-square and regression, and simulation (Monte Carlo) for complex designs such as logistic or Poisson regression, mixed models, cluster-randomized trials, survival models and interactions.
- Sample size for a planned study (a priori power analysis)
- Minimum detectable effect for a sample you already have planned
- Power curves for grant or protocol figures
- Sensitivity checks across a range of plausible effect sizes
How do you install the statistical-power skill?
Download the ZIP for the skill from this page. You can install it in one of two ways, depending on where you use your agent.
For Claude Code, unzip the download into your personal skills folder ~/.claude/skills/, or into a project's .claude/skills/ folder if you want the skill only for that project. For the Claude apps, upload the ZIP under Settings → Capabilities → Skills.
The helper scripts need Python 3.12 or newer. The source's tested setup used Python 3.13 with the packages below. The source suggests a separate environment for these, so it does not clash with other projects.
uv venv --python 3.13 .venv-power
uv pip install --python .venv-power/bin/python "statsmodels==0.15.0" "scipy==1.18.1" "numpy==2.5.3" "pandas==2.3.3" "matplotlib==3.11.2"
# Optional comparison / survival methods:
uv pip install --python .venv-power/bin/python "pingouin==0.7.0" "lifelines==0.30.3"What do you need before you start?
You need Python 3.12 or newer with statsmodels, SciPy, NumPy, pandas and matplotlib. pingouin (for comparison) and lifelines (for survival methods) are optional. Lifelines requires pandas below version 3, which the pinned versions above respect. On Windows, the Python path is .venv-power/Scripts/python.exe.
Package installation needs network access unless the packages are already cached. The calculations themselves run locally and need no API keys or accounts.
- Python 3.12 or newer (examples were tested on 3.13)
- statsmodels, SciPy, NumPy, pandas, matplotlib
- Optional: pingouin and lifelines
- No API keys or accounts
How do you trigger the skill with a natural request?
You do not need to name the skill. The agent matches your wording against the skill's description. Requests that mention an effect size, alpha or "80% power" without the words "power analysis" can also trigger it. Give the agent the details it needs: the test or design, the effect size you expect or consider meaningful, alpha, and the power you want.
The skill is not for laying out the study (randomization, blocking, factorial designs) and not for analysing data you have already collected. Those belong to other skills named in its description, experimental-design and statistical-analysis.
- "How many participants do I need to detect a Cohen's d of 0.5 with 80% power?"
- "What minimum detectable effect can I find with 30 per group?"
- "Make a power curve for my grant showing power against sample size."
- "I need to justify my sample size for the IRB protocol. Can you run a power analysis?"
- "Calculate the sample size for comparing two proportions, 0.40 vs 0.55."
What examples does the skill cover?
The skill's main helper, scripts/power.py, gives one consistent interface for common tests. The examples below show the calls the skill documents. For a two-sample test the result is n1, and n2 is ceil(ratio × n1). Power should be rechecked using the realized integer ratio.
Supported test values include t_ind (two independent means), t_paired and t_one, anova (one-way), two_proportions, one_proportion, correlation, chi2 and linear_regression.
- Two-group t-test: effect size 0.5, power 0.80, alpha 0.05 gives 64 in sample 1 with equal allocation
- Unequal allocation: a ratio of 3.0 for more controls than cases
- One-way ANOVA with 4 groups and Cohen's f of 0.25
- Two proportions of 0.40 vs 0.55, converted automatically to Cohen's h
- Power curve saved as an image for a grant figure
from power import sample_size, power, mde, power_curve
# How many per group to detect Cohen's d = 0.5, two-sided, 80% power?
sample_size(test="t_ind", effect_size=0.5, power=0.80, alpha=0.05)
# Fixed n=30/group: minimum detectable d at 80% power?
mde(test="t_ind", nobs1=30, power=0.80, alpha=0.05)
# Power curve for the grant figure
power_curve(test="t_ind", effect_size=0.5, n_range=range(10, 120, 5), save="power_curve.png")How should you choose the effect size?
The effect size is the input that matters most, and the skill is designed to push back on guessing it. In order of preference, the source suggests: first, the smallest effect of interest, meaning the smallest effect that would change a decision or matter clinically or scientifically; second, a pilot or prior-study estimate, with its uncertainty and selection bias taken into account; third, a convention such as Cohen's small, medium or large, used only as a last resort and stated as such.
Whatever you choose, the skill recommends a sensitivity analysis: report how the required sample size changes across a plausible range of effect sizes rather than a single number.
- Prefer the smallest effect size of interest
- Use pilot or prior estimates with uncertainty considered
- Use Cohen's conventions only as a last resort, and say so
- Report a range of required sample sizes, not one number
What about safety, scripts and network use?
The skill runs Python scripts on your machine, so review them before use if that matters to you. It does not use the network during calculations. Network access is only needed to install packages, unless they are already cached.
The skill also declines to report post-hoc (observed) power for finished studies. Power calculated from the effect you just estimated largely repeats the test's p-value and adds no independent evidence, so the skill suggests a sensitivity analysis or the confidence interval instead.
- Runs scripts: yes
- Uses network: no (except package installation)
- No API keys or accounts needed
- Observed post-hoc power is discouraged; use sensitivity analysis or confidence intervals
Tips for getting reliable results
Give the agent a justified effect size and say where it came from. Ask for the sensitivity range as well as the headline number. For mixed models, cluster trials or survival designs, expect simulation, and check that the simulated data-generating process matches your study. Keep the package versions and random seeds with the output so the result can be reproduced.
- State where the effect size came from
- Ask for a sensitivity range across effect sizes
- Use simulation when the design is complex and check its assumptions
- Record package versions and seeds with the output
- Check that the stated limits (precision, equivalence, noninferiority, sequential monitoring) are not what you need
What people use it for
- Calculating how many participants a two-group trial needs before recruitment in a grant application.
- Finding the minimum detectable effect for a pilot with a fixed number of samples per group.
- Producing a power curve figure for an IRB protocol or pre-registration.
- Planning sample size for a cluster-randomized trial or mixed model through simulation.
- Teaching students how changes in effect size, alpha and power affect required sample size.
Frequently asked questions
Is the statistical-power skill free to use?
The skill is published under the MIT licence, as stated on this page. It needs no API keys or accounts, but the Python packages it relies on must be installed, which requires network access unless they are cached.
What do I need to run the statistical-power skill?
You need Python 3.12 or newer, with statsmodels, SciPy, NumPy, pandas and matplotlib. Pingouin and lifelines are optional, for comparison and survival methods. The examples were tested on Python 3.13.
Where do I install the statistical-power skill?
Unzip the downloaded ZIP into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder. In the Claude apps, upload the ZIP under Settings → Capabilities → Skills.
Can the skill calculate observed power for a finished study?
No, it discourages it. Observed power from the estimated effect largely restates the p-value, so the skill recommends a sensitivity analysis or the confidence interval around the effect instead.
Does this skill analyse my data?
No. It plans sample sizes before data collection. For analysing data you have already collected, the description points to a separate statistical-analysis skill, and for study layout such as randomization or factorial designs it points to experimental-design.
What is the difference between this skill and a plain sample size calculator?
The skill can run standard closed-form calculations and also simulation-based power for complex designs such as mixed models, cluster-randomized trials and survival. It also pushes back on guessed effect sizes and suggests sensitivity analyses. It does not cover precision, equivalence, noninferiority or sequential-monitoring calculations, so those need other tools.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use this skill if you are a researcher, student or analyst who needs a justified sample size, a minimum detectable effect or a power curve for a planned study, and you can supply a credible effect size. Pick something else if you need to analyse collected data, plan randomization or factorial layouts, or calculate precision, equivalence, noninferiority or sequential-monitoring designs, which this skill does not cover.
Download the skill