/dif:dif-connect-cloudfrom dif
Connects a dif.sh workspace to dif analytics from the terminal. Handles CLI authentication, project linking, and config setup.
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.
Use this skill to connect the dif/ workspace in this repo to a dif analytics project. At the end, dif/config.yaml has mode: cloud and the project's publishable key under events:, and dif build has put the key into the generated client.
If the person gives you a publishable key (dif_pk_...), do not use the steps below. Run dif connect --key <key> --json, then dif build. That path needs no login and no network.
If dif is not on the PATH, use npx @dif.sh/cli in place of dif in every command. Never use npx dif: it can run a different npm package. If dif auth is an unknown command, the CLI is older than v0.9.0. Tell the person to update it.
--json to every dif auth and dif connect command. Each prints exactly one JSON object on stdout.ok and on the error code. Do not branch on message or on the exit code number.dif auth status --json
If logged_in is true, go to Step 4. This command makes no network call and never prints the token.
dif auth login --no-wait --json
It returns at once. Show verification_uri_complete and user_code to the person, for example:
Open https://cloud.dif.sh/cli/activate?code=WDJB-MJHT
Check that the page shows the code WDJB-MJHT, then approve.
A person with no dif account can sign up on that page. Do not open the URL yourself. The person approves in their own browser.
If the person is at a terminal and prefers it, they can run dif auth login there themselves. It opens the browser and waits. Then go to Step 4.
dif auth login --resume --json
"status": "logged_in": go to Step 4.authorization_pending: the person has not approved yet. Run the same command again. The CLI keeps the code.access_denied: the person clicked Deny. Stop and tell them.expired_token: the code expired. Stop and tell them. Start again at Step 2 only if they ask.no_pending_login: there is no login to resume. Go to Step 2.The command waits up to 600 seconds. If your shell stops long commands, add --timeout 60 and repeat on authorization_pending.
dif connect --json
On ok: true, go to Step 5. On needs_selection, the response lists orgs and projects. Show them to the person and ask for one of these:
dif connect --project <slug> --json.dif connect --create --json. Add --name <name> for a name other than the folder name.Add --org <slug> when orgs has more than one entry. When orgs is empty, --create makes a personal org. A project whose repo is this repo is usually the right one, but the person decides. Do not pick for them.
If repo.status is "unlinked", show repo.github_install_url to the person. Tell them that dif analytics syncs the experiment files from the repo after they install the GitHub App. Events work before the install.
If repo.status is "linked", there is nothing to do. Show dashboard_url in both cases.
dif build
This writes the key into dif/generated/client.ts. dif connect changed only dif/config.yaml.
To send page views and product events, use the dif-setup-analytics skill next.
error | What to do |
|---|---|
not_logged_in | Go to Step 2. |
token_invalid | The login expired or was revoked. If Step 1 showed "source": "env", the dif_cli_ token in DIF_TOKEN is no longer valid. Ask the person to replace or unset it, and stop. Otherwise go to Step 2. |
forbidden | This login cannot do that, for example create a project in that org. Tell the person. They can pick an existing project, or ask an org owner. |
org_not_found, project_not_found | The slug is wrong. Run dif connect --json with no flags to get the lists again. |
no_org | This login has no org and no projects. Offer dif connect --create: the server then makes a personal org and the project. Or ask for a dif_pk_… key and run dif connect --key <key>. |
no_workspace | There is no dif/ folder here. Run dif init first. |
bad_request, usage (exit 2) | dif analytics or the CLI refused a value, such as a slug that is not letters, digits and -. Read message, fix the value and run again once. |
rate_limited | Wait retry_after seconds, then try once more. |
cloud_unreachable, cloud_error | Tell the person and show message. Do not retry in a loop. |
~/.config/dif/credentials.json.dif auth logout unless the person asks.events: block by hand. dif connect writes it.DIF_CLOUD_URL if the person set it. It points the CLI at a local or self-hosted dif analytics.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub dif-sh/dif --plugin dif7 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-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