Feature flag experiments · built on Flagsmith

Your code ships behind feature flags. Do you know which ones help users?

Developers and agents push fixes behind flags every day. PerfFlags turns them into Flagsmith experiments, measures what real users get, and turns on only the fixes that make the experience better.

Star on GitHub

Run it locally

Let your coding agent set up PerfFlags

  1. Open a terminal in an empty folder and run claude.
  2. Paste the prompt below. It installs everything, connects Flagsmith, asks you for the keys it needs, and starts the app.
Set up PerfFlags on this machine and get it running locally. Work step by step and verify each step. If a step fails, stop and show me the exact error instead of working around it.

PerfFlags turns fixes behind a feature flag into Flagsmith experiments, measures real load times in real browsers, and turns on only the fix that wins.

Repository: https://github.com/Shobhnik13/perfflags

1. Check prerequisites: Node 22.19 or newer (`node --version`), pnpm (`pnpm --version`, install with `npm install -g pnpm` if missing), git, and the Flagsmith CLI v2 (`flagsmith --version`; install with `brew install Flagsmith/tap/flagsmith` or `curl -fsSL https://get.flagsmith.com | sh` if missing).
2. Clone the repository into ./perfflags and work inside it.
3. Install dependencies with `pnpm install`. If pnpm reports ignored build scripts, run `pnpm approve-builds esbuild sharp` and install again.
4. Install the browser the traffic runner uses: `pnpm --filter @perfflags/server exec playwright install chromium`.
5. Generate the demo shop images: `pnpm --filter @perfflags/web images:generate`.
6. Create the env file with `cp .env.example .env`, set FLAGSMITH_PROJECT_DIRECTORY to the absolute path of the repository, and link it for the web app with `ln -s ../../.env apps/web/.env.local`.
7. Connect Flagsmith:
   - Ask me to run `flagsmith login` myself (it opens a browser) and wait for me.
   - Run `flagsmith project list` and ask me which project and environment to use, or offer to create a project named perfflags with an environment named Development.
   - Bind the repository with `flagsmith init --project <project> --environment <client-side environment key>`.
   - Create a server-side key with `flagsmith environment key create <environment> --name perfflags-shop`. Its value is shown once: write it straight into .env as FLAGSMITH_SERVER_ENVIRONMENT_KEY without printing it.
   - Check that the environment has a warehouse: `flagsmith api api/v1/environments/<client-side key>/warehouse-connections/` must return at least one connection. If it returns none, send me to https://docs.flagsmith.com/experimentation/connect-a-warehouse and stop.
   - Write FLAGSMITH_ENVIRONMENT_KEY (the client-side key) and FLAGSMITH_PROJECT_ID into .env.
8. Now ask me, one at a time, for the keys you cannot create yourself, and write each into .env:
   - DATABASE_URL: a Postgres connection string (a free Neon database works).
   - ANTHROPIC_API_KEY: from https://console.anthropic.com.
   Never print a key back to me and never commit .env.
