Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>FlagLens for Flagsmith (Community)New to Visual Studio Code? Get it now.
FlagLens for Flagsmith (Community)

FlagLens for Flagsmith (Community)

CodeNeuron58

|
3 installs
| (1) | Free
Live Flagsmith flag states, typo warnings and one-click flag creation inside VS Code. Works with self-hosted Flagsmith and Flagsmith Cloud. Community extension, not affiliated with Flagsmith.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

FlagLens icon

FlagLens for Flagsmith

The whole feature-flag lifecycle inside VS Code: create a flag, A/B test it, ship the winner and clean up, on your own self-hosted Flagsmith. Works with Flagsmith Cloud too.

CI BSD-3-Clause

A mistyped flag name doesn't crash anything. The SDK quietly returns false, and your new feature never ships. A mistyped metric event is worse: the experiment runs for days and counts nothing. FlagLens reads your flags, metrics and experiments from your Flagsmith server and checks your code as you type:

if (flags.isFeatureEnabled('new_chekout')) {
//                          ~~~~~~~~~~~ Unknown Flagsmith flag "new_chekout". Did you mean "new_checkout"?

flagsmith.trackEvent('Purchase', { identifier: visitorId });
//                    ~~~~~~~~ Won't count for any metric: metric events are case-sensitive,
//                             and the metric counts "purchase".

FlagLens is a community extension. It isn't made, endorsed or supported by Flagsmith.

What's different

  • A full Toggle Wars round without leaving the editor. Create the A/B flag, pick the metric, split the traffic, watch the results and roll out the winner, all from VS Code.
  • The whole flag lifecycle. Wrap code in a flag, toggle it safely, find every use, then clean it up when it's done: FlagLens removes the check and keeps the winning code.
  • Typo protection for flags and metric events. Both fail silently in Flagsmith's SDKs; FlagLens catches both, with one-click fixes.
  • Self-hosted first. Built and tested against Flagsmith running in Docker, including Experimentation with the "Flagsmith database" warehouse. A one-command demo kit is included.
  • Safe by default. Every write asks first, production asks twice, results never name a winner too early, and a read-only mode hides every write.

Why I built this. Flagsmith's own issue #4848 proposed an editor assistant (a Copilot extension) and noted it would be most useful through the flag lifecycle: creating a flag and wrapping code in it, and removing stale flags. The issue was closed as not planned; FlagLens does both, in VS Code.

Play a round: the four Toggle Wars rounds in VS Code

Round In FlagLens
01 Create a flag: a multivariate flag holds the versions you want to compare Select the code for version A (and Alt-select version B), run Wrap as A/B Test (Ctrl+Alt+Shift+F). FlagLens creates a multivariate flag with a keyed variant and writes the experiment check.
02 Pick a metric: the event that counts as success Hover a trackEvent('purchase') call to see which metric counts it, or Create Experiment Metric straight from it. Event typos and case mismatches are flagged as you type.
03 Split the traffic: how many users join and how they're split Start Experiment: pick the flag, environment, metric, rollout % and variation split (equal or custom), review, start.
04 Ship the winner: win probability per version, roll the winner out with the same flag Hover the flag: the experiment card shows users, conversions, lift, the 95% credible interval and chance to beat control per variant; Open panel shows them as charts. Roll out the winner ends the experiment and serves it.
After the round Rolling out offers Clean Up the Code: FlagLens removes the A/B checks and keeps the winning variation's code, then offers to archive the flag.

Features

See and fix

  • Flag explorer. A sidebar listing your project's environments and flags, with on/off icons and values, a beaker on flags with a running experiment, an Experiments list, and a Flag health row: flags no code uses ("unused"), keys in code that aren't in Flagsmith ("missing"), and flags ready to clean up ("stale": the experiment ended, or on or off everywhere and unchanged for 30 days).
  • Hover card. Hover any flag key to see its state and value in every environment, its description, the A/B split of multivariate flags, any experiment's live results, and links to toggle, find references, clean up or open it in the dashboard.
  • Typo and unknown-flag warnings. Flag keys that don't exist get a squiggle. Quick fixes offer Change to '…' (closest match) and Create flag in Flagsmith.
  • Metric-event warnings. trackEvent / track_event / TrackEvent names are checked against your experiment metrics: case-only mismatches are errors (they never count), near misses are warnings with "Did you mean", and events no metric uses are noted. Only active when the project has metrics.
  • Find references (Shift+F12 on a flag key, or from the sidebar) across the whole workspace, not just open files.
  • CodeLens. A line above each flag check, e.g. new_checkout: on in dev · off in staging · off in prod, with a clean up link on stale flags, and above each trackEvent the metric that counts it.
  • Experiment panel. Charts per variant: conversion rate, chance to beat control and the credible interval of the lift, with Refresh and Roll out buttons. Open it from the hover, the sidebar's Experiments list, or Show Experiments.
  • Status bar. Shows the server and active environment, and turns into a warning if the server goes down. Cached data stays visible. While experiments run, a second item shows how many.

Change

  • Wrap selection in flag (Ctrl+Alt+F): creates the flag (off everywhere) and wraps the code in the right check for JavaScript, TypeScript, React (JSX) or Python.
  • Wrap as A/B test (Ctrl+Alt+Shift+F): the selection becomes the control, a second selection (or a copy) becomes the variant, and the check uses the experiment SDK calls that record exposures. The variant starts at 0%, so nothing changes until you start an experiment.
  • Toggle from the editor. Per environment, from the sidebar, hover or CodeLens. It always asks first, and production asks twice.
  • Experiments. Create metrics, start experiments, refresh results and roll out the winner.
  • Clean up flag. Removes every supported check for a flag across the workspace and keeps the side you choose: the on or off code, or, for A/B checks, the code of one variation (the rolled-out winner is starred). You review each change in VS Code's Refactor Preview first, and Ctrl+Z undoes it. Shapes it can't remove safely (else-if chains, combined conditions) are listed, never guessed.

Hovers, warnings and CodeLens read from an in-memory cache that refreshes every 60 seconds, so they never wait on the network. A Get Started walkthrough on VS Code's Welcome page takes you through it.

How FlagLens uses Flagsmith

Flagsmith is the source of truth for everything FlagLens shows and changes. It talks to the Flagsmith Admin API (/api/v1) of the server you connect to, built and tested against a self-hosted Flagsmith running in Docker, with an Organisation API key sent as Authorization: Api-Key ….

When Admin API call
Connect (checks the key) GET /projects/
Every refresh (on connect, on Refresh, every 60 s) GET /projects/, GET /environments/?project={id}, GET /projects/{id}/features/, then per environment GET /environments/{env key}/featurestates/, …/experiment-metrics/ and …/experiments/ (the last two only when Experimentation is on)
Create a flag (command, quick fix, wrap) POST /projects/{id}/features/ (created off)
Wrap as A/B test POST /projects/{id}/features/ with a multivariate option, then PATCH /projects/{id}/features/{id}/mv-options/{option}/ to set its variant key
Toggle a flag PATCH /environments/{env key}/featurestates/{id}/, or, with feature versioning, POST /environments/{env id}/features/{feature id}/versions/
Create a metric POST /environments/{env key}/experiment-metrics/
Start an experiment POST /environments/{env key}/experiments/, then …/experiments/{id}/start/
Experiment card GET …/experiments/{id}/results/; Refresh results calls POST …/results/refresh/
Roll out the winner POST …/experiments/{id}/complete/ with the chosen variant, the control, or disable
Archive a flag (after clean up) PATCH /projects/{id}/features/{id}/ with is_archived

Everything else (hover cards, warnings, CodeLens, the sidebar, references) reads FlagLens' in-memory copy of that data, so typing never waits on the network. Lists are paginated and followed to the end, so large projects load fully.

Your app still reads flags with the normal Flagsmith SDKs; FlagLens reads the same flag keys and event names out of your code so it can tell you when one doesn't exist in Flagsmith.

Install

  • VS Code Marketplace: FlagLens for Flagsmith, or search for "FlagLens" in the Extensions view, or run:
    code --install-extension codeneuron58.flaglens-flagsmith
    
  • Open VSX (Cursor, VSCodium, Windsurf and other VS Code forks): codeneuron58/flaglens-flagsmith
  • From a release: download flaglens-flagsmith-<version>.vsix from GitHub Releases, then run Extensions: Install from VSIX…, or:
    code --install-extension flaglens-flagsmith-0.1.0.vsix
    

Quick start

Try the demo (one command)

Needs Docker and Node.js 18+. On Windows, run it in Git Bash or WSL (it's a Bash script).

git clone https://github.com/CodeNeuron58/flaglens-flagsmith.git
cd flaglens-flagsmith
bash demo/start.sh

This starts a self-hosted Flagsmith on http://localhost:8000 with Experimentation turned on, and seeds a Demo Shop project: Development, Staging and Production environments, five flags, a Purchases metric and a running checkout button colour experiment. It creates an Organisation API key (written to the git-ignored demo/.flaglens-demo.env) and runs the demo shop on http://localhost:3000.

The demo uses a fixed demo login and is meant for your own machine only. Don't expose it on a public network.

Then in VS Code:

  1. Run FlagLens: Connect to Flagsmith from the Command Palette.
  2. Server URL: http://localhost:8000. API key: the FLAGSMITH_ORG_API_KEY value from demo/.flaglens-demo.env.
  3. Open demo/shop/server.js: find the flag typo and the metric-event typo.
  4. In another terminal, run node demo/simulate.mjs to send a few hundred simulated visitors, then hover checkout_button_color and click Refresh results.

Stop the server with docker compose -f demo/docker-compose.yml down (add -v to wipe its data).

Use your own Flagsmith

  1. In the Flagsmith dashboard, open Organisation Settings → API Keys and create a key.
  2. Run FlagLens: Connect to Flagsmith and enter your server URL (for example https://flagsmith.example.com, or https://api.flagsmith.com for Flagsmith Cloud) and the key.
  3. If your organisation has several projects, pick one. Switch later with FlagLens: Select Project.

Experiment features need Flagsmith's Experimentation (beta): EXPERIMENTATION_ENABLED=true on a self-hosted server, and a warehouse connected per environment.

Commands

Command What it does
FlagLens: Connect to Flagsmith Set the server URL and API key
FlagLens: Sign Out Remove the stored API key
FlagLens: Refresh Flags Reload flags now
FlagLens: Select Environment Choose the environment shown in the status bar
FlagLens: Select Project Choose the project to work with
FlagLens: Create Flag Create a flag, off in every environment
FlagLens: Toggle Flag Turn a flag on or off in one environment
FlagLens: Wrap Selection in Flag Create a flag and wrap the selected code in it
FlagLens: Wrap as A/B Test… Create a multivariate flag and write the A/B check
FlagLens: Create Experiment Metric… Create a metric for an event your code sends
FlagLens: Start Experiment… Pick flag, metric and split, then start the experiment
FlagLens: Find Flag References Every use of a flag in the workspace
FlagLens: Clean Up Flag… Remove a flag's checks and keep one side
FlagLens: Show Flag Health Unused, missing and stale flags
FlagLens: Show Experiments Every experiment in the project; opens its panel
FlagLens: Show Log Open the FlagLens output channel

Refresh results and Roll out the winner are in the experiment card of a flag's hover.

Settings

Setting Default Description
flaglens.serverUrl "" Flagsmith server URL. Set by Connect.
flaglens.dashboardUrl "" Dashboard URL for links. Empty = derived from the server URL.
flaglens.refreshIntervalSeconds 60 Auto-refresh interval; 0 turns it off.
flaglens.productionEnvironmentPattern prod\|live Regex for environments that need a second confirmation. User settings only.
flaglens.languages JS, JSX, TS, TSX, Python, Go, Java Language IDs to scan.
flaglens.detection.useDefaultPatterns true Detect the standard SDK calls.
flaglens.detection.customPatterns [] Extra regexes for in-house wrappers.
flaglens.diagnostics.enabled true Warn about unknown flag keys.
flaglens.diagnostics.requireFlagsmithReference true Only warn in files that mention flagsmith.
flaglens.events.diagnostics true Check trackEvent names against experiment metrics.
flaglens.staleAfterDays 30 Days on or off everywhere, unchanged, before a flag counts as stale. 0 turns it off.
flaglens.codeLens.enabled true Show the state summary above flag checks.
flaglens.readOnly false Look, don't touch: hides and blocks every action that changes Flagsmith.

Supported SDK calls

SDK Calls detected
JavaScript / React client flagsmith.hasFeature('key'), flagsmith.getValue('key'), useFlags(['key', …])
Node.js server flags.isFeatureEnabled('key'), flags.getFeatureValue('key'), flags.getFlag('key')
Python flags.is_feature_enabled("key"), flags.get_feature_value("key"), flags.get_flag("key")
Go flags.IsFeatureEnabled("key"), flags.GetFeatureValue("key"), flags.GetFlag("key")
Java flags.isFeatureEnabled("key"), flags.getFeatureValue("key")
Experiments (any SDK) getExperimentFlag('key'), useExperiment('key'), get_experiment_flag("key"), GetExperimentFlag(ctx, "key", …)
Metric events trackEvent('event'), track_event("event"), TrackEvent("event")

Keys can use single quotes, double quotes or backticks, and contain letters, numbers, _, . and -.

Custom patterns

Wrap Flagsmith in your own helper? Add a regular expression with a named group key:

// settings.json
"flaglens.detection.customPatterns": [
  "isOn\\(\\s*[\"'](https://github.com/CodeNeuron58/flaglens-flagsmith/blob/HEAD?<key>[\\w.-]+)[\"']"
]

Without a key group, the last capturing group is used. To match a list of keys, capture the list contents in a group named list (each quoted string inside becomes a key).

Security and privacy

  • The API key is stored in VS Code secret storage (your OS keychain), per server. It is never written to settings.json, logs or error messages.
  • FlagLens only talks to the server URL you enter, using the Flagsmith Admin API with an Authorization: Api-Key … header.
  • FlagLens collects no telemetry.
  • Every change to Flagsmith (create, toggle, start or end an experiment, archive) goes through a command you run and asks for confirmation; production-like environments ask twice. Code changes from Clean Up are shown in a preview first and can be undone.
  • A repository can't weaken this: flaglens.productionEnvironmentPattern is read from your user settings only, and in Restricted Mode (an untrusted folder) FlagLens ignores the workspace's serverUrl, dashboardUrl and detection.customPatterns.
  • Want to look without being able to change anything? Turn on flaglens.readOnly: hovers, warnings, results and the sidebar keep working, and every action that writes to Flagsmith is hidden and blocked.

FlagLens needs an Organisation API key, which can change anything in that organisation. Create a dedicated key just for FlagLens (Organisation Settings → API Keys), preferably in an organisation that holds only the projects you work on, and revoke it when you no longer need it. Never paste it into a screenshot, a video or an issue.

Known limitations

  • Experimentation is a beta in Flagsmith; FlagLens follows its current API and parses results defensively.
  • Clean Up supports the shapes FlagLens' Wrap and Wrap as A/B Test commands write, plus plain if/else checks and value comparisons; else-if chains and combined conditions are left for you.
  • Toggling in environments that use v2 feature versioning publishes a new version immediately.
  • Segment and identity overrides aren't shown or edited.
  • Open-source self-hosted Flagsmith allows one project; FlagLens handles several for Cloud and Enterprise users.

Roadmap

  • More SDKs: Ruby, .NET, Flutter
  • Segment overrides in the hover card

Ideas and bug reports are welcome in issues.

Contributing

See CONTRIBUTING.md for setup, tests and the code layout. Issues labelled good first issue are a good place to start.

License

BSD-3-Clause, the same licence as Flagsmith.

FlagLens is an independent community project, not affiliated with or endorsed by Flagsmith. "Flagsmith" is used only to describe compatibility.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft