/dif:dif-docsfrom dif
Reference for dif.sh — feature flags and A/B experiments stored as Markdown files and compiled into a typed TypeScript client. Use when adding flags, percentage rollouts, or A/B tests to JS/TS apps.
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.
None: SKILL.md is the whole skill.
dif keeps each feature flag or A/B experiment as one .md file under dif/experiments/, checked into git with the code it gates. dif validate checks the files, dif build compiles them to dif/generated/client.ts, and @dif.sh/sdk (zero dependencies) assigns variants locally at runtime. No signup, no network call to evaluate a flag.
npm install -D @dif.sh/cli # or: curl -fsSL https://dif.sh/install.sh | sh
npm install @dif.sh/sdk
npx @dif.sh/cli init # scaffolds dif/, config, agent files
npx @dif.sh/cli new new-checkout --surface home
# edit dif/experiments/active/new-checkout.md: variants, weights, status: active
npx @dif.sh/cli validate
npx @dif.sh/cli build
dif/generated/ is gitignored, so add "prebuild": "dif build" (and "predev": "dif build") to package.json, or CI and deploys ship without a client.
---
id: new-checkout
status: active
owner: [email protected]
surface: checkout
hypothesis: >
Inlining the address form lifts completed checkouts on mobile.
variants:
- id: "off"
weight: 90
- id: "on"
weight: 10
metrics:
primary: completed_checkout
created: 2026-07-01
---
A flag is an experiment you ramp toward 100%; an experiment holds a split. Same schema. The first variant is the fallback. Weights must sum to 100.
import "./dif/generated/client"; // once, at boot: registers every active flag
import { attributes } from "./dif/generated/audiences";
import { dif } from "@dif.sh/sdk";
dif.init({ userId: () => currentUser?.id ?? null, attributes: () => attributes() });
const checkout = dif("new-checkout", {
off: () => <OldCheckout />,
on: () => <NewCheckout />,
});
dif validate warns (W001) when a call site names an id that isn't an active experiment. At runtime, an unknown id or a variant with no matching branch renders the first branch and fires no exposure. For server rendering, use the pure assign(id, { userId, attributes }) export instead of dif(); @dif.sh/react and @dif.sh/svelte wrap both.
dif(), assign(), React and Svelte adapters, dif.track()): https://dif.sh/docs/sdk.mddif/config.yaml: https://dif.sh/docs/config.mdInstall the workflow skills with npx skills add dif-sh/dif: dif-author-experiment (draft and validate a flag or experiment), dif-conclude-experiment (get the result from dif cloud, check the verdict, record the decision and archive), dif-triage-experiments (review every active experiment in the dif cloud overview, then ramp, turn off or conclude the ones that need action, with one PR each in autonomous mode), dif-generate-surfaces (propose dif/surfaces/ from the app's routes), dif-setup-analytics (install site analytics or SDK page views, plan and add marketing and product events, check with dif site check and dif events that they arrive). dif init also writes them into .claude/skills/. The conclude and triage skills read dif cloud through its MCP server at https://cloud.dif.sh/mcp (set up with a read token) or a read token in DIF_TOKEN. Setup: https://dif.sh/docs/mcp.md
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
7 skills in this plugin
/dif-author-experimentAuthoring and iterating on dif.sh experiments — drafting frontmatter, choosing variants and weights, declaring audiences, and validating the file. Use whenever the user wants to create, draft, edit, or fix a dif experiment, or mentions A/B test, variant, audience, hypothesis, surface, exclusion group, or the commands dif new, dif validate, or dif build./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-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.npx claudepluginhub dif-sh/dif --plugin difOther plugins' skills for the same job