9. Create the database tables with `pnpm db:migrate`.
10. Start both apps as background shells in this session and keep them running: `pnpm dev:server` (API on http://localhost:4000) and `pnpm dev:web` (app on http://localhost:3000). Wait until `curl http://localhost:4000/api/health` returns ok and http://localhost:3000 loads.
11. Finish by telling me to open http://localhost:3000/dashboard, and walk me through the full test: scan http://localhost:3000/shop/product, ask the agent for a plan, enter my name and approve, approve the start, send 150 visitors, refresh the Flagsmith results about a minute after the traffic finishes, and ship the winner.

You will need: a Flagsmith account with Experimentation, a Postgres URL (Neon works) and an Anthropic API key. The agent asks for them at the end and keeps them in a git-ignored .env.

Measured on
real Chromium, throttled 4G
Decided by
Flagsmith Bayesian engine
Turned on by
a person, never the agent
flag hero_image · production

you › make the product page faster

merged › 3 fixes, all behind the flag:

  • off Serve the hero image as AVIF · agent
  • off Remove loading="lazy" from the hero · dev
  • off Preload the hero with fetchpriority="high" · agent

team › just turn them all on?

you › which ones actually help users?

PerfFlags verdictFlagsmith · Bayesian
Remove lazy-loading
LCP +4.6%15% chance to win
keep off
AVIF + eager + preload
LCP -84.9%100% chance to win
turn on

The problem

Every fix ships behind a flag. Then someone turns it on and hopes.

01

Code ships behind flags

Developers and coding agents merge fixes every day, wrapped in a feature flag so they can be turned on later.

02

Flags get flipped, not tested

Someone moves the flag from off to on and moves on. Nobody compares the users who got the fix with the users who did not.

03

Experiments feel like extra work

Variants, metrics, a fair split and the statistics for every fix take longer than the fix itself. So the experiment never happens.

How it works

From “make it faster” to a fix you can prove, in four steps.

  1. 01 · Scan

    See what users get today

    Lighthouse scans the live page, the version your users see with every flag off. Its findings show what is slow: a heavy hero image, lazy-loading, no priority hint.

  2. 02 · Plan

    An agent picks which flagged fixes to test

    Your fixes already sit behind a flag. Claude reads the findings and designs the experiment: which fixes, in which combinations, so the result shows which one matters.

  3. 03 · Measure

    Real browsers, real load times

    Flagsmith splits visitors by identity. Each visit is a real Chromium on throttled 4G, reporting its real Largest Contentful Paint and whether it reached the cart.

  4. 04 · Ship

    Turn on only what wins

    Flagsmith's Bayesian engine calls the winner. You approve, and the winner is turned on for everyone on the same flag. Losing fixes stay off.

A real result

Two fixes behind one flag. One of them did nothing.

Removing loading="lazy" is the textbook fix for a slow hero. On a 2.3 MB image it changed nothing: the download was the bottleneck. AVIF plus eager loading and a preload cut the load from 15.3 s to 2.3 s, and shoppers reached the cart 7× as often.

Demo store, 192 identities, Flagsmith Experimentation results. Every visit is a real Chromium load on throttled 4G with a 4× slower CPU; when a shopper gives up waiting is simulated.

You stay in charge

The agent proposes. A person approves.

Nothing changes in Flagsmith until someone with a name says yes: to create the experiment, to start it, and to ship the winner. Every decision lands in a log you can show an auditor.

  1. 03:43shobhnik approved the plan · flag, variants, metrics created
  2. 03:44shobhnik started the experiment
  3. 04:06Flagsmith: AVIF + eager + preload, 100% chance to win on LCP
  4. nextwaiting for a person to ship the winner

Built on Flagsmith

Every experiment is a real Flagsmith experiment. Nothing is mocked.

Multivariate flags

One flag per experiment, one keyed variant per fix.

Experiment metrics

lcp as a mean, lower is better. add_to_cart as an occurrence, higher is better.

Identity targeting

Each visitor keeps the variant they first saw. Exposures are recorded on the server.

Bayesian results

Lift, credible interval and chance to win for every variant and metric.

Same-flag rollout

Completing the experiment ships the winner on the flag you already have.

CLI and API

The agent provisions everything through the Flagsmith CLI. A person approves each step.

Your code is behind flags. Turn on what works.

Scan a page, let the agent design the experiment, and let Flagsmith prove which fix your users actually feel.

Run it locally

Let your coding agent set up PerfFlags

  1. Open a terminal in an empty folder and run claude.
  2. Paste the prompt below. It installs everything, connects Flagsmith, asks you for the keys it needs, and starts the app.
Set up PerfFlags on this machine and get it running locally. Work step by step and verify each step. If a step fails, stop and show me the exact error instead of working around it.

PerfFlags turns fixes behind a feature flag into Flagsmith experiments, measures real load times in real browsers, and turns on only the fix that wins.

Repository: https://github.com/Shobhnik13/perfflags

1. Check prerequisites: Node 22.19 or newer (`node --version`), pnpm (`pnpm --version`, install with `npm install -g pnpm` if missing), git, and the Flagsmith CLI v2 (`flagsmith --version`; install with `brew install Flagsmith/tap/flagsmith` or `curl -fsSL https://get.flagsmith.com | sh` if missing).
2. Clone the repository into ./perfflags and work inside it.
3. Install dependencies with `pnpm install`. If pnpm reports ignored build scripts, run `pnpm approve-builds esbuild sharp` and install again.
4. Install the browser the traffic runner uses: `pnpm --filter @perfflags/server exec playwright install chromium`.
5. Generate the demo shop images: `pnpm --filter @perfflags/web images:generate`.
6. Create the env file with `cp .env.example .env`, set FLAGSMITH_PROJECT_DIRECTORY to the absolute path of the repository, and link it for the web app with `ln -s ../../.env apps/web/.env.local`.
7. Connect Flagsmith:
   - Ask me to run `flagsmith login` myself (it opens a browser) and wait for me.
   - Run `flagsmith project list` and ask me which project and environment to use, or offer to create a project named perfflags with an environment named Development.
   - Bind the repository with `flagsmith init --project <project> --environment <client-side environment key>`.
   - Create a server-side key with `flagsmith environment key create <environment> --name perfflags-shop`. Its value is shown once: write it straight into .env as FLAGSMITH_SERVER_ENVIRONMENT_KEY without printing it.
   - Check that the environment has a warehouse: `flagsmith api api/v1/environments/<client-side key>/warehouse-connections/` must return at least one connection. If it returns none, send me to https://docs.flagsmith.com/experimentation/connect-a-warehouse and stop.
   - Write FLAGSMITH_ENVIRONMENT_KEY (the client-side key) and FLAGSMITH_PROJECT_ID into .env.
8. Now ask me, one at a time, for the keys you cannot create yourself, and write each into .env:
   - DATABASE_URL: a Postgres connection string (a free Neon database works).
   - ANTHROPIC_API_KEY: from https://console.anthropic.com.
   Never print a key back to me and never commit .env.
9. Create the database tables with `pnpm db:migrate`.
10. Start both apps as background shells in this session and keep them running: `pnpm dev:server` (API on http://localhost:4000) and `pnpm dev:web` (app on http://localhost:3000). Wait until `curl http://localhost:4000/api/health` returns ok and http://localhost:3000 loads.
11. Finish by telling me to open http://localhost:3000/dashboard, and walk me through the full test: scan http://localhost:3000/shop/product, ask the agent for a plan, enter my name and approve, approve the start, send 150 visitors, refresh the Flagsmith results about a minute after the traffic finishes, and ship the winner.

You will need: a Flagsmith account with Experimentation, a Postgres URL (Neon works) and an Anthropic API key. The agent asks for them at the end and keeps them in a git-ignored .env.

Star on GitHub