No slash command · from anglesite
Proposes, runs, and analyzes A/B tests using Astro build-time variants and Cloudflare Workers edge assignment. Manages hypothesis generation, variant creation, result monitoring, and winner promotion.
Ships in anglesite. 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.
None: SKILL.md is the whole skill.
Manage the full lifecycle of an A/B experiment: propose a hypothesis, generate variant copy, configure the test, monitor results, and promote the winner.
Read EXPLAIN_STEPS from .site-config. If true or not set, explain before every tool call that will trigger a permission prompt. If false, proceed without pre-announcing.
Experiments run in three layers:
src/pages/ab/<experiment-id>/<variant>.astro, built to /ab/<experiment-id>/<variant>/. The page under test (the control) is untouched.worker/site-entry.js assigns each new visitor a version by cookie and serves the variant page under the control's URL. Zero layout flicker. A direct visit to an /ab/… URL is a 404, and those pages are left out of the sitemap.src/scripts/experiment-goal.ts) reports the goal, and the Worker credits it to the visitor's version. npm run ai-experiment -- results runs a Bayesian comparison and prints a plain-language summary.| Concern | Where | Why |
|---|---|---|
| Active experiment config | experiments.json in the project, published to KV (EXPERIMENTS binding, key active-experiments) | The file is the source of truth and is version-controlled; KV is the copy the Worker reads at the edge |
| Impressions + conversions | Analytics Engine (ANALYTICS binding, dataset anglesite_events) | Non-blocking writes, SQL-queryable |
| Outcomes + learning history | experiments-history.json in the project | Committed with the site; read it to ground new hypotheses |
Every npm run ai-experiment command is a single self-contained command — never chain it, and never read .env yourself.
The site must already be live. A test needs real visitors. If the site has never been deployed (no CF_PROJECT_NAME in .site-config), say so, offer to make the improvement directly instead, and stop.
Then check what the site needs for edge routing:
npm run ai-experiment -- check
npm error Missing script: "ai-experiment" — the site was scaffolded before experiments shipped. Run ${CLAUDE_PLUGIN_ROOT}/skills/update/SKILL.md first, then re-run the check.Ready. — continue to Step 1.MISSING lines — each one prints its fix. Lines that name /anglesite:update need the update skill. The EXPERIMENTS and ANALYTICS lines are expected the first time: switch them on below. Apply any other fix exactly as printed.Tell the owner: "I'm switching on the part of your site that can show different versions to different visitors. It's free and it only takes a minute."
1. Create the KV namespace.
Preferred — Cloudflare MCP (no copy-paste):
${CLAUDE_PLUGIN_ROOT}/docs/cloudflare-mcp.md.kv_namespaces_list. If a namespace titled EXPERIMENTS already exists, reuse its id.kv_namespace_create with title: "EXPERIMENTS" and read the id from the response.Fallback — wrangler CLI (use only if no kv_namespace_create tool is available):
npx wrangler kv namespace create EXPERIMENTS
The output prints the namespace id.
2. Bind both resources in wrangler.jsonc with the Edit tool. The template ships the two blocks commented out — uncomment them and replace REPLACE_WITH_EXPERIMENTS_KV_ID with the id. If the blocks aren't there, add them at the top level:
"kv_namespaces": [
{ "binding": "EXPERIMENTS", "id": "<id from step 1>" }
],
"analytics_engine_datasets": [
{ "binding": "ANALYTICS", "dataset": "anglesite_events" }
],
The Analytics Engine dataset needs no creating — Cloudflare makes it on the first write.
3. Re-run the check and continue only when it prints Ready.:
npm run ai-experiment -- check
The bindings take effect on the next deploy (Step 3).
Analyze the page the owner wants to test. Consider:
/anglesite:stats)${CLAUDE_PLUGIN_ROOT}/docs/smb/ for the owner's BUSINESS_TYPEexperiments-history.json if it existsPropose a specific, testable hypothesis and the one action that counts as success (the goal). Example:
"I think changing the hero headline from 'Welcome to Pairadocs Farm' to 'Fresh Eggs and Seasonal Produce — Join Our CSA' will get more people to send the contact form, because visitors will immediately understand what you offer."
Always get the owner's approval before proceeding. Show them the exact copy for each variant.
If the owner says "test my site" without a specific idea, prioritize by expected impact:
One test at a time. Sequential. No multivariate experiments until traffic warrants it.
Create 1-2 alternative versions of the element under test. Ground the copy in:
BUSINESS_TYPE and brand voice (read docs/brand.md if it exists)experiments-history.json says has worked on this site beforePresent each variant side-by-side with the control for the owner to approve or edit.
Pick a short id for the test (lowercase letters, digits, hyphens — e.g. homepage-hero) and a goal name (e.g. contact-form-submit). Variants are named variant-a, variant-b.
Mark the goal on the page under test. Add data-experiment-goal="<goal name>" to the element whose use counts as success — a <form> (counted on submit) or an <a>/<button> (counted on click). Then load the beacon anywhere in the page body, with the relative path adjusted to the page's depth:
<script>import "../scripts/experiment-goal.ts";</script>
If the goal element is on a different page (the test changes the homepage, the form is on /contact), put the attribute and the script on that page instead.
Create the variant page. Copy the page under test to src/pages/ab/<id>/<variant>.astro and, in the copy:
../layouts/… in src/pages/index.astro becomes ../../../layouts/…);canonicalPath="<page path>" to the layout (e.g. canonicalPath="/"), so the variant keeps the real page's canonical URL and social image;src/pages/index.astro ← control (only the goal marker added)
src/pages/ab/homepage-hero/variant-a.astro ← variant
The owner can preview the variant in the dev server at /ab/<id>/<variant>/.
Write the definition to experiments.json at the project root (create it as a JSON array if it doesn't exist; keep earlier entries):
[
{
"id": "homepage-hero",
"name": "Homepage headline",
"page": "/",
"variants": ["control", "variant-a"],
"weights": [0.5, 0.5],
"metric": "contact-form-submit",
"active": true,
"hypothesis": "A headline that says what we sell gets more contact-form submissions",
"controlCopy": "Welcome to Pairadocs Farm",
"variantCopy": "Fresh Eggs and Seasonal Produce — Join Our CSA",
"startedAt": "YYYY-MM-DD"
}
]
page is the path of the page under test with no trailing slash (/ for the homepage). control is always first. metric must equal the data-experiment-goal value. Only one active experiment per page. Don't test a members-only page (one listed in worker/_premium-routes.json) — pick a public page instead.
Check it — this validates the file and confirms every variant page exists:
npm run ai-experiment -- check
Build:
npm run build
Deploy by following ${CLAUDE_PLUGIN_ROOT}/skills/deploy/SKILL.md. The deploy carries the variant page and, the first time, the new bindings. If the deploy reports that Analytics Engine is not enabled on the account, ask the owner to open the link in the error (it is a one-click, free opt-in in their Cloudflare dashboard), then deploy again.
Publish the config to the live site — only after the deploy, so the variant page exists before anyone is sent to it:
npx wrangler kv key put active-experiments --path experiments.json --binding EXPERIMENTS --remote
Verify it is live. This requests the page as new visitors until it has been handed every version (the Worker doesn't count these as impressions). The config can take up to a minute to reach the edge — if the first run says NOT LIVE, wait a minute and run it once more:
npm run ai-experiment -- verify
If SITE_DOMAIN isn't set yet, add --url https://<the site's workers.dev address>.
Only when verify prints LIVE, tell the owner: "The test is live. Ask me 'how is the test going?' any time and I'll check the numbers — I can't watch it on my own between our conversations."
If it still prints NOT LIVE, do not say the test is running. Read the reason it gives, fix it, and verify again.
Results need a Cloudflare API token in .env. Check without reading the file:
npm run ai-cf -- status
If CF_API_TOKEN or CF_ACCOUNT_ID is missing, follow "Step 0 — Check prerequisites" in ${CLAUDE_PLUGIN_ROOT}/skills/stats/SKILL.md (the token needs Account → Analytics Engine → Read), then come back.
npm run ai-experiment -- results homepage-hero
It prints visitors and goal completions per version, a plain-language comparison, and a final Verdict: line (variant-a, control, inconclusive, or no-data). Relay it to the owner in your own words — say "the original" and describe the variant by its copy, not its id:
Homepage headline "Fresh Eggs and Seasonal Produce" is outperforming the original by about 18%. We're 87% confident this is a real difference — a bit more data will confirm it. Original: 3.2% · New version: 3.8%
Early read in the output means fewer than 100 visitors have seen a version. Share the numbers, but don't recommend a decision.Warning: the traffic split does not match is a sample ratio mismatch — usually a technical problem (a caching layer, a bot hammering one page). Tell the owner the numbers can't be trusted yet and investigate before acting.no-data after the site has had real visits: run npm run ai-experiment -- verify to confirm routing is still live.Act when the verdict names a winner (95% confidence), or when the owner decides.
Record the outcome. This appends to experiments-history.json (with the final numbers) and sets the experiment inactive in experiments.json. --winner is a variant name, control, or inconclusive:
npm run ai-experiment -- conclude homepage-hero --winner variant-a --notes "Specific headline beat the generic welcome"
Stop the test on the live site right away, so every visitor gets the original again while you clean up:
npx wrangler kv key put active-experiments --path experiments.json --binding EXPERIMENTS --remote
Update the page.
In both cases remove the data-experiment-goal attribute and the beacon <script> unless another active experiment uses them, then delete the variant pages:
npm run ai-experiment -- cleanup homepage-hero
Build with npm run build, then deploy by following ${CLAUDE_PLUGIN_ROOT}/skills/deploy/SKILL.md.
Tell the owner, as fits:
If inconclusive after sufficient time (30+ days, or 500+ visitors per version): discuss before concluding — "The test has been running for a while and the results are too close to call. Want to keep testing, try a different variant, or call it?" — and act on their preference.
/ab/event — no identifier, no third partyThe owner should never need to understand statistics. Use these patterns:
| They say | You do |
|---|---|
| "Test two versions of my headline" | Run Steps 0-3 |
| "How is the test going?" | Run Step 4 |
| "Go with Version B" | Run Step 5 (promote) |
| "Stop the test" | Run Step 5 (discard) |
| "What have we learned?" | Read experiments-history.json and summarize the patterns |
What SKILL.md sets; muted values are Claude Code's defaults
Use when the owner wants to test which headline, button, or layout performs better, or asks about A/B testing or improving conversions.
Three short reads, in order
npx claudepluginhub anglesite/anglesite-skills --plugin anglesite56 skills in this plugin
/bookingEmbed appointment scheduling (Cal.com or Calendly) into the siteOther plugins' skills for the same job