Run an experiment
Test a challenger prompt against the one in use with two files, read the result per arm, and ship the winner as a Change.
An Experiment in code is two files: the challenger, beside the value it replaces, and one file in experiments/ that says what decides it. Merging starts it; concluding it ships the winner.
Prerequisites
- A project with
npx startup-builder devrunning. The examples useleaseline.app, which sells lease-renewal tracking to property managers at $29 a month. - A prompt in use,
prompts/, graded by an Evaluator. Prompts covers the file.support-reply.md
Steps
-
Copy the prompt to
prompts/and rewrite its body. Thesupport-reply@lease.md @leasesuffix makes it an arm, inert until an Experiment names it. -
Create
experiments/:reply-with-the-lease.mdx experiments/reply-with-the-lease.mdx --- hypothesis: Replies that cite the manager's lease record resolve more Conversations with no person involved. varies: prompts/support-reply unit: conversation metric: agent-resolution-rate guardrails: [resolution-time] window: 21d minN: 120 --- -
Save. The preview shows the Experiment in
draftand the challenger's Evaluator score beside the control's. A challenger that scores worse fails the Change here. -
Check an assignment without counting it. Mode
tryreturns the arm and records no Exposure:TypeScript import { $ } from 'startup-builder' const { variant } = await $.try.Flag.evaluate({ flag: 'reply-with-the-lease', unit: 'conversation_1' }) -
Merge the Change. The challenger runs in shadow on live Conversations, then
Experiment.startsplits them between the arms. -
Read the result. Each arm's Readout prints its value, its sample and whether it can be read yet:
Terminal npx startup-builder show /experiments/experiment_1 -
Once the window closes and both arms pass
minN, conclude it:
Ship the support reply that cites the lease.Result
ship records a Decision and opens a Change that makes the challenger prompts/. The losing arm is killed and kept, with every Exposure, and the Hypothesis moves to supported. kill keeps the control; iterate drafts the next challenger from the Readout.
A guardrail breach never waits for you: the Experiment stops and every unit returns to the control.
Next steps
- Experiments: every key, and what may never be varied.
- React hooks:
useVariantshows an arm in a component. - Experimentation: how stakes pick the method.