Calculates survey sample size: how many responses are needed for a margin of error and confidence level, a power analysis to compare two groups (minimum detectable difference), NPS margins and comparisons, minimum subgroup sizes, MaxDiff and conjoint rules of thumb, invitations from a response rate, and how many interviews reach saturation. Use for "how many people do I need", "what's the margin of error on 150 responses", "is n=80 enough" or "is my sample big enough to be statistically significant".
Ships in research-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Answers "how many responses do I need" and "is the n I have enough", with the assumption behind every
number. All arithmetic is done by scripts/survey_sample_size.py
(Python 3.9+, standard library only). Run it; do not redo the math in the conversation.
Use when the user asks:
Do not use for:
nps-analysis); say so and name the test.maxdiff-design. A conjoint design is not
covered. This skill only sizes the sample for them.survey-from-decision; for interview guides, ai-interview-guide.open-ended-coding; this skill only checks saturation from its code counts.A skill named here may not be installed. If it is missing, say so, name the method the request needs, and do not stretch this skill to cover it.
Pick the mode from the request, fill everything else from the defaults, and state the defaults in the answer. Ask one question only when the mode's required input is missing and cannot be inferred.
| Mode | Needed | Defaults |
|---|---|---|
Percentage, margin of error (proportion) | target margin, or the n (and count) to check | margin 0.05 (pass it: the script needs --margin or --n), p 0.5, confidence 0.95, large population, design effect 1 |
Mean, margin of error (mean) | SD and margin in scale units | confidence 0.95. No default SD: take it from a pilot or an earlier wave; without one, size the top-2-box share with proportion instead |
Two groups (compare) | the two percentages (or a lift), or the difference in SDs (d) | alpha 0.05 two-sided, power 0.80, equal groups, one comparison, pooled variance, no continuity correction |
What an n supports (check) | n | p 0.5, confidence 0.95, alpha 0.05, power 0.80, large population |
Net Promoter Score (nps) | target margin or difference in NPS points as a proportion (0.05 = ±5 points), or an n | promoter and detractor shares from an earlier wave, else variance 0.67; confidence 0.95; for --diff: alpha 0.05 two-sided, power 0.80 |
Gap between two answers (gap) | the two shares of one single-select question, and n | confidence 0.95 |
Subgroups (subgroups) | each reported subgroup's share | minimum base 100 (200 for MaxDiff or conjoint), or a target margin |
Invitations (invites) | completes and response rate | incidence, completion rate, deliverability 1.0; removal rate 0. No default response rate |
MaxDiff (maxdiff) | number of items | 4 per set (3 for 6 or 7 items, as maxdiff-design), sets = 3K/k, 1 subgroup. If a design exists, pass its --per-set and --sets |
Conjoint (conjoint) | tasks, alternatives (not counting None), levels per attribute | main effects, 1 subgroup |
Interviews (interviews) | number of distinct segments | 1 fairly homogeneous group, narrow aim, goal "codes" |
Saturation (saturation) | new codes per interview, in order | base 4, run length 2, threshold 0.05 |
If the user gives no goal at all ("how many do I need?"), do not ask: answer with the proportion
defaults (±5 points, 95%) and --table, and say what would change the answer (subgroups, a comparison, a
small population). If they give only an n ("is 80 enough?"), run check.
Give proportions, not percentages, to the script (0.05, not 5).
When the result will be published as a margin of error, ask how respondents were selected unless it is
clear; meanwhile give the number under the stated assumption. For an opt-in sample (a panel such as
Prolific, an open link sent to the whole customer list, a social post) pass --opt-in: the statement then
reads as a simple-random-sample benchmark, not the precision of the actual sample. A random sample drawn
from a complete list is not opt-in (its non-response still is a caveat).
Name the claim the survey must support. One overall percentage or mean, a comparison between two groups or waves, results per subgroup, or a choice exercise. The strictest claim sets n. If several apply, run each and take the largest.
Run the matching subcommand with --json, by the script's path inside this skill's directory:
S="<skill-dir>/scripts/survey_sample_size.py"
python3 "$S" proportion --margin 0.05 --table --json # n for ±5 points, and n at other margins
python3 "$S" proportion --margin 0.05 --population 2000 --weight-cv 0.5 --json
python3 "$S" proportion --n 150 --json # margin of error on 150 responses
python3 "$S" proportion --n 400 --opt-in --json # opt-in panel: benchmark wording
python3 "$S" proportion --n 12 --x 3 --json # 3 of 12: Wilson interval, not a ± margin
python3 "$S" check --n 80 --share under35=0.3 over35=0.7 --json # is n=80 enough? what it supports
python3 "$S" mean --sd 1.1 --margin 0.2 --json
python3 "$S" compare --p1 0.50 --p2 0.60 --table --json # n per group; add --lift 0.2 instead of --p2
python3 "$S" compare --p1 0.50 --p2 0.60 --n 150 --json # power with 150 per group
python3 "$S" compare --p1 0.50 --n 150 --json # smallest detectable difference
python3 "$S" compare --p1 0.50 --p2 0.60 --ratio 2 --comparisons 3 --json # unequal groups, three comparisons
python3 "$S" compare --d 0.3 --json # two means, d = difference / SD
python3 "$S" compare --diff 0.4 --sd 1.2 --json # two means in scale units
python3 "$S" compare --p1 0.50 --p2 0.60 --n 120 --n2 300 --json # power with groups of 120 and 300
python3 "$S" gap --p1 0.42 --p2 0.37 --n 600 --json # A vs B in the same sample
python3 "$S" nps --promoters 0.4 --detractors 0.2 --margin 0.05 --table --json # ±5 NPS points; ±3/5/7/10 rows
python3 "$S" nps --diff 0.10 --table --json # n per group for a 10-point change; 5-20 point rows
python3 "$S" subgroups --share smb=0.5 mid=0.35 ent=0.15 --margin 0.10 --json # quota table
python3 "$S" invites --completes 667 --response-rate 0.12 --incidence 0.6 --completion-rate 0.85 --removal-rate 0.1 --json
python3 "$S" maxdiff --items 20 --per-set 4 --sets 15 --subgroups 2 --json
python3 "$S" conjoint --tasks 12 --alternatives 3 --levels 3,4,5 --json
python3 "$S" interviews --segments 3 --json # --method focus-groups, --goal meaning
python3 "$S" saturation --new-codes 14,9,6,5,3,2,1,0 --json # or --file codes.csv
python3 "$S" SUBCOMMAND --help lists every option; --opt-in, --population, --deff, --weight-cv
and --icc with --cluster-size go on any subcommand that takes them. Bad input exits with status 2 and a one-line
message; fix the input, do not work around it.
Adjust for the sample you will really get.
--population (finite population correction; also on
check). If everyone in it responded, the script reports a census with no sampling error.--weight-cv (coefficient of variation of the weights), or --deff if known.
Clustered sampling for a descriptive estimate (classes, stores, teams): --icc with
--cluster-size. Assigning whole clusters to the arms of an experiment is out of scope.subgroups with every reported subgroup's share and use its quota table.compare (with --ratio when the
groups differ in size); it usually asks for more than the minimum base.--comparisons m. Say that
the Bonferroni split is conservative.For "is n enough", run check, or the reverse form of the matching command (--n). Say what the n
supports: the margin of error, the smallest detectable difference, or the power for a difference the
user names. Answer yes or no against a stated need; if none is stated, give the numbers and let the
user judge. When the script prints a Wilson interval, quote the interval, never a ± figure. For a rare
outcome (under 10 expected in the smaller category) the planned n keeps the Wilson interval within the
target; the statement says so.
Turn completes into invitations with invites when the user recruits from a list. Use their own
past response and removal rates; if they have none, show two scenarios rather than inventing a rate.
MaxDiff and conjoint: report the result as a rule of thumb and name the source. MaxDiff: at least
300 respondents in total and 200 per subgroup reported, raised above 30 items (doubled at 60; the same
rule maxdiff-design and maxdiff-analysis use); for a sparse design (each item under 2 times per respondent) also 500 item
exposures per group, preferably 1000. Conjoint: 500 representations per level, 1000 preferred, and at
least 300 respondents (200 per compared subgroup). Those
500/1000 figures count exposures or representations, not respondents. For a high-stakes study
recommend simulating the design.
Interviews and focus groups: run interviews for the planning range and present it as guidance per
segment, not a requirement. During fieldwork run saturation on the count of new codes per interview
and report its statement (for example "6+2"). Never attach a margin of error or a percentage to
interview counts. The evidence behind the ranges:
| Source | Finding | Applies when |
|---|---|---|
| Hennink and Kaiser 2022 (review of 23 articles) | 9–17 interviews or 4–8 focus groups reached saturation | Homogeneous group, narrow aim |
| Guest, Bunce and Johnson 2006 | Saturation within 12 interviews; main themes visible by 6 | Homogeneous group, structured guide |
| Hennink, Kaiser and Marconi 2017 | 9 interviews to hear the range of issues; 16 to 24 to understand them | Depth of meaning is the goal |
| Guest, Namey and Chen 2020 | Base of 4, runs of 2, stop when a run adds ≤5% new codes over the base | Checking saturation during fieldwork |
Build the answer from the script's output: the headline result, its statement (paste it
unchanged as the rationale sentence), the assumptions, and a --table run for "what changes the
number" where the mode has one.
Say why rather than changing the answer: two-proportion formulas (pooled, unpooled, arcsine) differ by
about 1–2% near 0.5 and by more far from it, some A/B calculators use the baseline variance only and round to nearest (pass
--variance baseline to reproduce them), and some survey calculators use z rounded to two decimals.
The table of worked differences is in references/sources.md, "Why other
calculators give slightly different numbers".
Always this shape:
**Answer:** <n> <completes | per group | interviews per segment>, to <the claim it supports>.
<Other modes: "**Answer:** n = <n> gives <±margin | interval | power x%>" for a reverse run; "**Answer:**
saturation <reached at 6+2 | not reached after n interviews>" for saturation.>
| Question | Method | Key inputs | Result |
|---|---|---|---|
| <e.g. Overall percentage within ±5 points> | <subcommand and formula name> | <p, confidence, N, deff> | <n, rounded up> |
| <one row per calculation run> | | | |
**Rationale to paste:** <the script's `statement`, unchanged>
**Assumptions**
- <each assumption the script printed, including every default used>
**What changes the number**
<the script's `--table` rows, or two or three extra runs: other margins, differences, a design effect>
**Quotas / field plan** (if subgroups are reported or the user recruits from a list)
- <quota table rows: subgroup, expected n, margin>
- Invitations: <n> at <response rate>, <incidence>, <completion rate>, <removal rate>
**Caveats**
- <sampling caveat: random vs opt-in (with `--opt-in`, the benchmark wording); rule of thumb vs calculation; quota needed for subgroups>
Sources: <the sources the script printed>
For an "is n enough" question the Answer line reads: **Answer:** Yes | No: n = <n> gives <margin, interval or detectable difference>; <need> takes <n required>. With no stated need, drop "Yes | No" and give the
numbers.
compare used, not proportion?gap used?--population, and was it passed?--opt-in passed, and does the
answer call the margin a simple-random-sample benchmark rather than this sample's precision?nps used (not proportion), with the variance it assumed stated?--comparisons passed, and is the correction called conservative?To run this on QuestionPunk, connect its MCP server (https://app.questionpunk.com/api/v1, OAuth sign-in). Tools: prolific_count_participants (pool size for given screener ids, not a promise of completes), prolific_study_calc_cost (an estimated quote), responses_get_counts (completes so far; filter to completed, real responses and apply the quality exclusions before comparing with the target n). None creates a study. Ask the user before creating, changing or publishing anything. If a tool says a permission is missing, reconnect and approve the requested access.
LICENSE.txt (opens in a new tab)fixtures/README.md (opens in a new tab)fixtures/cases.json (opens in a new tab)fixtures/saturation_guest2020.csv (opens in a new tab)references/sources.md (opens in a new tab)scripts/survey_sample_size.py (opens in a new tab)tests/test_survey_sample_size.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/research-skills:survey-sample-sizefrom research-skills
research-skills@buildwithclaude is listed by davepoon/buildwithclaude — review the source before installing
npx claudepluginhub davepoon/buildwithclaude --plugin research-skills22 skills in this plugin
/ai-interview-guideTurns research goals or an existing discussion guide or interview script into a brief an AI moderator can run for customer or user research: goal, must-ask questions, probes and probe depth, skip rules, topics to avoid, a consent screen with AI disclosure and a short opener, length, and a paste-ready interviewer prompt, with leading questions rewritten. Use for "interview 30 customers", "async user interviews", "AI-moderated interviews", "write the prompt for my AI interviewer" or "run my discussion guide at scale"./conjoint-analysisAnalyzes choice-based conjoint results from a CSV of tasks and choices: an aggregate multinomial logit with respondent-clustered standard errors, part-worth utilities, attribute importances, willingness to pay when price is an attribute, AMCEs and marginal means for fully randomized designs, segment comparisons, and a share-of-preference simulator, with bootstrap intervals. Use for "analyze conjoint results", "part-worths", "attribute importance", "willingness to pay from conjoint", "market simulator" or a Sawtooth, Qualtrics or Conjointly CBC export. Not for individual-level HB utilities./conjoint-designDesigns a choice-based conjoint (CBC) study: attributes and levels that don't overlap, prohibited combinations, tasks, concepts per task and a none option, a randomized design with level balance and minimal overlap (or fully randomized for AMCEs) generated by script, checks of level frequency, attribute association and relative D-efficiency, and a sample size from the Johnson-Orme rule. Use for "conjoint study", "design a conjoint", "discrete choice experiment", "which feature bundle", "trade-off research", "CBC design", "how many conjoint tasks" or "check my conjoint design"./csat-ces-analysisComputes CSAT and Customer Effort Score (CES) from ratings or counts: the top-2-box share with a Wilson interval and the mean, CES on the 7-point agree or ease scale or the original 1-5 effort scale (lower is better), with the convention printed so numbers reconcile with Zendesk or Qualtrics; tests differences between agents, channels, segments or periods and against a target; and splits comments by satisfied, neutral and dissatisfied. Use for "calculate CSAT", "CSAT from this export", "customer effort score", "CES results", "is our CSAT drop significant" or post-ticket surveys./gabor-granger-analysisEstimates a demand curve and the revenue- or profit-maximizing price from Gabor-Granger purchase-likelihood answers: take rate at each tested price with confidence intervals, a monotonicity check per respondent, a monotone demand curve, arc price elasticity, revenue and profit curves with a bootstrap check on the optimal price, and optional user-supplied weights for stated-intent overclaim. Reads full, adaptive or monadic price ladders. Use for "Gabor-Granger", "price ladder results", "demand curve from survey", "revenue-maximizing price", "price test results" or "would you buy at $X" data./kano-analysisDesigns and analyzes Kano surveys: writes the functional and dysfunctional question pair for each feature, classifies every answer with Kano's evaluation table (attractive, one-dimensional, must-be, indifferent, reverse, questionable), assigns each feature its category with Fong's test for a clear winner, and computes Better/Worse coefficients with intervals for a quadrant chart. Use for "Kano model", "Kano survey", "Kano analysis", "which features are must-haves vs delighters", "feature prioritization survey" or "better worse coefficients".