/dif:dif-author-experimentfrom dif
Drafts, edits, and validates dif.sh A/B test experiment files. Covers the full loop from dif new through dif validate to dif build, including frontmatter, variants, audience, and hypothesis.
Ships in dif. 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.
Use this skill when you're drafting, editing, fixing, or iterating on a .md file under dif/experiments/active/. It covers the loop from dif new through dif validate to dif build.
Before drafting:
dif/context.json to see what experiments are currently active, on which surface, and how long they've been running. If dif/context.json doesn't exist this is a fresh repo — run dif build once to generate it, or read dif/experiments/active/*.md directly.dif/surfaces/<your-surface>.md — the ## Learnings log shows what's already been concluded on this surface. Build on those findings; don't re-test something already answered. dif new will also embed the last 3 learnings into the draft as an HTML comment, so you'll see them again in the file. If dif/surfaces/ is empty or only has the default home.md from dif init, run the dif-generate-surfaces skill first to produce the surface set before drafting.dif/config.yaml to see what audience attributes are declared. You can only use predicates over attributes listed there (E006); anything else needs to be added to the config first.This isn't ceremony — the experiment file you draft is downstream of these three reads. Skipping them produces lower-quality experiments.
dif new <kebab-id> --surface <surface-name>
# edit dif/experiments/active/<kebab-id>.md
dif validate # collects all errors at once
# fix any errors (see references/validation-errors.md)
dif build # also runs validate
git add dif/ && git commit
dif new writes a frontmatter stub with status: draft, today's date, owner from git config, and two default variants (control / variant_a at 50/50). It also embeds the surface's last 3 learnings as an HTML comment inside ## Brief. Your job is to fill in the hypothesis:, the ## Brief, the ## Rationale, and (usually) audience: and metrics:.
You can also pass --from <existing-experiment-id> to copy variants, audience, and exclusion_group from a prior experiment — useful for follow-up tests on the same surface.
hypothesis: — one sentence, falsifiable, naming both the change and the expected primary-metric outcome for a named audience. Example: "Bolder CTA copy will lift checkout conversion on mobile by 1–3% over 14 days without regressing latency."variants: — at least two. Weights must sum to exactly 100 (E005). Keep control as the literal first id; the SDK treats it as the no-change branch. Variant ids are kebab-case.audience: (optional but usually present) — include / exclude lists of attribute predicates. Attributes must be declared in dif/config.yaml's audience_attributes. See references/audiences.md for the predicate grammar.metrics: primary: — the single metric this is moving. One primary metric per experiment, full stop. Add metrics: guardrails: for metrics that must not regress.exclusion_group: (optional) — string key that lets two experiments on the same surface coexist. The runtime picks the earlier-created: one per user. Required when E007 fires.The body has three sections:
## Brief — what you're testing and why. Reference the prior learnings comment that dif new embedded.## Rationale — what signal prompted this (funnel report, ticket cluster, user research). Why now, why this approach over the alternatives.## Decision — leave empty. dif conclude fills this.50 / 30 / 30 — sums to 110, fails E005.country: US when country isn't in audience_attributes — fails E006. Add the attribute first.exclusion_group — fails E007. Pick: shared group, or narrow one audience so they're provably disjoint (e.g. country: US vs country: UK).dif validatedif validate collects every error in one pass and points at the file + line. Fix top-to-bottom; rerun until clean. Common shapes:
--- fences.audience_attributes (and create dif/audiences/<name>.ts) or remove the predicate.exclusion_group to both files, or narrow one audience.dif/tracking-plan.yaml. Fix the spelling, or offer to run the dif-setup-analytics skill (Step 4) to add the event and its dif.track() call. An experiment whose metric is never sent has no data.See references/validation-errors.md for every code with its fix.
If you're proposing the experiment yourself (not implementing one a human specified): the input is dif/context.json + dif/surfaces/<surface>.md Learnings. The Learnings log is the surface's institutional memory — read all of it, not just the last three lines. Propose hypotheses that build on or contradict prior findings. Don't propose tests that re-litigate something already concluded unless the conditions have meaningfully changed.
references/frontmatter.md — full schema and a complete worked example.references/validation-errors.md — every error and warning code with the exact fix.references/audiences.md — predicate grammar, the config.yaml pairing, the dif/audiences/*.ts resolver contract, and how exclusion groups differ from audience filters.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dif-sh/dif --plugin dif7 skills in this plugin
/dif-conclude-experimentConclude a dif.sh experiment or rollout with real numbers. Gets the result from dif analytics over MCP or REST, checks the verdict, writes the Decision from decision_draft, runs dif conclude, and records the surface Learning. Use when the user wants to conclude, finish, ship, kill, wrap up or document the outcome of a dif experiment, write a decision, record a learning, or run the command dif conclude./dif-connect-cloudConnect a dif.sh workspace to dif analytics from the terminal. Signs the dif CLI in with a code the person approves in the browser, links or creates the dif analytics project, writes its publishable key into dif/config.yaml, shows the GitHub App install link and runs dif build. Use when the user wants to connect, link or set up dif analytics, log in or sign up to dif, send events to dif analytics, or mentions dif cloud, dif auth login, dif connect or needs_selection./dif-docsReference for dif.sh — feature flags and A/B experiments stored as Markdown files in the repo and compiled by `dif build` into a typed TypeScript client. Use when adding feature flags, a percentage rollout, or an A/B test to a JavaScript or TypeScript app (Next.js, React, SvelteKit, plain TS), when the user wants flags as code instead of a dashboard, or when the user mentions dif, dif/config.yaml, dif build, dif validate, or @dif.sh/sdk./dif-generate-surfacesGenerating the initial set of dif.sh surfaces by reading the app's structure and product context. Use when the user wants to set up, scaffold, populate, auto-create, or propose surfaces for a dif project — especially right after `dif init`, when `dif/surfaces/` is empty or sparse, or when `dif new` fails with "surface does not exist". Reads the codebase (routes, pages, README, package.json) plus `dif/context.json`, proposes a candidate set of surfaces with one-line rationales, confirms with the user, then writes the matching `dif/surfaces/<name>.md` files./dif-setup-analyticsSet up dif analytics in an app and prove events arrive. Installs the site analytics script for page views, wires sign-in, consent and CSP, plans and adds marketing and product events with dif.track and data-dif-event, checks every experiment metric is tracked, and runs the install check. Use when the user wants to set up, install, add or check dif analytics, page views, visitors, UTM, conversion or product events, tracking, a tracking plan or instrumentation, or when triage reports fix_instrumentation or a metric has no data./dif-triage-experimentsTriage every running dif.sh experiment and rollout from the dif analytics overview. Shows what needs action, then ramps rollouts, turns off or kills harmful variants, and concludes winners and inconclusive tests by editing dif/ files, with one branch and one PR per experiment in autonomous mode. Use when the user asks to triage experiments, review all experiments, see what needs action, ramp, turn off, kill, find winners, or check the dif analytics overview.Other plugins' skills for the same job