All docs

docs / get started

Configuration

Keys, flagsmith.json and flagsmith.env, settings and commands.

On this page

Petri needs two things: where your Flagsmith is, and a key that can read it. Everything else has a default. A repo bound with the Flagsmith CLI, or set up by selfhost/bootstrap.mjs, needs no configuration at all.

Connecting

Petri looks for a connection in this order and uses the first it finds:

  1. The key you entered with Petri: Connect to Flagsmith, kept in VS Code's SecretStorage (never in settings or files).
  2. The Flagsmith CLI's credential variables in the environment VS Code was started from: FLAGSMITH_API_KEY_<host> for self-hosted (for http://localhost:8000, the name is FLAGSMITH_API_KEY_localhost_8000) or FLAGSMITH_API_KEY for Flagsmith Cloud.
  3. flagsmith.env in the workspace root, the same variables in a file. selfhost/bootstrap.mjs writes it, and it is gitignored.

The API URL, project and environment come from flagsmith.json in the workspace root when it exists (written by flagsmith init or by the bootstrap), otherwise from the petri.apiUrl setting and the environment you pick in the sidebar.

An organisation API key is what Petri expects. It reads flags, experiments, metrics and results, and it sends the writes you approve. Flagsmith calls it an Admin API key; it is not the SDK environment key.

Variables and files

Variable / file Used by What for
FLAGSMITH_API_KEY_<host> extension, CLI, MCP server Organisation API key for a self-hosted Flagsmith. <host> is the host and port with . and : replaced by _ (and - doubled).
FLAGSMITH_API_KEY extension (Cloud only), CLI, MCP server Organisation API key for Flagsmith Cloud. The CLI also accepts it for any host.
FLAGSMITH_API_URL CLI, MCP server Flagsmith API URL, if not in flagsmith.json or --api-url
FLAGSMITH_ENVIRONMENT CLI, MCP server Environment key, if not in flagsmith.json or --environment
flagsmith.json extension, CLI, MCP server, Agent Skill API URL, project and environment (the Flagsmith CLI's binding file)
flagsmith.env extension, CLI, MCP server The variables above in a file, read from the workspace or checked folder
petri.lock.json extension, CLI, Action Commit it: the treatment lock of running experiments (PETRI013), the pre-registered stop, and decisions with their evidence. Written by Lock Running Experiments, starting an experiment, or petri-check lock
petri.plan.json CLI, Action, MCP server Experiment changes and staged ramps proposed as pull requests, applied by petri-check apply. Details →
.petri/audit.jsonl extension Every approved or declined write, appended
ANTHROPIC_API_KEY copilot only Claude key, if not set with Petri: Set Anthropic API Key. Everything else works without it.

Settings

Setting Default What for
petri.apiUrl http://localhost:8000/api/v1 Flagsmith Admin API base URL, e.g. https://api.flagsmith.com/api/v1. Connect sets it.
petri.include **/*.{js,jsx,ts,tsx,mjs,cjs,py,go,rb,java,kt,swift,dart,php,cs,rs,vue,svelte} Files scanned for flag reads and events
petri.exclude **/{node_modules,dist,build,out,.git,.next,vendor,venv,.venv}/** Files never scanned
petri.model claude-opus-5-5 Claude model for the Experiment Copilot
petri.verifyCommand empty (npm test when the nearest package.json has a test script) Run after the copilot edits code; the edit is reverted if it fails. Verified edits →
petri.autoRefreshSeconds 60 How often flags, experiments and results are re-read, and Petri Watch runs (0 turns it off)

Commands

All are in the command palette under Petri:.

Command What it does
Connect to Flagsmith · Disconnect · Select Environment Pick the instance, key and environment
Refresh · Rescan Workspace for Flags Re-read Flagsmith · re-scan the code
Open Experiment Results The results panel: every arm and metric with 95% intervals and Petri's verdict
Start Experiment · Pause Experiment · Complete Experiment & Roll Out… The lifecycle, each behind an approval
Recompute Experiment Results Ask Flagsmith to recompute exposures and results (the one call that needs no approval)
Remove Losing Code Path… After completion, the copilot proposes one diff that deletes the dead branch; your tests then run, and it's undone if they fail
Lock Running Experiments · Pre-register When to Decide Write petri.lock.json for experiments already running · set the planned stop (a date, a sample size, or one from a minimum detectable effect)
Turn Selection into Experiment… · Ask the Experiment Copilot Start the copilot
Set Anthropic API Key Stored in SecretStorage
Start Self-Hosted Flagsmith (Docker) Writes the Compose file and starts Flagsmith with experimentation
Set Variant Keys… · Store Experiment Events in Flagsmith · Switch to getExperimentFlag() Quick fixes for PETRI004, PETRI011 and PETRI005

What success looks like

Open a file that reads a flag in a running experiment. Above the read you see a CodeLens like 🧪 <experiment> · running · <leading arm> +<lift> on <primary metric> · <chance> to win, the experiment is listed in the Petri sidebar, and the status bar shows the environment you're connected to.

docs/configuration.mdView or edit on GitHub →