CLI
The featflags command for your terminal and CI, for flags, history, key lists, code references, experiment keys, exports and the LaunchDarkly importer.
Install
On Linux or macOS (x86_64 or arm64):
curl -fsSL https://raw.githubusercontent.com/featflags/cli/main/install.sh | sh
It installs the latest release in ~/.local/bin, after checking it against the release’s checksums. FEATFLAGS_VERSION=1.2.3 picks a release and FEATFLAGS_INSTALL_DIR another directory. On Windows, download the zip from the releases page.
Sign in
On your machine, sign in through the browser:
featflags login --api-url https://app.featflags.io
The app opens, asks you to sign in if you aren’t, and lists your organisations with your role in each. Pick one and the CLI gets a personal token for it, with your roles there, valid for 90 days, stored in your config directory (~/.config/featflags/config.json, %APPDATA%\featflags\config.json on Windows, or FEATFLAGS_CONFIG) and readable only by you. A token works in one organisation, so for another, log in again. --no-browser prints the link instead of opening it; the browser has to be on the same machine.
featflags whoami # who you are, in which organisation, with which roles
featflags logout # revokes the token and forgets it
In CI, don’t log in: set FEATFLAGS_API_URL to https://app.featflags.io and FEATFLAGS_TOKEN to an API token from Settings → API tokens, ideally a service token with only the roles the job needs.
Commands
export FEATFLAGS_PROJECT=acme # saves repeating --project
featflags projects list
featflags flags list # on or off in each environment
featflags flags get new-checkout # per environment: state, default, rules, targets, prerequisites
featflags flags toggle new-checkout --env production --off --comment "incident 4211"
featflags flags copy new-checkout --from staging --to production --parts rules,default -c "launch"
featflags changes list --flag new-checkout --env production --limit 20
featflags lists upload customers.txt --segment customers --list included
featflags lists upload qa.txt --flag new-checkout --env production --variant on --kind user
featflags experiment-key generate --env production
featflags code-refs scan --dry-run
featflags doc pull --project acme --env production --kind server --out flags.json # FEATFLAGS_PROJECT doesn't apply to doc pull
featflags export -o acme.zip
featflags import acme.zip
| Command | What it does |
|---|---|
flags toggle, flags copy |
Turn a flag on or off in an environment; copy chosen parts of its targeting from one environment to another, as one change. |
changes list |
A project’s history, filtered by flag and environment. |
lists upload |
Uploads a list of keys, one per line, to a segment or a flag’s individual targets, replacing the list, and waits until it’s live, showing progress; --no-wait returns at once. |
experiment-key generate |
Makes a new experiment key on your machine, prints it once and sends featflags only its fingerprint. --stop-running rotates it under running experiments, stopping them. |
code-refs scan |
Finds where the project’s flag keys are quoted in this checkout and uploads them for the branch; --dry-run only prints them. See Code references. |
doc pull |
Writes an environment’s flags exactly as SDKs receive them, so a build can bundle them and SDKs start from them without waiting for the network. --kind server needs writer access, like the server key. |
export |
The whole organisation as a zip: projects, flags, segments, members, history, list keys and analytics. Needs an admin or owner. |
import |
An export’s projects into the token’s organisation, as changes. It writes nothing if a project with the same key already has flags or segments; members, history and analytics stay behind. |
import launchdarkly |
Copies a LaunchDarkly project; see Importing from LaunchDarkly. |
The commands that change flags, lists and keys take --comment (-c), recorded with the change; environments can require one.
Output and exit codes
Commands print tables; --json prints the API’s JSON instead, for scripts.
| Exit code | Means |
|---|---|
| 0 | Done. |
| 1 | Usage error, including no token. |
| 2 | featflags (or LaunchDarkly, for an import) refused the request or couldn’t be reached; the reason is on stderr. |
| 3 | An import check failed (--strict, --verify). |
When featflags rate-limits a request, the CLI waits as long as it’s told (at most a minute) and tries again, up to five attempts.
Configuration
| Variable | Flag | |
|---|---|---|
FEATFLAGS_API_URL |
--api-url |
https://app.featflags.io. Defaults to the one login stored. |
FEATFLAGS_TOKEN |
--token |
An API token; defaults to the one login stored. |
FEATFLAGS_PROJECT |
--project |
The project for every command that takes one, but doc pull. |
FEATFLAGS_CONFIG |
Where login stores its token. |