What does "statistical significance" mean for AI experiments?

Running statistical significance on an AI experiment the same way you'd run it on a button color test is one of the most common ways teams end up drawing confident conclusions from noise.
The core problem is structural: traditional A/B testing assumes a fixed treatment, but AI models are probabilistic by design. Every LLM call is a sample from a distribution, not a deterministic output. That adds a second layer of variance on top of normal user behavior — and the statistical frameworks most teams use were never built to handle two noise sources at once.
This article is for engineers, PMs, and data teams who are running or planning AI experiments and want to understand why standard testing instincts break down. Whether you're testing a new prompt configuration, a different model version, or an LLM-powered feature, the same core issues apply. Here's what you'll learn:
- Why AI outputs are noisier than traditional feature tests — and what that means for sample sizes
- How to choose metrics that actually reflect user outcomes, not just model quality
- The validity traps that silently corrupt results: p-hacking, peeking, and multiple metrics
- Why statistical significance alone isn't enough, and how to define practical significance before your experiment runs
The article moves in order from the statistical foundations to the practical decisions you make when designing and interpreting AI experiments. Each section builds on the last, so if you're new to significance testing in this context, reading straight through will give you the clearest picture.
What statistical significance actually means (and why AI experiments make it harder)
If you've run A/B tests before, you've encountered the phrase "statistically significant" — probably as the threshold between "we can ship this" and "we need more data." But the concept is frequently misapplied even in traditional testing environments, and AI experiments introduce a structural complication that makes misapplication far more costly.
Before getting into what makes AI experiments different, it's worth being precise about what statistical significance actually means.
The core definition: p-values, null hypotheses, and the 0.05 threshold
Statistical significance is a measure used in hypothesis testing to determine whether observed results are unlikely to have occurred due to chance alone. The mechanism is the p-value: a number that answers a specific question — if there were truly no difference between your control and treatment, how likely would it be to see results this large just by chance? A p-value of 0.05 means there's only a 5% chance you'd see this result if nothing real were happening.
When the p-value falls below a predetermined threshold — conventionally 0.05 — you reject the null hypothesis, which is simply the assumption that there is no real effect between your control and treatment groups. That threshold acts as the gatekeeper between "this might be noise" and "this is probably real."
Two things are worth internalizing here. First, the 0.05 threshold is a convention, not a law of nature. It's a reasonable default that the field has coalesced around, but it carries no special mathematical authority.
Second — and this matters enormously for AI experiments — statistical significance only tells you whether an effect is real. It says nothing about whether that effect matters. As one practitioner put it on Hacker News: "Significance testing only tells you the probability that the measured difference is a 'good measurement'... Whether the measured difference is significant in the sense of 'meaningful' is a value judgement." A result can be statistically significant and practically irrelevant. Keeping those two questions separate is essential.
What traditional A/B tests assume about determinism
Standard A/B testing was designed around a specific noise structure. Once a user is assigned to a variation, their experience is fixed. A button is blue or it isn't. A headline reads one string or another. The treatment is deterministic — it doesn't change between exposures, across users, or over time.
This means the only meaningful source of variance in a traditional experiment is user behavior. People click or they don't. They convert or they don't. That behavioral variance is real and substantial, but it's bounded and well-understood.
The statistical framework — power analysis, minimum detectable effects, sample size calculations — was built to handle exactly this structure: one noise source, controlled through randomization and sufficient sample size.
How AI outputs break the determinism assumption
AI models, particularly large language models, are probabilistic by design. Temperature settings, sampling parameters, and model versioning mean that the same prompt from the same user in the same context can produce meaningfully different outputs across calls. The treatment is not fixed. It varies.
This introduces a second, independent source of variance that traditional A/B testing frameworks were never designed to accommodate. In a standard experiment, variance comes from users. In an AI experiment, variance comes from users and from the model's outputs. These two sources compound.
When you're measuring whether a new LLM configuration improves task completion rates, you're trying to detect a signal through two layers of noise simultaneously — the natural variation in how different users behave, and the natural variation in what the model produces for any given user.
This isn't a minor technical footnote. It's a structural difference that changes the statistical bar before you've written a single line of experiment configuration.
What compounded variance means for sample sizes
Variance and sample size are directly linked in hypothesis testing. When variance increases, you need more data to detect the same effect at the same confidence level. Another way to say the same thing: if your sample size is fixed, higher variance means only larger effects will show up as significant — smaller real improvements become invisible to the test.
That's what minimum detectable effect (MDE) means in practice: the smallest true difference between control and treatment that your experiment can reliably surface given your significance threshold and statistical power.
Teams that size AI experiments using the same calculators they use for button color tests will systematically underpower their studies. The calculator assumes one noise source. The experiment has two. The result is experiments that run to completion, show no significant effect, and get interpreted as "the AI feature doesn't work" — when the real problem is that the study was never adequately powered to detect the effect in the first place.
CUPED and post-stratification exist precisely to address this: by controlling for pre-experiment variance, they effectively shrink the noise floor and let experiments reach significance faster without requiring proportionally larger sample sizes.
The practical implication is straightforward: AI experiments require either larger samples, longer runtimes, tighter metric definitions, or variance reduction techniques — and ideally some combination of all four. Teams that don't account for this upfront will spend cycles on underpowered experiments and draw conclusions from noise.
Why AI outputs are noisier than traditional feature tests
When you run an A/B test on a button color, every user in the treatment group sees the same button. The only variance in your results comes from differences in how users respond. That's one source of noise, and it's the source that classical statistical frameworks were built to handle.
AI experiments introduce a second source of noise that sits upstream of the user entirely — the model output itself — and when these two sources compound, the sample sizes and run times that feel adequate for traditional tests become systematically insufficient.
Output stochasticity: the noise layer that doesn't exist in button tests
In a deterministic feature test, "treatment" means something precise: every user in the treatment group received the same intervention. In an LLM-powered feature, treatment group members don't share a common experience — they share a distribution of experiences. The model produces different outputs for different users, and often different outputs for the same user on repeated queries.
This means you're not measuring the effect of a feature; you're measuring the average effect of a range of outputs, some of which may be helpful, some neutral, some actively counterproductive. That output-level variance sits on top of normal user-level behavioral variance, and the two sources multiply rather than average out.
Delayed user outcomes and the learning curve problem
The METR study on AI-assisted developer productivity illustrates this failure mode with unusual clarity. In a controlled within-subject design — where the same 16 experienced open-source developers alternated between AI-assisted and non-AI-assisted tasks — developers perceived a 20–24% speedup from using Cursor. Controlled measurements showed actual slowdowns. Three-quarters of participants saw reduced performance; only one quarter improved.
Notably, the one developer with more than 50 hours of prior Cursor experience was among the top performers, suggesting that AI tool benefits, if they exist, accrue over time as users climb a steep learning curve. This creates a specific measurement problem: the costs of an AI feature (slower task completion during the adaptation phase) are immediate and show up cleanly in your experiment window, while the benefits may only materialize weeks later as users internalize new workflows.
As Simon Willison noted in discussing the study, "getting a significant productivity boost from LLM assistance and AI tools has a much steeper learning curve than most people expect." A short experiment window captures the noisiest, least representative phase of user behavior — which is exactly when most teams are measuring.
Metric attribution lag: when the outcome you care about happens later
Even setting aside the learning curve, there's a separate problem with causal chain length. A coding assistant might improve output quality in ways that only surface in code review rates or production bug counts weeks after the experiment closes. A customer support AI might reduce churn in ways that take a full billing cycle to register.
This isn't the same as the learning curve problem — it's about the distance between the AI's output and the business outcome you actually care about. The longer that causal chain, the more opportunity there is for confounding variables to enter the measurement, and the less your experiment window reflects the true steady-state effect.
How these three sources interact to inflate required sample sizes
Each of these noise sources — output stochasticity, user adaptation lag, and metric attribution lag — independently increases within-group variance. When they operate simultaneously, the effect on required sample sizes is compounding. Higher variance raises the MDE threshold, which means you need proportionally larger samples to achieve the same statistical power at the same confidence level.
A sample size calculation done using traditional A/B test variance assumptions will underpower an AI experiment, often by a significant margin.
The practical corrective is to treat variance reduction as a first-class concern in AI experiment design. Techniques like CUPED — which controls for pre-experiment covariates like prior tool experience, exactly the confound the METR study identified — and post-stratification can meaningfully reduce the sample sizes required to reach significance. That's not a complete solution to AI-specific noise, but it's a concrete lever that teams can pull while they work on the harder problems of metric selection and experiment duration.
Eval scores measure the model; these metrics measure whether users are better off
Accounting for AI-specific variance gets you to a valid experiment. Choosing metrics that actually reflect user outcomes means you're measuring the wrong thing with statistical rigor — which is its own kind of failure. Metric selection is the single highest-leverage decision you make in an AI experiment.
Get it wrong and you'll either miss a genuinely effective feature or declare a win on something that doesn't move the needle for users. This problem is more acute in AI experiments than in traditional A/B tests precisely because the outputs are probabilistic and the outcomes you care about are often delayed — which means the gap between what you can easily measure and what you should measure is unusually wide.
The hierarchy: downstream behavioral outcomes over model scores
The temptation in AI experiments is to reach for metrics that are close to the model: eval scores, BLEU scores, accuracy benchmarks, response quality ratings. These are measurable, fast to compute, and feel rigorous. The problem is they answer the wrong question. Evals tell you whether the model is better. A/B tests should tell you whether users are better off — and those two things frequently diverge.
The right hierarchy puts downstream behavioral metrics at the top: retention rate, task completion rate, session depth, revenue per user. These are the outcomes that reflect whether the AI feature is actually delivering value. Intermediate model-quality scores can serve as guardrails — useful for catching regressions — but they shouldn't be your primary success metric.
Landon Smith, Head of Post-Training at Character.AI, put it directly: the goal is to compare modeling techniques "from the perspective of our users," guiding research in the direction that best serves the product, not the benchmark.
The North Star Metric framework is a useful anchor here. A well-chosen NSM reflects the core value delivered to users, predicts long-term revenue, and is actionable by the team. Spotify's "time spent listening" is the canonical example — it captures engagement in a way that model-quality scores never could.
Where AI metric design goes wrong
Three failure modes show up repeatedly in AI experiments. The first is measuring model outputs instead of user outcomes — the "vibe check" problem. A model that scores higher on internal evals may not improve task completion at all, and treating eval improvement as a proxy for user value is where many teams go wrong.
The second failure mode is choosing metrics with very low base rates. A metric that converts at 0.5% requires an enormous sample to detect a meaningful effect. The Minimum Detectable Effect (MDE) framework makes this concrete: if the expected effect size is smaller than the MDE given your sample size and significance threshold, the test cannot surface a real difference even if one exists. Low-baseline proxies don't just require more data — they often make experiments practically infeasible.
The third failure mode is metric proliferation. Adding model-quality metrics alongside behavioral metrics feels thorough, but it inflates your false positive rate in ways that compound quickly. With five unrelated metrics evaluated at a 0.05 significance threshold, the probability of at least one false positive reaches 41%. With two metrics, it's still 19%.
The practitioner community has flagged this as one of the most common misuses of significance testing in industry — and AI experiments, with their natural temptation to track both model and user metrics simultaneously, are especially vulnerable.
Variance reduction as a practical lever
Even with the right metrics, AI experiments tend to have high within-group variance — which means longer runtimes and larger required sample sizes. Variance reduction techniques are the practical response to this problem. They don't fix bad metric selection, but they make good metric selection more efficient.
CUPED works by using data you already have about users before the experiment starts — things like their prior usage frequency, historical purchase rate, or tenure — to filter out variance that has nothing to do with the treatment. If heavy users always convert at higher rates regardless of what you test, CUPED controls for that, leaving a cleaner signal. Post-stratification achieves a related reduction through stratified analysis after the fact.
GrowthBook's experimentation platform includes both natively, and post-stratification has been shown to run experiments approximately 20% faster — a meaningful gain when you're waiting on downstream behavioral metrics that take days or weeks to accumulate.
Sequential testing is the third tool worth understanding here. When downstream behavioral metrics take time to mature, teams face pressure to peek at results early. Sequential testing methods allow continuous monitoring without inflating false positive rates — which is particularly relevant when your primary metric is something like 30-day retention rather than an immediate click.
The underlying principle across all three techniques is the same: reduce the noise in your measurement so the signal from a real effect can emerge faster. None of them substitute for choosing a metric that reflects actual user outcomes in the first place.
P-hacking, peeking, and multiple metrics: the validity traps that undermine AI experiment results
Even when you've chosen the right metrics and accounted for AI-specific noise, your experiment results can still be meaningless — not because of bad data, but because of how you ran the test. The validity threats in this section aren't exotic edge cases.
They're the default behavior of fast-moving product teams under pressure to ship, and they're especially dangerous in AI experiments where iteration cycles are fast and the temptation to keep tweaking until something works is structurally baked into the workflow.
Every metric you add compounds your false positive rate
Every time you add a metric to an experiment and evaluate it at a 0.05 significance threshold, you're not just measuring one more thing — you're compounding your family-wise error rate. GrowthBook's documentation puts this plainly: if you test the same hypothesis across 20 different metrics at the 5% significance level, the probability of finding at least one statistically significant result by chance alone climbs to around 64%. That's not a failure of execution. That's arithmetic.
The five-metric version of this problem is less dramatic but more common. Testing five independent metrics at α = 0.05 yields a false positive probability of roughly 22.6%. The math: each metric has a 95% chance of not producing a false positive (that's what 0.05 significance means). For five independent metrics, the chance that all five avoid a false positive is 0.95 × 0.95 × 0.95 × 0.95 × 0.95, or about 77%. Which means the chance that at least one produces a false positive is the remaining 23%.
And that calculation assumes the metrics are independent, which they almost never are. Page views correlate with funnel starts. Session length correlates with engagement scores. When metrics move together, the theoretical false positive rate becomes an approximation rather than a ceiling.
The practical implication: teams that track ten guardrail metrics plus three primary metrics without applying any correction aren't running a rigorous experiment. They're running a lottery.
P-hacking in AI prompt and model iteration
AI experiments create a specific p-hacking loop that traditional A/B testing rarely encounters. When you're testing a button color, there's one button. When you're testing a prompt configuration, there are hundreds of plausible variants — different phrasings, different context windows, different temperature settings — and the natural workflow is to iterate until something looks good, then declare a winner.
GrowthBook's documentation names the underlying fallacy directly: the Texas Sharpshooter Fallacy, where a marksman shoots at a barn and then paints the target around the bullet holes. Testing many prompt variants and retroactively identifying the "significant" one is structurally identical. The target was drawn after the shooting.
What makes this insidious is that it doesn't require bad intent. GrowthBook's documentation notes that p-hacking occurs "either consciously or unconsciously" — analysts exploring different subgroups or time windows until something surfaces. In AI development, where prompt iteration is a legitimate engineering practice, the line between exploration and data dredging is easy to cross without noticing.
The fix is procedural: specify the exact prompt or model configuration being tested before running the experiment, not after reviewing preliminary results.
The peeking problem and sequential testing
Peeking — checking results before the pre-specified sample size is reached and stopping early when significance appears — is one of the most common ways experiments get invalidated. It inflates Type I error rates because the probability of crossing the significance threshold at least once during an experiment is higher than the probability of crossing it at the planned endpoint. Stop early enough times on enough experiments, and your 5% false positive rate quietly becomes something much larger.
AI experiments are particularly vulnerable here because delayed outcome metrics create pressure to look early. If your primary metric is 30-day retention, waiting for full data collection feels costly. The temptation to check at day 10 and ship if things look promising is real.
Sequential testing is the technical solution. It allows valid inference at any interim look by adjusting the significance threshold dynamically — so you can check results mid-experiment without inflating your error rate. Within GrowthBook, sequential testing is available as part of the core experiment workflow, which means teams don't need to implement the math themselves.
Correction methods and the A/A baseline
For teams running multiple metrics, two correction approaches are worth knowing. Bonferroni correction divides the significance threshold by the number of tests (α/n), making it the most conservative option — appropriate when any false positive is costly.
Benjamini-Hochberg takes a different approach: instead of asking "what's the chance of any false positive at all?" (which Bonferroni answers), it asks "among the results I'm calling significant, what fraction are probably false positives?" That's a more useful question when you're tracking many metrics — it's less likely to dismiss real effects as noise, at the cost of accepting that some small fraction of your "significant" results may not be real. GrowthBook's experimentation platform includes both correction methods natively.
Before running any high-stakes AI experiment, an A/A test — where both variants receive identical treatment — serves as a calibration check on your measurement infrastructure. A healthy A/A test will occasionally surface a single metric as significant due to the inherent 5% false positive rate; that's expected.
What signals a broken setup is three or four metrics simultaneously showing 99%+ or sub-1% probability to win. That pattern indicates a tracking problem, a randomization failure, or a data pipeline issue — and it's far better to discover this before your experiment than after.
The broader context here matters: industry estimates suggest roughly one in three experiments produces a genuine improvement — though the exact figure varies by domain and team maturity. When your baseline success rate is that low, inflating false positive rates through multiple testing, peeking, or prompt-iteration p-hacking doesn't just distort individual results — it systematically corrupts your team's ability to learn what actually works.
Statistical significance is not enough: why practical significance matters more in AI tests
There are two questions at the heart of every experiment, and they are not the same question. The first: Is this result real? The second: Does this result matter? Statistical significance answers the first. It tells you whether the effect you observed is likely to be genuine rather than a product of random variation. It says nothing — nothing at all — about whether that effect is large enough, valuable enough, or meaningful enough to act on.
"Statistical significance helps establish whether a result is reliable, while practical significance helps determine whether it is worth acting on." These are sequential questions, not interchangeable ones. Passing the first does not mean passing the second.
This distinction is widely misunderstood. A Hacker News commenter who works in industry described it as "one of the most common fallacies I observe in industry and a lot of science" — the tendency to read "statistically significant" as synonymous with "notable" or "meaningful." It isn't.
And for AI experiments specifically, where shipping a new model version or prompt configuration carries real costs in inference, latency, maintenance burden, and regression risk, conflating the two questions is an expensive mistake.
The scale problem: when statistical significance becomes automatic
The mathematical relationship between sample size and p-values creates a trap that's easy to miss. As your user base grows, even vanishingly small effects produce very low p-values. At the volumes typical of AI product deployments — millions of sessions — almost any difference between variants will clear the p < 0.05 threshold.
One Hacker News commenter illustrated this directly: "This intervention causes an uplift in [metric] with p<0.001. High statistical significance! The uplift: 0.000001%. Meaningful? Probably not."
This isn't a hypothetical edge case. It's the operating reality for teams running AI experiments at scale. The probabilistic output layer of AI systems means there are always some measurable differences between variants. The question is never whether a difference exists — at sufficient scale, you will always find one. The question is whether the difference is large enough to justify the cost and risk of shipping.
Consider the NN/g example: Design A has an 85.0% checkout completion rate; Design B has 85.2%. A test returns p < 0.05 — statistically significant. But a 0.2 percentage point difference is almost certainly not worth acting on. The result is real. It is not worth shipping for.
Define your MDE before the experiment runs, not after
The practical solution is to define your minimum detectable effect — the smallest improvement that would actually change a business decision — before the experiment launches. Not after you see the results. After you see the results, you're rationalizing.
GrowthBook's documentation defines MDE as the minimum difference between control and treatment that can be detected given a specific significance threshold, statistical power, and sample size. The critical discipline is ensuring that the effect size you expect to see exceeds the MDE you've defined as meaningful. If a 0.2% improvement in task completion wouldn't change whether you ship the feature, don't declare victory when you detect it.
Define the threshold that would change the decision, and treat anything below it as a null result regardless of p-value.
For AI features specifically, this bar needs to reflect the full cost of shipping. A new model version isn't free — it carries inference cost, latency implications, and the ongoing maintenance burden of supporting a more complex system. The practical significance threshold should be calibrated against those costs, not just the upside metric.
If a 1% improvement in retention doesn't cover the cost of running a heavier model, then 1% is not a meaningful win. Define that threshold upfront, write it into your experiment plan, and hold to it when results come in.
Experiment platforms that build MDE into experiment design and track cumulative impact across experiments do so precisely because individual p-values don't tell the full story. A single experiment might show a statistically significant but tiny effect; the question of whether that effect compounds into meaningful business outcomes requires a different lens entirely.
The mindset shift is this: statistical significance is a filter for noise, not a mandate to ship. It tells you the signal is real. You still have to decide if the signal is worth acting on — and that decision should be made before you ever look at the data.
Where AI experiments break down: setup, execution, and interpretation
The through-line of this article is simple, even if the mechanics aren't: AI experiments fail not because teams are careless, but because they apply frameworks built for one noise source to problems with two. Output stochasticity, user adaptation lag, and metric attribution lag compound in ways that make traditional sample size intuitions unreliable, traditional metric choices misleading, and traditional result interpretation actively dangerous.
The fix isn't exotic — it's disciplined setup before the experiment runs and honest interpretation after it closes.
Lock in your metric and MDE before a single user is bucketed
The most consequential decisions in an AI experiment happen before a single user is bucketed. Lock in your primary metric — a downstream behavioral outcome, not an eval score — and define the minimum effect size that would actually change your shipping decision, factoring in the real costs of the new model or configuration.
If you can't articulate what "meaningful" looks like before you see data, you're not running an experiment; you're running a search for confirmation.
Mid-experiment discipline: peeking, metric proliferation, and variance control
Resist the pull to check results early, especially when your primary metric takes weeks to mature. If you need to monitor mid-experiment, use sequential testing — it's built for this. Keep your metric count tight, apply Bonferroni or Benjamini-Hochberg correction if you're tracking multiple outcomes, and treat guardrail metrics as guardrails, not additional success criteria.
GrowthBook ships sequential testing and both correction methods natively, so the infrastructure isn't the barrier — discipline is.
A significant result is not a mandate to ship
A p-value below 0.05 tells you the effect is probably real. It does not tell you the effect is worth acting on. Ask both questions in sequence: Is this result real? And is it large enough to justify the cost of shipping? If the detected effect sits below the MDE threshold you defined before the experiment, treat it as a null result regardless of what the p-value says. That threshold exists precisely so you don't rationalize small wins into shipping decisions.
The honest truth is that most AI experiments — like most experiments generally — won't produce a clear win. That's not failure. That's how you build a reliable signal over time instead of a catalog of confident mistakes. This article was written to give you a clear picture of where AI experimentation actually breaks down, and what to do about it. If even one section changes how you design your next experiment, it's done its job.
The highest-leverage move depends on where you are in the process
Where are you in the process?
About to launch an AI experiment: Write down your primary metric and your MDE threshold before you configure anything else. If you cannot articulate what "meaningful" looks like before seeing data, stop and define it now. Those two decisions will determine whether your results are interpretable.
Already ran an experiment and unsure whether to trust results: Check two things: (1) Did you define your success criteria before or after you saw the data? (2) Did you apply any correction for multiple metrics? If the answer to either is "after" or "no," your result may not be trustworthy regardless of the p-value.
Earlier in the process, not yet running experiments: Run an A/A test on your measurement infrastructure before anything else. A broken tracking setup invalidates every experiment downstream — and it's far cheaper to find that out now than after you've drawn conclusions from corrupted data.
Related insights
- A/B testing in the age of AI: evolution or revolution?
- How Fanatics Made Experimentation a Strategic Growth ...
- How to A/B Test AI: A Practical Guide
Related Articles
A magazine's home page shows two recent issues. The design team wants subscribers to try a shelf with four. All four covers are public, and changing editions while the page is open should update the shelf immediately. That gives you a small React feature with a useful acceptance test. Click from guest to subscriber and back, and count the covers each time.
We'll put the display limit in a typed local flag, evaluate it inside a React component, and leave the choice of edition with the app. The example runs in a client-rendered React app without a GrowthBook account, an SDK key, or a request for flag rules. For the wider workflow, free feature flags for coding agents explains what to ask an agent to implement and how to review the result.
Define what one flag controls
Start with an existing React and TypeScript app, or create a Vite React project for the example. Install both GrowthBook packages so the definitions and the hooks resolve against compatible SDK versions.
Create src/flags.ts. Here the feature value is a number, which lets the component use the same rendering code for either edition. A future change from four covers to three is one edit to the rule.
A guest falls through to the default of two. A subscriber matches the rule and gets four. This rule applies to every subscriber, so the ID has no effect on the result here. If you later roll the shelf out to a percentage of subscribers, you already have an identity to use for repeatable assignment.
The type registration release note explains the version requirement for LocalFeatures. The registration connects the definition, the attributes, and the value returned by the hook. For the TypeScript mechanics, see Jeremy Dorn's Register pattern walkthrough.
Put the current reader above the shelf
Replace src/App.tsx with the component below. The edition switch is a local fixture so anyone reviewing the change can reproduce both states. In an existing app, take those two values from the active reader in your session layer.
The provider receives an instance initialized with the current reader and the checked-in rules. React can render the correct shelf on the first pass for that reader. If the app is still loading a session, decide what should occupy the shelf in the meantime. For this public list a two-cover guest view is reasonable. On a page where a switch would interrupt the reader, wait for the session before mounting the shelf.
Give your agent the React setup
Use the local flags guide to ask for a typed definition, a provider with the current reader, and a test that changes the edition.
Open the Agent GuideThe useMemo dependencies include the ID and the edition. If a reader subscribes while signed in, their ID can stay the same while their edition changes. Depending only on the ID would leave the old SDK instance in place. Passing a fresh object as the dependency on every render would create unnecessary instances. The example uses the two primitive values the rule setup actually needs.
Read the numeric flag where React renders the list
Create src/IssueShelf.tsx. Keep one stable ID per issue and let the component use the resolved value to select how many items to render.
Keep the hook at the top of the component, inside the provider's subtree. The React SDK supplies the flag value through that provider. Calling a hook inside a click handler or inside the list loop would break the Rules of Hooks. Use the returned number in ordinary render logic.
There are two places you can see the number two in this implementation. The definition's defaultValue is what an ordinary guest gets through evaluation. The 2 passed to the hook is a fallback for a value the SDK can't supply. Giving them the same value makes the basic shelf a sensible fallback, but checking only the guest case would let a broken provider arrangement or missing definition go unnoticed. The subscriber case proves that the component actually received the rule.
The list keys identify magazine issues. Keep those keys independent of the flag. Switching from two covers to four should preserve the identity of the first two rows. There's also no need to remount the whole app with an edition-specific key. React preserves state according to component position and keys. For example, a search input outside the shelf shouldn't lose its text because someone subscribed.
Check the transition in both directions
Use the template's build script to type-check and bundle the app. Once that passes, start the dev server and open the local address it prints.
On first load, the page says guest and lists November and October. Click Switch edition. The same page should say subscriber and add September and August. Click again. The list should return to the original two issues, in order. This last check catches code that appends more results on upgrade and never removes them on downgrade.
For a compile-time check, temporarily replace the numeric fallback with the string "2". Run the build again and inspect the error on the hook call. Then restore 2 and rebuild. If the string compiles, check that src/flags.ts belongs to the same TypeScript project as the component and that the package manager resolved compatible core and React versions.
Look for the core package used by your app and by the wrapper. If the app has several incompatible installations, align the versions before diagnosing the JSX. A team using an existing build script should also confirm it actually runs the TypeScript checker.
Hand off a React change someone can review
Give your coding agent the one-shot local feature flags guide and a short description of the observable behavior. For this shelf, the request can be as specific as the test.
The shelf controls how many public titles to display. If your actual feature unlocks paid articles, enforce access when the server serves an article. A client-rendered flag only decides what to show in that browser. Whenever a change to the display limit can wait for a deployment, the small local file keeps the decision reviewable alongside the component. When an editor needs to change it between issues without an engineering release, compare the free GrowthBook options for managing flag rules.
Manage the shelf in GrowthBook
Start a GrowthBook workspace when your magazine team is ready to manage shelf rules between deployments.
Get Started with GrowthBookTwo customers download the same weekly report. One has agreed to preview a new CSV column. The other feeds the old two-column format into an importer. Both requests can land on the same Node.js process, and each needs the right file even if the other request arrives while the report is loading.
This tutorial builds that endpoint with one checked-in feature flag. The process loads the rules once. Each request supplies its own workspace attributes and receives its own evaluation. You can run the whole example on your machine without an account, a client key, or a flag server. The free feature flags for coding agents walkthrough introduces the local approach. Here we'll give the agent a server-specific test to pass.
Set up a small TypeScript service
Use Node.js 22 or newer for this example. In an empty directory, create an npm project that uses ES modules, install the core SDK, and add the TypeScript tools.
Create tsconfig.json at the project root. The sample runs TypeScript directly with tsx and checks types in a separate step. Type checking with tsx explains why the two commands serve different purposes.
The following files all live next to that configuration. The server imports ./flags.js even though the source file is flags.ts. That spelling follows TypeScript's Node.js module resolution for ESM and works with this runner.
Define the report contract in one flag
Create flags.ts. The public format has two columns. The sample preview workspace gets one additional column. The only targeting attribute the rule needs today is reportPreview. Carry the workspace ID too, so two people downloading a report on behalf of the same workspace can share an assignment if you introduce a percentage rollout later.
The SDK type registration update covers this rule syntax and the 2.2.0 minimum. If you misspell reportPreview in a condition or use a string where the boolean flag expects a value, TypeScript can point at the definition. The Register pattern also makes the same feature name available in other modules without threading a generic type through each handler.
Before you add the endpoint, decide what belongs to the process and what belongs to the request. The feature definitions are identical for both customers. Their identity and preview enrollment can differ. If a handler changes an attribute on a single shared user instance before awaiting a database query, another handler could replace that attribute before the first handler resumes.
Give your agent a server-side task
Use the one-shot guide to add checked-in rules. Ask your agent to keep workspace attributes local to each request and demonstrate both CSV formats.
Open the Local Flags GuideCreate a scope when the request arrives
Create server.ts. The Node.js SDK provides GrowthBookClient for the process and createScopedInstance for the current request. The two fixture paths below stand in for two authenticated workspaces. The server binds to the loopback address so you can exercise it locally.
The HTTP handler looks up a workspace, creates its scope, and holds that scope across an asynchronous operation. The short promise-based timer gives a second request time to arrive. In a real export, that's where the database or storage read would happen. Keep the stable client at module scope and the scoped instance inside the handler. If a formatter needs the decision, pass it the boolean or the scoped instance.
In production, resolve the workspace and its access rights from the authenticated session before reading the report. The two selectable paths here are fixtures for public sample data. A caller's choice of a header, query string, or workspace slug can't establish permission to read another customer's report. The endpoint also prevents shared response caching. If you cache real exports, the cache needs to distinguish the workspace and the report format, along with any other inputs that change the response.
Test two requests that overlap
In the first terminal, type-check the service and start it. A successful type check exits quietly. The next command prints the loopback address and keeps the server running.
Save the following as verify.mjs. In a second terminal, run node verify.mjs. Node's built-in fetch calls the local server. Strict assertions compare the full header and data row, including where each row ends.
You should see the single success line. Testing just the preview workspace proves that the code can add a column. Testing both responses catches the more expensive mistake of silently changing an existing customer's export. Keeping the old format assertion around is especially valuable when the downstream importer belongs to someone outside your team.
To check the compile-time boundary, temporarily change gb.isOn("includeUniqueReaders") to gb.isOn("includeUniqueReader") and rerun npx tsc --noEmit. The diagnostic should identify the misspelled key. Restore it before running the server again. A coding agent can include the before-and-after type check and the two CSV headers in its pull request.
Decide when to expand the report
When one preview customer is ready, leave everyone else on the default. If the next step is to enroll a fraction of workspaces, choose an attribute that matches the promise you're making. Hashing a workspace ID lets colleagues downloading the same report share a format. Hashing each user's ID could give two analysts in the same company different column sets. The one-shot guide shows how to express a percentage and hash attribute in a local rule.
A new rule in flags.ts reaches a process through your deployment. During a rolling deploy, the same workspace might hit old and new processes. If customers need a durable choice of export schema, keep supporting the agreed format in the API itself. When the operational requirement is to change targeting between deploys, you can keep the scoped evaluation in the handler and change how the process receives its rules. The free GrowthBook offerings overview covers Cloud Starter and self-hosting for teams that want to manage those rules.
Manage report targeting in Cloud
Create a GrowthBook workspace when the team supporting exports needs to expand the preview independently of a server release.
Get Started with GrowthBookYour conference agenda has a new “Show room” button. Reviewers should see it on the first page load. Everyone else should get the existing agenda. If a Server Component renders the old agenda and a browser hook independently decides to show the new button, the first HTML and the browser can disagree.
In the Next.js App Router, the server can make this decision once and pass a boolean to the interactive component. We'll define the flag in the repo, select the preview audience with a local test cookie, and verify the actual HTML for both visitors. Clicking the button will still work after hydration. You can follow along without a GrowthBook account or client key. If you're assigning this work to an agent, the free feature flags for coding agents walkthrough gives the background.
Keep the flag definitions on the server
Use a TypeScript App Router project, or create a small one with create-next-app. These paths assume the project has an app directory at its root. If yours uses src/app, put both app and lib under src so the relative imports still match.
Keep the starter's root layout. Create lib/agenda-flags.ts with the following code. The SDK type registration update explains how LocalFeatures checks the flag and its rule against the registered types. This setup requires version 2.2.0 or later.
The module can reuse the client and rules across requests handled by the same process. It only holds the current visitor's audience inside the function call. Two requests can therefore use the same flag file and get different results. The Node.js SDK documents the scoped client used under the App Router here.
This particular rule has no percentage and needs no visitor ID. The two audiences are sufficient. If the team later asks for a rollout to 10% of attendees, add a stable attendee or registration ID and choose which of those units should stay together. Jeremy Dorn's Register pattern article explains how a change to an attribute type reaches the call sites that construct it.
Read the cookie for this request
Create app/agenda/page.tsx. The static heading can render for everyone. The request-specific content sits behind a Suspense boundary, so the fallback can show a neutral loading message until the server has the cookie.
The App Router's cookies function reads the incoming request asynchronously. Read it inside the visitor-specific component. Keeping that read out of shared cached code lets the surrounding page reuse common content without treating one visitor's decision as another's. This placement also accommodates App Router projects using Cache Components.
Give your agent the Next.js setup
Use the local flags guide with a concrete request to evaluate one flag on the server and return the same decision to the browser.
Open the Local Flags GuideThe cookie in this demo is a convenient way to preview a public UI treatment. Anyone with that cookie can see the room label. To target paying attendees or private sessions, obtain the audience from the verified session on the server and authorize the underlying data separately.
Pass one decision to the interactive component
Create app/agenda/Agenda.tsx. It's a Client Component because a visitor can open and close the room details. Its initial branch comes directly from the boolean supplied by the page.
The client boundary takes a serializable prop. The component receives true or false. The SDK instance, targeting rules, and cookie handling stay in the server module. You don't need a React provider for this component because its only browser-side choice is whether the visitor has clicked the button.
Follow one page load through server rendering and hydration. For a preview visitor, the server can send a section with a “Show room” button. React's first client render gets the same showRoom value and starts with open set to false. Hydration attaches the click handler. Opening the room detail then updates component state and doesn't require another flag evaluation.
Verify the HTML and the click separately
Build the production app and start it on port 3100.
In a second terminal, save this as verify-agenda.mjs in the project root and run node verify-agenda.mjs. The test makes two requests to the same route and looks for a marker on the rendered section. A marker in the HTML helps catch an implementation that only adds the intended layout after JavaScript runs.
Now open http://localhost:3100/agenda in a fresh browser profile. You should see the session title without a room button. In that local page's browser console, set the demo cookie and reload.
Click Show room and look for Room 204. Click Hide room and the room should disappear. This second check proves the component became interactive. If the server response test passes but the click fails, inspect the browser console for a hydration error before changing the flag rules.
Remove the fixture and reload once more. The button should disappear and the agenda title should remain.
The reload is deliberate. Editing the cookie in an already open document doesn't rerun its Server Component. In your app, use the normal session-change flow to request a fresh server render when a visitor signs in, signs out, or leaves a preview group.
Choose where the next flag should be evaluated
For a decision needed in the initial HTML, give the agent an observable requirement. Ask it to show the two HTTP responses, then click the interactive control in the preview. The first check catches an incorrect layout. The second catches correct HTML that never becomes interactive.
If a later feature depends on an action entirely within the browser, evaluate whether its flag belongs in the client tree. The one-shot local flags guide covers both placements. This agenda only needs one server decision. Updating its checked-in rule takes a deployment. Keep that tradeoff in view if the event organizer needs to pause a preview while attendees are already arriving. For that case, compare GrowthBook’s free options for changing flags between deploys.
Manage the agenda rollout in Cloud
Create a GrowthBook workspace when the organizer needs to adjust a preview audience while your Next.js app is serving attendees.
Get Started with GrowthBookReady to ship faster?
No credit card required. Start with feature flags, experimentation, and product analytics—free.



