Quickstart
Zero to a resolving Flag.
Install the CLI, create and verify a Flag in dev, connect the SDK, then turn the Flag on in prod.
Building with a coding agent?
Install the splitch skill in your repository. Codex, Claude Code, and OpenCode can follow these steps with the CLI and read its JSON output.
npx skills add https://github.com/zaks-io/splitch/tree/main/skills/splitchFor an agent with native MCP support, you can also connect the remote server directly.
claude mcp add --transport http splitch https://mcp.splitch.devSign in in your browser when your agent connects. In Claude Code, run /mcp if it does not prompt. There is no key to copy.
Step 1 / 13
Install and authenticate
The CLI ships on npm. Log in with the device flow: it prints a verification URL and polls until approved.
npm install --global @splitch/cli splitch loginStep 2 / 13
Choose or create an Organization
List the Organizations you can access. If the list is empty, create one. Use the Organization's returned id as --org in the next step.
splitch orgs list --json # If the list is empty: splitch orgs create --name "My Org" --jsonStep 3 / 13
Create an App
Replace <orgId> with your Organization's id. Creating an App also creates dev and prod Environments. Save the id of the entry with key dev in the returned environments array. You will need that canonical env_ ID to Promote to prod.
splitch apps create --org <orgId> --name "My App" --jsonStep 4 / 13
Select the dev Environment
Select the App and Environment to use for the following commands. This selection does not change your permissions.
splitch use --app my-app --env devStep 5 / 13
Get your credential
The Client Key is public and safe to ship in a browser. The API Key is secret, surfaced once, for trusted servers. New Client Keys start open to all origins so they work immediately; lock them to your origins before production.
splitch client-key getStep 6 / 13
Create a Flag
Define the Flag once for the App, then configure it for each Environment. The CLI defaults the lifecycle class to release, the owner to you, and expiry to 90 days. A new Flag starts disabled and serves the Default Variant until you enable it and set a Percentage Rollout.
splitch flags create --key new-checkout --variants on,offStep 7 / 13
Enable and roll out
Enable the Flag and set its Percentage Rollout to 100% so every Targeting Key in this Environment gets the non-default Variant. See /docs/flags for Flag Configuration fields.
splitch flag-config update new-checkout --enabled true --rollout 100Step 8 / 13
Verify
Verify the Flag for a Targeting Key without recording an Exposure. If the response has reason "DISABLED", enable the Flag before continuing. After enabling it, expect reason "SPLIT" and value true. This confirms that your credentials and Flag Configuration work in the selected Environment.
splitch flags verify new-checkout --targeting-key test-user-1 --json # before enable: {"value":false,"variantName":"off","reason":"DISABLED"} # after enable: {"value":true,"variantName":"on","reason":"SPLIT"}Step 9 / 13
Install the SDK
Install the JavaScript SDK in your app.
npm install @splitch/sdkStep 10 / 13
Wire the SDK
Replace pk_... with the dev keyMaterial from client-key get, then run this example in a JavaScript module. It evaluates the Flag for test-user-1 and logs the result. Check for reason "ERROR" and use errorCode to handle a failed evaluation. SDK evaluations record Exposures only while an Experiment Run is live. This plain Flag has no Experiment Run, so it records no Exposure.
import { createSplitchClient } from "@splitch/sdk"; // Paste keyMaterial from `splitch client-key get` (pk_…; not the ck_… keyId). const splitch = createSplitchClient({ clientKey: "pk_..." }); const d = await splitch.evaluateDetails("new-checkout", { targetingKey: "test-user-1", }); if (d.reason === "ERROR") throw new Error(d.errorCode); console.log(d.value, d.variantName, d.reason);Step 11 / 13
Promote to prod
Promote the enabled state and Percentage Rollout from dev to prod. Replace <devEnvironmentId> with the id of the dev entry in environments[] from App creation. --from-environment-id requires the canonical env_ ID, while --env accepts the key prod. New Apps use the confirm Policy for these prod changes. This command returns APPROVAL_REVIEW_REQUIRED with exit code 4 and a pending Approval Request. Prod stays unchanged until Confirmation.
splitch flags promote new-checkout --env prod --from-environment-id <devEnvironmentId> --body-json '{"select":{"enabled":true,"rollout":true}}' --idempotency-key promote-1 --jsonStep 12 / 13
Review and confirm the Promotion
Inspect the Approval Request using details.approvalRequestId from the previous response. When you are ready to apply it, rerun the same Promotion command with the same idempotency key and add --confirm. Under the confirm Policy, this Confirmation lets you self-review and apply the pending Approval Request.
splitch approval-requests get <approvalRequestId> --json splitch flags promote new-checkout --env prod --from-environment-id <devEnvironmentId> --body-json '{"select":{"enabled":true,"rollout":true}}' --idempotency-key promote-1 --json --confirmStep 13 / 13
Verify prod and connect your app
Verify the Flag in prod, then fetch prod's Client Key. Replace the SDK example's clientKey with the returned keyMaterial to connect your production app. Each Environment has its own credential. Restrict the Client Key to your production origins before shipping it.
splitch flags verify new-checkout --env prod --targeting-key test-user-1 --json # {"value":true,"variantName":"on","reason":"SPLIT"} splitch client-key get --env prod --json
When a step fails
If a command fails, read its error code and follow the recovery steps below. Agents can use the recommendedAction field in a 409 response to choose the next action.
| You hit | It means | Do |
|---|---|---|
| APPROVAL_REVIEW_REQUIRED | the Environment Policy gates this change | inspect the Approval Request, then provide Confirmation if you intend to apply it |
| VARIANT_NOT_AVAILABLE | the Variant is not promoted to this Environment | promote the Variant to this Environment, then retry |
| RUN_FROZEN | the edit touches a running Experiment Run | clone into a new draft Experiment Run |
| APP_MISMATCH | wrong key for this App or Environment | fetch the credential for this Environment |
| 401 / 403 | bad or revoked key, or origin not allowed | check the key and its origin allow-list |
splitch